• 🏆 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!

[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?
 
Level 19
Joined
Sep 4, 2007
Messages
2,826
  • 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:
Level 4
Joined
Sep 29, 2004
Messages
52
  • 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)
 
Level 6
Joined
Feb 2, 2005
Messages
205
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.
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
[trigger="Put these on top of actions"]Custom script: local integer bj_forLoopAIndex
Custom script: local integer bj_forLoopAIndexEnd[/trigger]
 
Level 6
Joined
Nov 28, 2007
Messages
203
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
 
Level 4
Joined
Sep 29, 2004
Messages
52
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.
Top