- Joined
- Sep 6, 2015
- Messages
- 576
As the title says, I want each trigger execution to perform in a different variable, and not to overwrite the variable which is set in it. This question bothered me for quite a some time now.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Untitled Trigger 007

Events


Unit - Dreadlord 0175 <gen> Starts the effect of an ability

Conditions


(Ability being cast) Equal to Sleep

Actions


Set temp_integer = (Execution count of (This trigger))


Set counter = (counter + 1)


Set unit1[temp_integer] = (Target unit of ability being cast)


Unit - Make unit1[temp_integer] Invulnerable


If (All Conditions are True) then do (Then Actions) else do (Else Actions)



If - Conditions




(Level of Sleep for (Casting unit)) Equal to 1



Then - Actions




Wait 20.00 seconds




Unit - Make unit1[temp_integer] Vulnerable



Else - Actions




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






(Level of Sleep for (Casting unit)) Equal to 2





Then - Actions






Wait 40.00 seconds






Unit - Make unit1[temp_integer] Vulnerable





Else - Actions






If (All Conditions are True) then do (Then Actions) else do (Else Actions)







If - Conditions








(Level of Sleep for (Casting unit)) Equal to 3







Then - Actions








Wait 60.00 seconds








Unit - Make unit1[temp_integer] Vulnerable







Else - Actions
Because the integer value cannot have partial numbers, only whole, so I left out that "-.04".Set SleepDuration[TempInteger] = SleepDuration[TempInteger] - .04
Untitled Trigger 008

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Sleep

Actions


Set counter = (counter + 1)


Set SleepUnit[counter] = (Target unit of ability being cast)


Set SleepDuration[counter] = (20 x (Level of Sleep for (Triggering unit)))


Unit - Make SleepUnit[counter] Invulnerable


If (All Conditions are True) then do (Then Actions) else do (Else Actions)



If - Conditions




counter Equal to 1



Then - Actions




Trigger - Turn on Untitled Trigger 009 <gen>



Else - Actions
Untitled Trigger 009

Events


Time - Every 0.04 seconds of game time

Conditions

Actions


For each (Integer TempInteger) from 1 to counter, do (Actions)



Loop - Actions




Set SleepDuration[TempInteger] = SleepDuration[TempInteger]




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






SleepDuration[TempInteger] Less than or equal to 0





Then - Actions






Unit - Make SleepUnit[TempInteger] Vulnerable






Set SleepUnit[TempInteger] = SleepUnit[counter]






Set SleepDuration[TempInteger] = SleepDuration[counter]






Set TempInteger = (TempInteger - 1)






Set counter = (counter - 1)






If (counter Equal to 0) then do (Trigger - Turn off (This trigger)) else do (Do nothing)





Else - Actions
It will not work because the SleepDuration will never get to 0 value. You may need to change that integer variable to a real variable so you can decrease it based on an interval.
I had changed that real variable to integer because "Level of Sleep for Triggering Unit" couldn't be used with a real variable. Now I added the ability level condition in front of everything and changed it to real and it works fine. Here are the complete triggers:Set SleepDuration[Counter] = 20. * Level of Sleep for Triggering Unit (Real Variable)
Trigger 1

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Sleep

Actions


If (All Conditions are True) then do (Then Actions) else do (Else Actions)



If - Conditions




(Level of Sleep for (Triggering unit)) Equal to 1



Then - Actions




Set counter = (counter + 1)




Set SleepUnit[counter] = (Target unit of ability being cast)




Set SleepDuration[counter] = (20.00 x 1.00)




Unit - Make SleepUnit[counter] Invulnerable




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






counter Equal to 1





Then - Actions






Trigger - Turn on Untitled Trigger 009 <gen>





Else - Actions



Else - Actions




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






(Level of Sleep for (Triggering unit)) Equal to 2





Then - Actions






Set counter = (counter + 1)






Set SleepUnit[counter] = (Target unit of ability being cast)






Set SleepDuration[counter] = (20.00 x 2.00)






Unit - Make SleepUnit[counter] Invulnerable






If (All Conditions are True) then do (Then Actions) else do (Else Actions)







If - Conditions








counter Equal to 1







Then - Actions








Trigger - Turn on Untitled Trigger 009 <gen>







Else - Actions





Else - Actions






If (All Conditions are True) then do (Then Actions) else do (Else Actions)







If - Conditions








(Level of Sleep for (Triggering unit)) Equal to 3







Then - Actions








Set counter = (counter + 1)








Set SleepUnit[counter] = (Target unit of ability being cast)








Set SleepDuration[counter] = (20.00 x 3.00)








Unit - Make SleepUnit[counter] Invulnerable








If (All Conditions are True) then do (Then Actions) else do (Else Actions)









If - Conditions










counter Equal to 1









Then - Actions










Trigger - Turn on Untitled Trigger 009 <gen>









Else - Actions







Else - Actions
Trigger 2

Events


Time - Every 0.04 seconds of game time

Conditions

Actions


For each (Integer TempInteger) from 1 to counter, do (Actions)



Loop - Actions




Set SleepDuration[TempInteger] = (SleepDuration[TempInteger] - 0.04)




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






SleepDuration[TempInteger] Less than or equal to 0.00





Then - Actions






Unit - Make SleepUnit[TempInteger] Vulnerable






Set SleepUnit[TempInteger] = SleepUnit[counter]






Set SleepDuration[TempInteger] = SleepDuration[counter]






Set TempInteger = (TempInteger - 1)






Set counter = (counter - 1)






If (counter Equal to 0) then do (Trigger - Turn off (This trigger)) else do (Do nothing)





Else - Actions
What do you mean with that OR condition? Where to add it and what exactly to add?You also need to make the condition 'OR' statement together with the duration and if the target dies.
Set SleepDuration[counter] = ( 20 x (Real(Level of Ability from triggering unit)))
Or - ( Multiple Conditions )
SleepDuration[TempInteger] Less than or equal to 0.00
( SleepUnit[TempInteger] is dead ) Equal to true
Ok, thanks. Here are the final triggers:No, nesting the condition for the level is not the solution so remove that if's statements in the trigger 1.
All you have to do is to find the GUI function inside the parameter of that real variable;
( Conversion - Integer to Real ) or known as I2R.
( It seems pOke forgot to include that conversion )
then you can now freely put an integer value
( level ) into that real variable.
So it should look like:
Set SleepDuration[counter] = ( 20 x (Integer(Level of Ability from triggering unit)))![]()
Put the 'Or' statement here together with the checking if sleep unit is dead.
Or - ( Multiple Conditions )![]()
SleepDuration[TempInteger] Less than or equal to 0.00![]()
( SleepUnit[TempInteger] is dead ) Equal to true![]()
^ Unit is dead can be found on a boolean condition.
Remember to put them inside the 'Or' statement or else it will considered the statement as 'And' thus returning the statement to false if both statement don't agree from each other.
Trigger 1

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Sleep

Actions


Set counter = (counter + 1)


Set SleepUnit[counter] = (Target unit of ability being cast)


Set SleepDuration[counter] = (20.00 x (Real((Level of Sleep for (Triggering unit)))))


Unit - Make SleepUnit[counter] Invulnerable


If (All Conditions are True) then do (Then Actions) else do (Else Actions)



If - Conditions




counter Equal to 1



Then - Actions




Trigger - Turn on Trigger 2 <gen>



Else - Actions
Trigger 2

Events


Time - Every 0.04 seconds of game time

Conditions

Actions


For each (Integer TempInteger) from 1 to counter, do (Actions)



Loop - Actions




Set SleepDuration[TempInteger] = (SleepDuration[TempInteger] - 0.04)




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






Or - Any (Conditions) are true







Conditions








SleepDuration[TempInteger] Less than or equal to 0.00








(SleepUnit[TempInteger] is dead) Equal to True





Then - Actions






Unit - Make SleepUnit[TempInteger] Vulnerable






Set SleepUnit[TempInteger] = SleepUnit[counter]






Set SleepDuration[TempInteger] = SleepDuration[counter]






Set TempInteger = (TempInteger - 1)






Set counter = (counter - 1)






If (All Conditions are True) then do (Then Actions) else do (Else Actions)







If - Conditions








counter Equal to 0







Then - Actions








Trigger - Turn off (This trigger)







Else - Actions





Else - Actions
I checked that already, I will try it if I will be making any such spells.If you're interested in further;
https://www.hiveworkshop.com/pastebin/bb36a403d199a9674f100c0b7bf81eff7063/
I don't know anything about them. How to use them, how do they function and how would they fit these triggers?You could try using local variables. They are unique for each function call but stop existing on function return.
They are only available with JASS. They function like local variables in other programming languages. The only major difference is that local declared local handle variables need to be nulled before function return due to a bug resulting in a reference counter reference leak.I don't know anything about them. How to use them, how do they function and how would they fit these triggers?
