• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Trigger] Triggers w/ Loops

Status
Not open for further replies.
Level 4
Joined
Sep 29, 2004
Messages
52
Well, I havent seen a post that exactly answers problems with GUI loops, so I decided to post this. When it comes to making GUI triggers with loops it sometimes bug, for example this soul fissure spell trigger I'm working on:
Actions
Set SoulFissureCaster = (Casting unit)
Set SoulFissureCasterLoc = (Position of SonicBoomCaster)
Set SoulFissurePoint = (Target point of ability being cast)
Set SoulFissureAng = (Angle from SoulFissureCasterLoc to SoulFissurePoint)
Set SoulOffset = 0.00
Set SoulFissureDamage = (Units within 250.00 of (SoulFissureCasterLoc offset by (300.00 + SoulOffset) towards SoulFissureAng degrees) matching (((Matching unit) belongs to an ally of (Owner of SoulFissureCaster)) Equal to False))
For each (Integer A) from 1 to 4, do (Actions)
Loop - Actions
Wait 0.05 seconds
Unit Group - Pick every unit in SoulFissureDamage and do (Actions)
Loop - Actions
Unit - Cause SoulFissureCaster to damage (Picked unit), dealing (((Real((Intelligence of SoulFissureCaster (Include bonuses)))) x (3.00 + (1.00 x (Real((Level of Sonic Boom (Wind Master) for SoulFissureCaster)))))) + 50.00) damage of attack type Spells and damage type Death
Special Effect - Create a special effect at (Position of (Picked unit)) using Objects\Spawnmodels\Undead\UndeadDissipate\UndeadDissipate.mdl
Special Effect - Destroy (Last created special effect)
Unit - Create 1 Dummy Caster3 for (Owner of SoulFissureCaster) at (SoulFissureCasterLoc offset by (300.00 + SoulOffset) towards SoulFissureAng degrees) facing SoulFissureAng degrees
Set SoulStomper = (Last created unit)
Unit - Add a 1.50 second Generic expiration timer to SoulStomper
Unit - Order SoulStomper to Orc Tauren Chieftain - War Stomp
Set SoulOffset = (SoulOffset + 300.00)
Set SoulFissureDamage = (Units within 250.00 of (SoulFissureCasterLoc offset by (300.00 + SoulOffset) towards SoulFissureAng degrees) matching (((Matching unit) belongs to an ally of (Owner of SoulFissureCaster)) Equal to False))
Custom script: call DestroyGroup(udg_SoulFissureDamage)
Custom script: call RemoveLocation(udg_SoulFissureCasterLoc)
Custom script: call RemoveLocation(udg_SoulFissurePoint)


With this trigger, instead of looping 4 times, sometimes it may loop 2 times, or 6 times, and on one occasion, 20 times @_@. Is there anyway to make a more efficient spell, I even used LeakCheck to catch all the leaks or any other deficiencies within this trigger, does anyone have a solution to this problem?
 
  • Actions
  • Set SoulFissureCaster = (Casting unit)
  • Set SoulFissureCasterLoc = (Position of SonicBoomCaster)
  • Set SoulFissurePoint = (Target point of ability being cast)
  • Set SoulFissureAng = (Angle from SoulFissureCasterLoc to SoulFissurePoint)
  • Set SoulOffset = 0.00
  • Set SoulFissureDamage = (Units within 250.00 of (SoulFissureCasterLoc offset by (300.00 + SoulOffset) towards SoulFissureAng degrees) matching (((Matching unit) belongs to an ally of (Owner of SoulFissureCaster)) Equal to False))
  • For each (Integer A) from 1 to 4, do (Actions)
  • Loop - Actions
  • Wait 0.05 seconds
  • Unit Group - Pick every unit in SoulFissureDamage and do (Actions)
  • Loop - Actions
  • Unit - Cause SoulFissureCaster to damage (Picked unit), dealing (((Real((Intelligence of SoulFissureCaster (Include bonuses)))) x (3.00 + (1.00 x (Real((Level of Sonic Boom (Wind Master) for SoulFissureCaster)))))) + 50.00) damage of attack type Spells and damage type Death
  • Special Effect - Create a special effect at (Position of (Picked unit)) using Objects\Spawnmodels\Undead\UndeadDissipate\UndeadD issipate.mdl
  • Special Effect - Destroy (Last created special effect)
  • Unit - Create 1 Dummy Caster3 for (Owner of SoulFissureCaster) at (SoulFissureCasterLoc offset by (300.00 + SoulOffset) towards SoulFissureAng degrees) facing SoulFissureAng degrees
  • Set SoulStomper = (Last created unit)
  • Unit - Add a 1.50 second Generic expiration timer to SoulStomper
  • Unit - Order SoulStomper to Orc Tauren Chieftain - War Stomp
  • Set SoulOffset = (SoulOffset + 300.00)
  • Set SoulFissureDamage = (Units within 250.00 of (SoulFissureCasterLoc offset by (300.00 + SoulOffset) towards SoulFissureAng degrees) matching (((Matching unit) belongs to an ally of (Owner of SoulFissureCaster)) Equal to False))
  • Custom script: call DestroyGroup(udg_SoulFissureDamage)
  • Custom script: call RemoveLocation(udg_SoulFissureCasterLoc)
  • Custom script: call RemoveLocation(udg_SoulFissurePoint)
This trigger is still unreadable. Copy the whole trigger as text and add the trigger tag around it. We don't know if the second loop is inside or outside of your first loop. Usually people use Jass with locals to prevent the triggers to screw up(It depends on what your trigger does).
 
Last edited:
  • Soul Fissure
  • Events
  • Unit - A unit Finishes casting an ability
  • Conditions
  • (Ability being cast) Equal to Soul Fissure (Overlord)
  • Actions
  • Set SoulFissureCaster = (Casting unit)
  • Set SoulFissureCasterLoc = (Position of SonicBoomCaster)
  • Set SoulFissurePoint = (Target point of ability being cast)
  • Set SoulFissureAng = (Angle from SoulFissureCasterLoc to SoulFissurePoint)
  • Set SoulOffset = 0.00
  • Set SoulFissureDamage = (Units within 250.00 of (SoulFissureCasterLoc offset by (300.00 + SoulOffset) towards SoulFissureAng degrees) matching (((Matching unit) belongs to an ally of (Owner of SoulFissureCaster)) Equal to False))
  • For each (Integer A) from 1 to 4, do (Actions)
    • Loop - Actions
      • Wait 0.05 seconds
      • Unit Group - Pick every unit in SoulFissureDamage and do (Actions)
        • Loop - Actions
          • Unit - Cause SoulFissureCaster to damage (Picked unit), dealing (((Real((Intelligence of SoulFissureCaster (Include bonuses)))) x (3.00 + (1.00 x (Real((Level of SonicBoom (Wind Master) for SoulFissureCaster)))))) + 50.00) damage of attack type Spells and damage type Death
          • Special Effect - Create a special effect at (Position of (Picked unit)) using Objects\Spawnmodels\Undead\UndeadDissipate\UndeadD issipate.mdl
          • Special Effect - Destroy (Last created special effect)
      • Unit - Create 1 Dummy Caster3 for (Owner of SoulFissureCaster) at (SoulFissureCasterLoc offset by (300.00 + SoulOffset) towards SoulFissureAng degrees) facing SoulFissureAng degrees
      • Set SoulStomper = (Last created unit)
      • Unit - Add a 1.50 second Generic expiration timer to SoulStomper
      • Unit - Order SoulStomper to Orc Tauren Chieftain - War Stomp
      • Set SoulOffset = (SoulOffset + 300.00)
      • Set SoulFissureDamage = (Units within 250.00 of (SoulFissureCasterLoc offset by (300.00 + SoulOffset) towards SoulFissureAng degrees) matching (((Matching unit) belongs to an ally of (Owner of SoulFissureCaster)) Equal to False))
  • Custom script: call DestroyGroup(udg_SoulFissureDamage)
  • Custom script: call RemoveLocation(udg_SoulFissureCasterLoc)
  • Custom script: call RemoveLocation(udg_SoulFissurePoint)
 
The Trouble starts if you use more than one unit to cast the spell or the cool down of it is < 1.

Waits in loops are dangerous, plus the minimum wait is around 0.25 secs, no matter what you wrote in the gui.

You shouldn't use a Integer A loop for a spell or regular called Triggers, use a custom integer instead.
 
[trigger="Put these on top of actions"]Custom script: local integer bj_forLoopAIndex
Custom script: local integer bj_forLoopAIndexEnd[/trigger]
 
Just do as he says and put them on the top of the actions:gg:(Makes no sense, but is prolly the right thing to do)Or atleast test it o.O

Btw, need_o2? what does it really do? Kinda need it.. i think O_O
 
Ok, i put it in, like this.
  • Soul Fissure
  • Events
  • Unit - A unit Finishes casting an ability
  • Conditions
  • (Ability being cast) Equal to Soul Fissure (Overlord)
  • Actions
  • Custom script: local integer bj_forLoopAIndex
  • Custom script: local integer bj_forLoopAIndexEnd
  • Set SoulFissureCaster = (Casting unit)
  • Set SoulFissureCasterLoc = (Position of SonicBoomCaster)
  • Set SoulFissurePoint = (Target point of ability being cast)
  • Set SoulFissureAng = (Angle from SoulFissureCasterLoc to SoulFissurePoint)
  • Set SoulOffset = 0.00
  • Set SoulFissureDamage = (Units within 250.00 of (SoulFissureCasterLoc offset by (300.00 + SoulOffset) towards SoulFissureAng degrees) matching (((Matching unit) belongs to an ally of (Owner of SoulFissureCaster)) Equal to False))
  • For each (Integer A) from 1 to 4, do (Actions)
    • Loop - Actions
      • Wait 0.05 seconds
      • Unit Group - Pick every unit in SoulFissureDamage and do (Actions)
        • Loop - Actions
          • Unit - Cause SoulFissureCaster to damage (Picked unit), dealing (((Real((Intelligence of SoulFissureCaster (Include bonuses)))) x (3.00 + (1.00 x (Real((Level of SonicBoom (Wind Master) for SoulFissureCaster)))))) + 50.00) damage of attack type Spells and damage type Death
          • Special Effect - Create a special effect at (Position of (Picked unit)) using Objects\Spawnmodels\Undead\UndeadDissipate\UndeadD issipate.mdl
          • Special Effect - Destroy (Last created special effect)
      • Unit - Create 1 Dummy Caster3 for (Owner of SoulFissureCaster) at (SoulFissureCasterLoc offset by (300.00 + SoulOffset) towards SoulFissureAng degrees) facing SoulFissureAng degrees
      • Set SoulStomper = (Last created unit)
      • Unit - Add a 1.50 second Generic expiration timer to SoulStomper
      • Unit - Order SoulStomper to Orc Tauren Chieftain - War Stomp
      • Set SoulOffset = (SoulOffset + 300.00)
      • Set SoulFissureDamage = (Units within 250.00 of (SoulFissureCasterLoc offset by (300.00 + SoulOffset) towards SoulFissureAng degrees) matching (((Matching unit) belongs to an ally of (Owner of SoulFissureCaster)) Equal to False))
  • Custom script: call DestroyGroup(udg_SoulFissureDamage)
  • Custom script: call RemoveLocation(udg_SoulFissureCasterLoc)
  • Custom script: call RemoveLocation(udg_SoulFissurePoint)
It seems to be working, course I'll have to host a game to see if it truely works.
 
Status
Not open for further replies.
Back
Top