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

Making a constant array

Status
Not open for further replies.
Level 10
Joined
Jun 6, 2007
Messages
392
Hello!

I have lots of different heroes and abilities on my map. My goal is to make certain heroes to learn certain abilities at certain levels, so I thought it might be a good idea to store unit types and level-ability pairs into an array of some kind. The ideal structure is like this:

Code:
unit type 1 |level 1, ability 1
            |level 2, ability 2
            |     ...
-------------------------------
unit type 2 |level 3, ability 3
            |level 4, ability 4
            |level 5, ability 5
            |      ...
-------------------------------
...         |

So basically any number of ability-level pairs can be linked to a unit type, and all these <unit type>-<level-ability pair list> pairs are listed in an array. This would be easier in vJASS since it has structs, but I prefer using the original world editor. So, should I use hashtable for this or is there a better solution?
 
Level 12
Joined
Oct 16, 2010
Messages
680
well i think you don't realy need the level 1, level 2 part of this
you can simply use the indexing

what i mean is store the abilityes in the arrays depending on the index of the array
eg:

unit type 1 [1] ability 1
unit type 1 [2] ability 2
unit type 1 [3] null (do this if you want levels without learning new abilities)
unit type 1 [4] ability 3

and maybe you can store the whole data in one array like
//this is the unit type 1
array [1] abilityt1_1
array [2] abilityt1_2
.
.
.
// this is the unit type 2
array [101] abilityt2_1
array [102] abilityt2_2

and for finding the correct data while playing
save the unit types like the same way so u can referenc to them

unittype [1] = footman (raw data required here:D)
unittype [2] = Archer
.
.
.
and when unit gains level
search for the unit type and with the index u can search for the ability
i would do it this way
 
Level 10
Joined
Jun 6, 2007
Messages
392
Thanks for your reply!

Doesn't that require a lot of space if there are 100+ unit types and max level is 100? I was first thinking about saving them into a hashtable. Each row would look like this:

unit type | number of abilities | level a | ability x | level b | ability y |...
 
Level 12
Joined
Oct 16, 2010
Messages
680
your map has 100+ unit types and 100 lvl?
well if there are so many values one array won't work cuz its limit (around 9100)
i don't realy know how hashtables works but i think it has a limit too, so if you want to do this way watch for the limits (how much data it can store)

either way it will requires a lot of space:S

maybe if there is a pattern like an ability will level up every 5th lvl(dunno how you imagined)
you should trigger it that way
 
Status
Not open for further replies.
Top