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

[Trigger] Optimizing my trigger with multiples waits with better index

Status
Not open for further replies.
Level 4
Joined
Dec 5, 2011
Messages
75
Sorry for the large trigger, i just learnt indexing these days so,anyone knows a better way to use less variables that makes my spell still MUI?im not sure if it is MUI but i tested it and it runs fine
A question, can i use those arrays variables with other spell?
  • SHIVA
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (==) Shiva
    • Actions
      • Set summonINDEX = (summonINDEX + 1)
      • Set Summon_Unit[summonINDEX] = (Triggering unit)
      • Set Summon_Loc[summonINDEX] = (Position of Summon_Unit[summonINDEX])
      • Set Summon_Point[summonINDEX] = (Target point of ability being cast)
      • Set Angle_Face = (Angle from Summon_Loc[summonINDEX] to Summon_Point[summonINDEX])
      • Set Angle_Offset[summonINDEX] = (Summon_Loc[summonINDEX] offset by 100.00 towards Angle_Face degrees)
      • Cinematic - Fade out and back in over 1.50 seconds using texture White Mask and color (100.00%, 100.00%, 100.00%) with 20.00% transparency
      • Animation - Change Summon_Unit[summonINDEX]'s animation speed to 0.00% of its original speed
      • Unit - Pause Summon_Unit[summonINDEX]
      • Special Effect - Create a special effect at Angle_Offset[summonINDEX] using war3mapImported\Comet.mdx
      • Set Seffect_Var[1] = (Last created special effect)
      • Special Effect - Destroy Seffect_Var[1]
      • Wait 2.50 seconds
      • Set Increasing_Shiva = (Increasing_Shiva + 1)
        • Do Multiple ActionsFor each (Integer A) from 1 to 5, do (Actions)
          • Loop - Actions
            • Special Effect - Create a special effect at (Summon_Loc[Increasing_Shiva] offset by (Random real number between 50.00 and 300.00) towards (Random real number between 1.00 and 360.00) degrees) using Abilities\Spells\Undead\FrostNova\FrostNovaTarget.mdl
            • Set Seffect_Var[9] = (Last created special effect)
            • Special Effect - Destroy Seffect_Var[9]
            • Wait 0.20 seconds
      • Special Effect - Create a special effect at Angle_Offset[Increasing_Shiva] using war3mapImported\frost warp.mdx
      • Set Seffect_Var[2] = (Last created special effect)
      • Special Effect - Destroy Seffect_Var[1]
      • Unit - Create 1 Shiva for (Owner of Summon_Unit[Increasing_Shiva]) at Angle_Offset[Increasing_Shiva] facing Angle_Face degrees
      • Set Summoning_Unit[Increasing_Shiva] = (Last created unit)
      • Unit - Make Summoning_Unit[Increasing_Shiva] face Summon_Point[Increasing_Shiva] over 0.05 seconds
      • Animation - Play Summoning_Unit[Increasing_Shiva]'s channel animation
      • Unit - Add a 13.50 second Generic expiration timer to Summoning_Unit[Increasing_Shiva]
      • Wait 2.50 seconds
      • Set summonINDEX2 = (summonINDEX2 + 1)
      • Unit - Create 1 Ice Orb for (Owner of Summon_Unit[summonINDEX2]) at Angle_Offset[summonINDEX2] facing Angle_Face degrees
      • Set Effects_Unit[1] = (Last created unit)
      • Special Effect - Create a special effect attached to the origin of Summoning_Unit[summonINDEX2] using war3mapImported\s_PowerCharge_Effect_Portrait.mdx
      • Set Seffect_Var[3] = (Last created special effect)
      • Special Effect - Destroy Seffect_Var[3]
      • Unit - Add a 5.00 second Generic expiration timer to Effects_Unit[1]
      • Trigger - Turn on SHIVA EFFECT <gen>
      • Wait 3.00 seconds
      • Trigger - Turn off SHIVA EFFECT <gen>
      • Set summonINDEX3 = (summonINDEX3 + 1)
      • Animation - Play Summoning_Unit[summonINDEX3]'s spell animation
      • Unit - Create 1 Ice Blast for (Owner of Summon_Unit[summonINDEX3]) at Angle_Offset[summonINDEX3] facing Angle_Face degrees
      • Set Effects_Unit[2] = (Last created unit)
      • Unit - Add a 3.00 second Generic expiration timer to Effects_Unit[2]
      • Set SummonPickedUnits[summonINDEX3] = (Units within 500.00 of Summon_Point[summonINDEX3] matching ((((Matching unit) belongs to an ally of (Owner of (Triggering unit))) Equal to (==) False) and (((Matching unit) is alive) Equal to (==) True)))
      • Wait 3.00 seconds
      • Set summonINDEX4 = (summonINDEX4 + 1)
      • Unit Group - Pick every unit in SummonPickedUnits[summonINDEX4] and do (Actions)
        • Loop - Actions
          • Set Summon_Target[summonINDEX4] = (Picked unit)
          • Set Summoning_Loc[summonINDEX4] = (Position of Summon_Target[summonINDEX4])
          • Unit - Create 1 Dummy0 for (Owner of Summon_Unit[summonINDEX4]) at Summon_Point[summonINDEX4] facing Angle_Face degrees
          • Set Effects_Unit[summonINDEX4] = (Last created unit)
          • Unit - Add Shivas to (Last created unit)
          • Unit - Order (Last created unit) to Orc Tauren Chieftain - War Stomp
          • Unit - Add a 3.00 second Generic expiration timer to Effects_Unit[summonINDEX4]
          • Special Effect - Create a special effect at Summoning_Loc[summonINDEX4] using Abilities\Spells\Undead\FreezingBreath\FreezingBreathMissile.mdl
          • Set Seffect_Var[7] = (Last created special effect)
          • Special Effect - Destroy Seffect_Var[7]
      • Countdown Timer - Start Time_Expires as a One-shot timer that will expire in 3.00 seconds
      • Wait 3.50 seconds
      • Set summonINDEX5 = (summonINDEX5 + 1)
      • Animation - Play Summoning_Unit[summonINDEX5]'s attack animation
      • Unit - Unpause Summon_Unit[summonINDEX5]
      • Animation - Change Summon_Unit[summonINDEX5]'s animation speed to 100.00% of its original speed
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • summonINDEX Equal to (==) Increasing_Shiva
          • Then - Actions
            • Set summonINDEX = 0
            • Set Increasing_Shiva = 0
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • summonINDEX2 Equal to (==) Increasing_Shiva
          • Then - Actions
            • Set summonINDEX2 = 0
            • Set Increasing_Shiva = 0
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • summonINDEX2 Equal to (==) summonINDEX3
          • Then - Actions
            • Set summonINDEX2 = 0
            • Set summonINDEX3 = 0
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • summonINDEX3 Equal to (==) summonINDEX4
          • Then - Actions
            • Set summonINDEX3 = 0
            • Set summonINDEX4 = 0
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • summonINDEX4 Equal to (==) summonINDEX5
          • Then - Actions
            • Set summonINDEX4 = 0
            • Set summonINDEX5 = 0
          • Else - Actions
      • Custom script: call RemoveLocation (udg_Summon_Loc[udg_Increasing_Shiva])
      • Custom script: call RemoveLocation (udg_Summon_Loc[udg_summonINDEX])
      • Custom script: call RemoveLocation (udg_Summon_Loc[udg_summonINDEX2])
      • Custom script: call RemoveLocation (udg_Summon_Loc[udg_summonINDEX3])
      • Custom script: call RemoveLocation (udg_Summon_Loc[udg_summonINDEX4])
      • Custom script: call RemoveLocation (udg_Summon_Loc[udg_summonINDEX5])
      • Custom script: call RemoveLocation (udg_Summoning_Loc[udg_summonINDEX4])
      • Custom script: call RemoveLocation (udg_Summoning_Loc[udg_summonINDEX5])
      • Custom script: call RemoveLocation (udg_Summon_Point[udg_Increasing_Shiva])
      • Custom script: call RemoveLocation (udg_Summon_Point[udg_summonINDEX])
      • Custom script: call RemoveLocation (udg_Summon_Point[udg_summonINDEX2])
      • Custom script: call RemoveLocation (udg_Summon_Point[udg_summonINDEX3])
      • Custom script: call RemoveLocation (udg_Summon_Point[udg_summonINDEX4])
      • Custom script: call RemoveLocation (udg_Summon_Point[udg_summonINDEX5])
      • Custom script: call RemoveLocation (udg_Angle_Offset[udg_Increasing_Shiva])
      • Custom script: call RemoveLocation (udg_Angle_Offset[udg_summonINDEX])
      • Custom script: call RemoveLocation (udg_Angle_Offset[udg_summonINDEX2])
      • Custom script: call RemoveLocation (udg_Angle_Offset[udg_summonINDEX3])
 
Use local variables, there is no need for indexing here.
  • Example
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Custom script: local integer i = 0
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Set i = (i + 1)
      • Wait 1.25 seconds
      • Custom script: set udg_i = i
      • Custom script: set i = i + 1
      • Game - Display to (All players) the text: (String(i))
      • Wait 1.25 seconds
      • Custom script: set udg_i = i
      • Game - Display to (All players) the text: (String(i))
It will display:
0
1
 
Level 4
Joined
Dec 5, 2011
Messages
75
I tried locals but somehow it was overlaping but i will try again thanks!
When should i use index then?
Can i use my global i with other spells?im also going to use the same unit and point variables in other spells too
 
Level 4
Joined
Dec 5, 2011
Messages
75
Sorry,i couldnt make it work, the spell is overlaping.
Can you modify my trigger just until the second wait?I think im not really sure if i know how to use locals
 
Last edited:
Level 4
Joined
Dec 5, 2011
Messages
75
Sorry for the double post but i think my EDIT buttom is broken
Hey i figured out how to do it with globals can you check if its ok?
Questions:
-Why does my jass helper shows undeclared variable error if i set it inside Unit Groups?
-Do i need to null all locals variables i made?
-Do i need to use locals for everything?dummies,effects etc.
-I found indexing very helpful, when is it important?


  • SHIVA LOCALS 2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (==) Shiva
    • Actions
      • Custom script: local unit summonunit
      • Custom script: local unit summontarget
      • Custom script: local unit summoningunit
      • Custom script: local location summonloc
      • Custom script: local location summoningloc
      • Custom script: local location summonpoint
      • Custom script: local location angleoffset
      • Custom script: local group summonpickedunit=CreateGroup()
      • Set SummonUnit = (Triggering unit)
      • Custom script: set summonunit = udg_SummonUnit
      • Set SummonLoc = (Position of SummonUnit)
      • Custom script: set summonloc = udg_SummonLoc
      • Set SummonPoint = (Target point of ability being cast)
      • Custom script: set summonpoint = udg_SummonPoint
      • Set Angle_Face = (Angle from SummonLoc to SummonPoint)
      • Set AngleOffset = (SummonLoc offset by 100.00 towards Angle_Face degrees)
      • Custom script: set angleoffset = udg_AngleOffset
      • Cinematic - Fade out and back in over 1.50 seconds using texture White Mask and color (100.00%, 100.00%, 100.00%) with 20.00% transparency
      • Animation - Change SummonUnit's animation speed to 0.00% of its original speed
      • Unit - Pause SummonUnit
      • Special Effect - Create a special effect at AngleOffset using war3mapImported\Comet.mdx
      • Set Seffect_Var[1] = (Last created special effect)
      • Special Effect - Destroy Seffect_Var[1]
      • Wait 2.50 seconds
      • Custom script: set udg_SummonUnit = summonunit
      • Custom script: set udg_SummonLoc = summonloc
      • Custom script: set udg_SummonPoint = summonpoint
      • Custom script: set udg_AngleOffset = angleoffset
        • Do Multiple ActionsFor each (Integer A) from 1 to 5, do (Actions)
          • Loop - Actions
            • Special Effect - Create a special effect at (SummonLoc offset by (Random real number between 50.00 and 300.00) towards (Random real number between 1.00 and 360.00) degrees) using Abilities\Spells\Undead\FrostNova\FrostNovaTarget.mdl
            • Set Seffect_Var[9] = (Last created special effect)
            • Special Effect - Destroy Seffect_Var[9]
            • Wait 0.20 seconds
      • Special Effect - Create a special effect at AngleOffset using war3mapImported\frost warp.mdx
      • Set Seffect_Var[2] = (Last created special effect)
      • Special Effect - Destroy Seffect_Var[1]
      • Unit - Create 1 Shiva for (Owner of SummonUnit) at AngleOffset facing Angle_Face degrees
      • Set SummoningUnit = (Last created unit)
      • Custom script: set summoningunit = udg_SummoningUnit
      • Unit - Make SummoningUnit face SummonPoint over 0.05 seconds
      • Animation - Play SummoningUnit's channel animation
      • Unit - Add a 13.50 second Generic expiration timer to SummoningUnit
      • Wait 2.50 seconds
      • Custom script: set udg_SummonUnit = summonunit
      • Custom script: set udg_SummonLoc = summonloc
      • Custom script: set udg_SummonPoint = summonpoint
      • Custom script: set udg_AngleOffset = angleoffset
      • Custom script: set udg_SummoningUnit = summoningunit
      • Unit - Create 1 Ice Orb for (Owner of SummonUnit) at AngleOffset facing Angle_Face degrees
      • Set Effects_Unit[1] = (Last created unit)
      • Special Effect - Create a special effect attached to the origin of SummoningUnit using war3mapImported\s_PowerCharge_Effect_Portrait.mdx
      • Set Seffect_Var[3] = (Last created special effect)
      • Special Effect - Destroy Seffect_Var[3]
      • Unit - Add a 5.00 second Generic expiration timer to Effects_Unit[1]
      • Trigger - Turn on SHIVA EFFECT Copy <gen>
      • Wait 3.00 seconds
      • Custom script: set udg_SummonUnit = summonunit
      • Custom script: set udg_SummonLoc = summonloc
      • Custom script: set udg_SummonPoint = summonpoint
      • Custom script: set udg_AngleOffset = angleoffset
      • Custom script: set udg_SummoningUnit = summoningunit
      • Trigger - Turn off SHIVA EFFECT Copy <gen>
      • Animation - Play SummoningUnit's spell animation
      • Unit - Create 1 Ice Blast for (Owner of SummonUnit) at AngleOffset facing Angle_Face degrees
      • Set Effects_Unit[2] = (Last created unit)
      • Unit - Add a 3.00 second Generic expiration timer to Effects_Unit[2]
      • Set SummonPickedUnit = (Units within 500.00 of SummonPoint matching ((((Matching unit) belongs to an ally of (Owner of (Triggering unit))) Equal to (==) False) and (((Matching unit) is alive) Equal to (==) True)))
      • Custom script: set summonpickedunit = udg_SummonPickedUnit
      • Wait 3.00 seconds
      • Custom script: set udg_SummonUnit = summonunit
      • Custom script: set udg_SummonLoc = summonloc
      • Custom script: set udg_SummonPoint = summonpoint
      • Custom script: set udg_AngleOffset = angleoffset
      • Custom script: set udg_SummoningUnit = summoningunit
      • Custom script: set udg_SummonPickedUnit = summonpickedunit
      • Unit Group - Pick every unit in SummonPickedUnit and do (Actions)
        • Loop - Actions
          • Set SummonTarget = (Picked unit)
          • Set SummoningLoc = (Position of SummonTarget)
          • Unit - Create 1 Dummy0 for (Owner of SummonUnit) at SummonPoint facing Angle_Face degrees
          • Set Effects_Unit[5] = (Last created unit)
          • Unit - Add Shivas to (Last created unit)
          • Unit - Order (Last created unit) to Orc Tauren Chieftain - War Stomp
          • Unit - Add a 3.00 second Generic expiration timer to Effects_Unit[5]
          • Special Effect - Create a special effect at SummoningLoc using Abilities\Spells\Undead\FreezingBreath\FreezingBreathMissile.mdl
          • Set Seffect_Var[7] = (Last created special effect)
          • Special Effect - Destroy Seffect_Var[7]
      • Custom script: set summoningloc = udg_SummoningLoc
      • Custom script: set summontarget = udg_SummonTarget
      • Countdown Timer - Start Time_Expires as a One-shot timer that will expire in 3.00 seconds
      • Wait 3.50 seconds
      • Custom script: set udg_SummonUnit = summonunit
      • Custom script: set udg_SummonLoc = summonloc
      • Custom script: set udg_SummonPoint = summonpoint
      • Custom script: set udg_AngleOffset = angleoffset
      • Custom script: set udg_SummoningUnit = summoningunit
      • Custom script: set udg_SummonPickedUnit = summonpickedunit
      • Custom script: set udg_SummonTarget = summontarget
      • Custom script: set udg_SummoningLoc = summoningloc
      • Animation - Play SummoningUnit's attack animation
      • Unit - Unpause SummonUnit
      • Animation - Change SummonUnit's animation speed to 100.00% of its original speed
      • Custom script: call RemoveLocation (udg_SummonLoc)
      • Custom script: call RemoveLocation (udg_SummoningLoc)
      • Custom script: call RemoveLocation (udg_SummonPoint)
      • Custom script: call RemoveLocation (udg_AngleOffset)
 
-Why does my jass helper shows undeclared variable error if i set it inside Unit Groups?
It create new function, and your locals won't work in it.
Do i need to null all locals variables i made?
Only handles: units, players...
Do i need to use locals for everything?dummies,effects etc.
Not really just for things you use after wait.
-I found indexing very helpful, when is it important?
It just use arrays to generate new globals when you cast spell again and then restore their place once when spell end, making room for new ones.
 
Status
Not open for further replies.
Top