• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

help about variables

Status
Not open for further replies.
Level 3
Joined
Jul 11, 2005
Messages
50
varables i cant tell you what they are but i can tell u how to use them in my opooin there are only 2 types of varables numbers and quests units players etc.. so lets say your trying to make it so that if a player kills 5 fire elementals a gate is opened so what you do is this
Trigger
Event
Unit - a unit dies
Condion
Unit Type - Type of triggering unit = to Fire elemental
Action
Set Varable (make a new REAL varable titled FireElemental) FireElemental to Value FireElemental + 1

now if you want to have a message after each kill make a trigger
Event
Value of real varable - becomes X (where x is what kill there on)
Action
Game - Text message X more fire elementals to go (are whatever you want to say)

now once they've killed all 5 make a trigger
Event
Value of real varable - becomes 5
Action
Destuctables - open/close/destory gate then open the gate you want.

if you need more help on varables i'll expalin further
 
Level 9
Joined
Jun 26, 2005
Messages
511
yea but i know another way tho

event:
unit-a units dies
conditions:
unit type of (dying unit) equal to (fire elemental 1)
unit type of (dying unit) equal to (fire elemental 2)
unit type of (dying unit) equal to (fire elemental 3)
unit type of (dying unit) equal to (fire elemental 4)
unit type of (dying unit) equal to (fire elemental 5)
actions:
desttrutiable-open/close/destroy gate (open selected gate)

thats should work...
 
Level 3
Joined
Jul 11, 2005
Messages
50
the point is to teach them how to use varables. and yours whouldent wrok unless each of the elementals was a different unit
 
Level 6
Joined
Mar 18, 2005
Messages
153
For those who want to understand arrays:
how do i create arrays?
while making a new variable just activate the "array" box and set the number of possible entries.
to call the different entries you have specify the number of the entrie: tinef[1] for the first entrie, tinef[2] for the second entrie (tinef is the name of the variable).

WTF are arrays anyway???
a common variable has only 1 value. by using arrays its possible to store many values in a single variable. this is useful to create certain dynamic things instead of using copy-paste all the time.

HUH?
heres an example:
10 spawnpoints are created (regions in this case).
a variable named "spawnpoints" is created as array with the size 10.
at the beginning of the map the spawnregions are stored in the array:

Set spawnpoint[1] = frist_spawn_region <gen>
Set spawnpunkte[2] = second_spawn_region <gen>

etc.

whatever... now whats the clue with arrays?
besides the overview, arrays have a nice feature: you can replace the index-number by a variable itself.
instead of using this
Unit - Create 1 Soldier for Player 1 (Red) at (Center of spawnpoints[1]) facing Default building facing (270.0) degrees
u can make it like that
Set randomnumber = (Random integer number between 1 and 10)
Unit - Create 1 Soldier for Player 1 (Red) at (Center of spawnpoints[randomnumber]) facing Default building facing (270.0) degrees

=> 1 unit is spawned in a random spawnpoint

of course u could solve this with mass IFs but this wouldnt work anymore if u make a map with 100 possible spawnpoints.

any other examples?
in case u want to spawn 1 unit in each spawnregion u could make a loop reffering to all arrayentries.
For each (Integer A) from 1 to 10, do (Actions)
Loop - Actions
Unit - Create 1 Soldier for Player 1 (Red) at (Center of spawnpoints[(Integer A)]) facing Default building facing (270.0) degrees

=> the action unit-create is executed 10 times. the value of integer A changes each time so another spawnpoint is used in each step. YES u could just copy-paste triggers instead. but that wont work if u have 100.000 spawnregions (theres a maximum triggerlength :p)

hf
 
Status
Not open for further replies.
Top