• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

How to make a unit group array?

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hi!

How can I insert into a Unit (or Unit Group) Array all the players heroes?.

Game has a maximum of 5 players, (so maximum 5 heroes, since it's an RPG), and the Hero is Sold-Free on the beginning of the game. I'm planning to use Save-load later... so, again:

How can I insert sold heroes, or Loaded heroes into a Variable?

Of course, in common triggers (GUI)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
You mean, creating 1 Group Array, and another 5 Groups (One for each Player) and set
First Group [1] = PlayerGroup 1
First Group [2] = PlayerGroup 2
First Group [3] = PlayerGroup 3
First Group [4] = PlayerGroup 4
First Group [5] = PlayerGroup 5
¿?

Somehow, I'm sure you can't mean that xD.
Where do I find the player ID to insert it into the Unit-Group array?

----
Can't I just create a Unit-Group called "Hero" and insert all the "Hero" units in there, independent of the player/owner of the unit, or something like that?
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
get player id of player? It's a native.

GetPlayerId(player)


There is a GUI equivalent.

edit
Oh crap, I thought you meant 5 heroes per player. Scrap the groups completely, just have a unit array and set the unit[playerId]=hero



Here's a great resource on save/load
http://www.hiveworkshop.com/forums/spells-569/save-load-snippets-v1-0-0-1-a-202714/

It also includes information as to the importance for being able to access the player's hero = ).


It's like a map filled with tutorials, demonstrations, useful scripts, etc.
 
Level 26
Joined
Mar 19, 2008
Messages
3,140
Use unit array variable. Array values should depend on player id number.

So, in your trigger with event Unit - Sells unit, use following actions:
  • Custom script: set udg_Unit[GetPlayerId(GetOwningPlayer(GetSoldUnit()))] = GetSoldUnit()
OR
  • Set Unit[(Player number of (Owner of (Sold unit)))] = (Sold unit)
You might add them into some kind of unit group - what can help you latter when refering to 'heroes' picked.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
One question. if I set that
  • Set Unit[(Player number of (Owner of (Sold unit)))] = (Sold unit)
in one Trigger, other "Sold Units" from other triggers won't be added to that variable? I mean, only Sold Units from that trigger will be added to that variable array...? (I've had that question for over a week xD)

Another one: @Spinnaker, I'm not sure if I did understand what youd said
"You might add them into some kind of unit group"
You mean another variable of type Unit-Group?... What would that be for?
 
Status
Not open for further replies.
Top