• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece!🔗 Click here to enter!

Loop problem

Status
Not open for further replies.
Level 3
Joined
Jan 2, 2010
Messages
34
  • Nether Chains
    • Event
      • Unit - A unit Starts using ability
    • Conditions
      • (Ability being cast) Equal to Nether Chains
    • Actions
      • Set TempLoc9 = (Target point of ability being cast)
      • Set TempLoc10 = (Target point of ability being cast)
      • Special Effect - Create a special effect at TempLoc9 using Abilities\Spells\Other\Drain\DrainCaster.mdl
      • Set SpecialEffect[1] = (Last created special effect)
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Wait 2.00 game-time seconds
          • Game - Display to (All players) the text: (String((Integer A)))
          • Special Effect - Create a special effect at TempLoc10 using Abilities\Spells\Undead\DeathCoil\DeathCoilSpecialArt.mdl
          • Special Effect - Destroy (Last created special effect)
          • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at TempLoc9 facing default degrees
          • Unit - Add a 1.50 second expiration timer to (Last created unit)
          • Unit - Add Nether Chains(dummy) to (Last created unit)
          • Unit - Set level of Nether Chains(dummy) for (Last created unit) to (Level of Nether Chains for (Triggering unit))
          • Set GroupVar4 = (Units within 900.00 of TempLoc9 matching ((((Owner of (Matching unit)) is an enemy of (Owner of (Triggering unit))) Equal to True) and (((Matching unit) is alive) Equal to True)))
          • Set UnitVarPicked2 = (Random unit from GroupVar4)
          • Unit - Order (Last created unit) to Orc - Mage: Chain Lightning UnitVarPicked2
          • Custom script: call DestroyGroup (udg_GroupVar4)
      • Special Effect - Destroy SpecialEffect[1]
      • Custom script: call RemoveLocation (udg_TempLoc9)
      • Custom script: call RemoveLocation (udg_TempLoc10)
At my last map this spell works good but here it's shot 2 times and dissapear.
I added a Game - Display text (Integer A) to see where is bug and i saw 1 -> 34 ;o
Can someone tell me what i can do to fix it?
Thanks
 
Level 6
Joined
Mar 22, 2009
Messages
276
Yep TriggerHappy is right. Use a custom integer variable. Why use it? Here.
Example.
In Trigger1 I have a function For each (Integer A) from 1 to 10, do Actions..
now it runs and begin increasing the value for Integer A. Assuming it is now 4.
In Trigger2 I also have a function For each (Integer A) from 1 to 10, do Actions..
then it runs too while trigger1 runs.. Trigger2 will begin counting from 4.
That's it :)
 
To go along with what these guys are saying, use this because it's MUI:

  • Nether Chains
    • Event
      • Unit - A unit Starts using ability
    • Conditions
      • (Ability being cast) Equal to Nether Chains
    • Actions
      • -------- - - - Configure custom scripts - - - --------
      • Custom script: local integer i = 0
      • Custom script: local real x = GetSpellTargetX( )
      • Custom script: local real y = GetSpellTargetY( )
      • Custom script: local location loc = GetSpellTargetLoc( )
      • Custom script: local effect fx = AddSpecialEffect(Abilities\\Spells\\Other\\Drain\\DrainCaster.mdl,x,y)
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Wait 2.00 game-time seconds
          • Custom script: call DestroyEffect(AddSpecialEffect(Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl,x,y))
          • -------- - - - Configure variables - - - --------
          • Custom script: set udg_TempLoc9 = loc
          • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at TempLoc9 facing default degrees
          • Set GroupVar4 = (Units within 900.00 of TempLoc9 matching ((((Owner of (Matching unit)) is an enemy of (Owner of (Triggering unit))) Equal to True) and (((Matching unit) is alive) Equal to True)))
          • Custom script: call RemoveLocation(udg_TempLoc9)
          • -------- - - - Have dummy do actions - - - --------
          • Unit - Add a 1.50 second expiration timer to (Last created unit)
          • Unit - Add Nether Chains(dummy) to (Last created unit)
          • Unit - Set level of Nether Chains(dummy) for (Last created unit) to (Level of Nether Chains for (Triggering unit))
          • Set UnitVarPicked2 = (Random unit from GroupVar4)
          • Unit - Order (Last created unit) to Orc - Mage: Chain Lightning UnitVarPicked2
          • Custom script: call DestroyGroup(udg_GroupVar4)
          • -------- - - - Failsafes the "Integer A" - - - --------
          • Custom script: set i = i + 1
          • Custom script: exitwhen i > 10
      • -------- - - - Clean up leaks - - - --------
      • Custom script: call DestroyEffect(fx)
      • Custom script: set fx = null
      • Custom script: call RemoveLocation(loc)
      • Custom script: set loc = null
 
Status
Not open for further replies.
Top