| 01-26-2004, 12:45 AM | #1 |
I am a decent Triggerer.. id say about.... 6/10.... but i really get stumped on Variables.... like i can make a leader board and spells with a specific unit but most of them confuse me.... can someone link me to a tutorial or anything that explains what each variables does and how they work?.... |
| 01-26-2004, 01:36 AM | #2 |
There's a good explanation of what a variable is and how it behaves in the WC3 WE's help, actually. It goes something like this: A variable is like a bucket that a trigger uses to store a piece of information. But there are different shaped buckets for different shapes of information, so an "Integer" variable can only hold a piece of information that is shaped like an integer (any number with no digits after the decimal). To extend the metaphor, an array is like a stack of buckets arranged in a filing system, all with the same shape. Each bucket in the filing system can hold a different piece of information, but they must all be the same kind of information. And to refer to any given bucket, we use its position in the filing system. |
| 01-26-2004, 05:35 PM | #3 |
Some easy example what variables are: You got a trigger that creates a specialeffect (unholy frenzy) overhead of any unit casting Slow. Event - A Unit casts a spell Condition - Ability being cast equal to Slow Action - Create Specialeffect "Unholy Frenzy" Overhead of triggering unit Now in the action, you will use "Event Response - Triggering Unit". But if you have a second trigger to manipulate that unit, you can no more use "Event Response", because its a new trigger with a new event. Lets take an example, you want the slow casting unit to have another Special Effect if the unit gets attacked. Event - A Unit is attacked Condition - Attacked Unit equal to .....? Action - Create Specialeffect "Bloodlust" on Weapon of unit .....? You cant put triggering unit of the other trigger in there. BUT you got variables! So want to SAVE a unit into a variable to do this: You create a new UNIT Variable and name it "Caster_Slow". Then you add a line to the first trigger: Event - A Unit casts a spell Condition - Ability being cast equal to Slow Action - Create Specialeffect "Unholy Frenzy" Overhead of triggering unit Set Variable Caster_Slow to Triggering unit Now if a unit is casting SLOW the special effect will appear and the unit will be saved into Caster_Slow. Now in the second trigger, you can use it: Event - A Unit is attacked Condition - Attacked Unit equal to Caster_Slow Action - Create Specialeffect "Bloodlust" on Weapon of Caster_Slow You can save all kind of stuff in there, if you need it later. If you create special effects and want to remove them later... you need to save them as variables, etc, etc Now ARREYS. Took me forever to find it out, cuz nobody could explain it easy enough o_O Maybe you already noticed that the 2 triggers have a problem. If multiple units cast slow, only the last one will get the "Bloodlust" Effect on the weapon. Now here you can use an ARREY. Arreys are just something like Multi-Variables. A normal variable looks like this: Name [SavedData] In our example it would be Caster_Slow [Unit] Now an Arrey (Arrey of 5) looks like this Name [SavedData1] [SavedData2] [SavedData3] [SavedData4] [SavedData5] If u use arreys, it will look like this: Set Variable CasterSlow[_] to (value) In that field [_] you have to enter a number to select the SavedData1 or SavedData2 or SavedData3. You could just save most stuff into 100000 variables or put some stuff together. In our example, you NEED an arrey. We had the problem that only the last unit that was casting slow will have the bloodlust effect. Here is our use of variables to fix this: You create Caster_Slow as an Arrey with 20 Slots. You also need to create an Integer Variable, lets name it "UnitCounter" with the starting value "0". Event - A Unit casts a spell Condition - Ability being cast equal to Slow Action - Create Specialeffect "Unholy Frenzy" Overhead of triggering unit Set Variable UnitCounter to (UnitCounter + 1) Set Variable Caster_Slow[UnitCounter] to Triggering unit The first line will set the Integer "UnitCounter" to +1 every time the trigger runs. The starting value is "0". First time the trigger runs, UnitCounter will be set to 0+1 (=1), the next time to 1+1 (=2) and the next time to 2+1 (=3). The second line will use UnitCounter to access the Slots of our Arrey. As it goes up every time the trigger runs, the first unit will be saved to Caster_Slow[1], the second unit will be saved to Caster_Slow[2], to be continued... Well, I just found out this was a bad example, so the next trigger will look abit wierd >:-/ Anyway, you will now see the best about Arreys, this can save you ALOT of time and really make them useful (even in this bad example). Loops. The Action is: "For each (Integer A) from _ to _ do" This will run a Loop, lets say you put in For each Integer A from 1 to 3 do Now it will run _3_ times the other actions after this one. The first time "Integer A" will be 1, the second time it will be 2 and the third time it will be 3. "Integer A" is another value you can put it... just look at the following example, it will explain it. Event - A Unit is attacked Condition - none (look sentence above... >:-/ ) Action - For Each (Integer A) from 1 to 20 do - IF/THEN/ELSE - If Slow_Caster[Integer A] is equal to Attacked Unit - Then Create Specialeffect "Bloodlust" on Weapon of Caster_Slow[Integer A] - Else do nothing The Loop 1-20 will run that IF THEN ELSE 20 times. Integer A will be everytime another number (1, 2, 3, 4, ...., ..., ... 20). Now Slow_Caster[Integer A] will be Slow_Caster[1], Slow_Caster[2], Slow_Caster[3], .... till 20. I know, its a bad example, but I tried to explain it >_< I hope its easy to understand. |
