HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Variables vs Arrays, Plz help

08-26-2003, 03:04 AM#1
xXL33t-DragonXx
I'm creating a new ability that summons a unit(heroA) and has it follow the unit(heroB) that summoned it automatically. Each time an ability point is put into the summon ability the unit gains a new item. To do this I need to keep track of heroA and heroB with variables. This I could do easily. :D The problem occurs when another player picks the same heroB and uses the same skill to summon heroA or if the player picks another hero which can summon heroA. So I thought about using arrays, however I don't completly understand arrays. If I use an array in place of a variable does it keep track of the array that I called for? For instance if heroB summons heroA(array1) and heroC summons heroA(array2) will the game keep track of them like that? Or, will I have to create seperate variables for each player?

I realize my question may be hard to follow, but it's very important to me, so if you wish to help me and don't quite understand I'll be more than happy to explain more indepth.(sp?)

P.S. Thank you;)
08-26-2003, 03:08 AM#2
mikedogdude
An array just stores multiple variables. Changing Array[1] wont affect Array[2]. Its just a way of storing lots of things, such as if you dont want to create a variable for every special effect, you create SFX which is an array. Then every effect would be SFX[1] SFX[2] etc....
08-26-2003, 03:11 AM#3
x(Lunchbox)x
So you want it so every time you summon d00d1 it summons a d00d2 then every ability point it summons d00d1 and d00d2 cept they have items? I dunt understand.

Unf.
08-26-2003, 03:41 AM#4
xXL33t-DragonXx
Ok let me try to explain me a little bit more indepth.

Trigger 1
Event
A unit enters entire map

Condition
Unit type is equal to dood1

Action
Set variable(dood1) equal to triggering unit

Trigger 2
Event
dood1 places learns ability(sword)

Condition

Action
create dood2 for owner of dood1
Set variable(dood2) equal to last created unit

Trigger 3
Event
Time elapsed .10 seconds

Condition

Action
Move variable(dood2) instantly to position of dood1

Trigger 4
Event
A unit casts an ability

Condition
Ability being cast is equal to (itemAbility)

Action
Give variable(dood2) item1
Set variable(item1) to last created item

Trigger5
Event
A unit casts an ability

Condition
Integer hero level of (triggering player) is greater than or equal to level 3
variable(dood2) has variable(item1)

Action
Destroy variable(item1)
Give variable(dood2) item2
Set variable(item1) to last created item


That works fine for what I want to do. If another player picks a hero that summons dood2 then it screws up the variables. So when item1 should be equal to item4 it might be equal to item3 due to another player being at a different skill level. Was that a little bit more clear?
:bgrun:
08-26-2003, 04:02 AM#5
Zoizite
If you're going to only have 1 dood1/dood2 per player, use an array with the index set as the player number.

IE: dood1(1) would be for player 1 or dood1(7) would be for player 7

set up the trigger something like this

set dood1(player number of (owner of unit(last created unit))) equal to last created unit
08-26-2003, 04:59 AM#6
xXL33t-DragonXx
Thanks Zoizite :D
08-26-2003, 05:53 AM#7
Zoizite
Did you get it working?