• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Converting 4 GUI trigs to 1 JASS trig

Status
Not open for further replies.
Level 7
Joined
Feb 26, 2005
Messages
210
I have a spell that takes up four triggers. It works 100% correctly but I know if I use JASS I could probably make it just one trigger.

The spell is called "Cry of the Undead". It animates all dead units in an area around the Hero but if the caster stops channleing for any reason the animated units are destroyed. Here are the triggers:

  • Cry of the Undead
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Cry of the Undead
    • Actions
      • Set L = (Position of (Casting unit))
      • Unit - Create 1 DoorMan for (Owner of (Casting unit)) at L facing Default building facing degrees
      • Unit - Add Animate Dead * to (Last created unit)
      • Unit - Set level of Animate Dead * for (Last created unit) to (Level of (Ability being cast) for (Casting unit))
      • Unit - Set the custom value of (Last created unit) to V
      • Set V = (V + 1)
      • Set Summoner[(Custom value of (Last created unit))] = (Casting unit)
      • Custom script: call RemoveLocation(udg_L)
  • Summon Deadling
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set G = (Units in (Entire map) matching ((Unit-type of (Matching unit)) Equal to DoorMan))
      • Unit Group - Pick every unit in G and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Undead Death Knight - Animate Dead
      • Custom script: call DestroyGroup(udg_G)
  • Deadling Summoned
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • ((Summoned unit) has buff Deadel) Equal to True
    • Actions
      • Unit - Remove classification of A sapper from (Summoned unit)
      • Unit - Set the custom value of (Summoned unit) to V
      • Set V = (V + 1)
      • Set Summoner[(Custom value of (Summoned unit))] = Summoner[(Custom value of (Summoning unit))]
  • Stop Channleing
    • Events
      • Unit - A unit Stops casting an ability
    • Conditions
      • (Ability being cast) Equal to Cry of the Undead
    • Actions
      • Set G = (Units owned by (Owner of (Casting unit)) matching (((Unit-type of (Matching unit)) Equal to DoorMan) or (((Matching unit) has buff Deadel) Equal to True)))
      • Unit Group - Pick every unit in G and do (Custom script: call KillSummonedUnit(GetEnumUnit(), GetSpellAbilityUnit()))
      • Custom script: call DestroyGroup(udg_G)
JASS:
function KillSummonedUnit takes unit summoned, unit summoner returns nothing
    if udg_Summoner[GetUnitUserData(summoned)] == summoner then
        call KillUnit(summoned)
    endif
endfunction
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
It is possiable but efectivaly, 3/4 triggers will be leaked meaning you can not turn them off/destroy them.
In the int function, use a local trigger variable and make a fresh trigger in it. Then attach one of the other triggers to it and repeat for the other triggers.
Then just paste your action functions in and your done.

Remember to optimize since there are probably a few USLESS functions caused by the stupidity of GUI.
Also you can use locals for some of the triggers to replace the globals.
 
Level 11
Joined
Oct 13, 2005
Messages
233
I have a spell that takes up four triggers. It works 100% correctly but I know if I use JASS I could probably make it just one trigger.

I'm not entirely sure you know what a trigger is exactly. Are you referring to those "pages" you create when you push the new trigger button? This spell would still require at least 3 triggers in order to work properly, but they could all be put onto one of those "pages". A trigger isn't one of those "pages", it's just like a unit, special effect, etc in that it's an object. It just happens to be that these objects can detect events, check conditions for those events, and then call a function for the actions.

Also, how much experience with JASS do you have? Is this the first major thing you're trying to do? Are you just looking to fit 4 "pages" into 1? If you're going to convert the GUI triggers to JASS, you might as well take advantage of the features of JASS which could require you to change a lot of things. However, the more you practice with JASS the better you'll be at it.

Also, are you asking for help with this or what? I don't really see any questions or anything in your post.
 
Level 11
Joined
Jul 12, 2005
Messages
764
I think he heared things about local triggers, and he wants to implement the 4 triggers into 1, by creating local triggers. But this is exactly what Doc wrote, they are global triggers, you cannot refer to them (turn on/off, etc..) like they were "normal" ones.
 
Status
Not open for further replies.
Top