• 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.

Best way to store stats for large amounts of units

Status
Not open for further replies.
Level 4
Joined
May 2, 2009
Messages
69
Hello Hive,

I'm a novice mapmaker who is now trying to study up on things and learn to use the Map Editor for what it's really worth.

I've taken a few cracks at trying to use a triggered combat system, (abilities that deal damage based on stats, using stats for attacks and defense), but there's one single problem that I keep facing, and that is how to store stats for a large amount of units. A large amount being somewhere around 80+.

It was easy when I planned on only using stats for the players' heroes, I just used array variables and got the player number to retrieve the stored data. But I KNOW there is a more efficient way than making a variable with an array size of 80+.

I want the triggers to look something like:
"Casting Unit deals damage to Target Unit equal to Casting Unit's Strength * Target Unit's Armor Reduction Value"

I've heard a little bit of information about hash tables. Is that the sort of thing I'm looking for, to store and save information based on the unit type?
 
Level 4
Joined
May 2, 2009
Messages
69
I suppose you have a point with that, but I guess what my REAL problem is lies with the fact that I don't know how to get the data based on the unit type. I can set Armor/Str/Int values to every unit, one by one, but how do I retrieve those stats in a trigger? For example, if the Armor value of a Ghoul is set in the variable "Armor[45]", and "Armor[45] = .31", how do I plug that into the trigger like the one in my first post?

Like I said, I'm quite a newbie here, and the only option I can see is very impractical. And that is to have 80+ triggers saying
"If Unit Type (target of ability being cast) = Ghoul --> Run Trigger (Hero attack Ghoul)"
For each unit type

And vice-versa for when it is a unit attacking the player. And I would have to do this for every attack and spell.

Is there a way to just preset the stats when the game starts and easily retrieve them mid-trigger?
 
Level 4
Joined
May 2, 2009
Messages
69
Okay, perfect. I think I saw a tutorial on hashtables somewhere, I'll dig it up and figure it out. Thanks for the help, guys.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Global variables have no defined size. For integer and real you can get away with setting the GUI size field to 1 as long as you initialize the indices you want to use somewhere else (otherwise they will just be 0). It is dangerous to use many globals with large sizes as the initialization routine might hit the op limit and cause the initialization thread to crash so trigger events are not set up.
 
Status
Not open for further replies.
Top