[Miscellanous / Other] Player Indexing

Level 4
May 24, 2017
I just had an idea that I wanted opinions on. Unit indexing is when each unit is given a custom value, but I had this player indexing idea for RPGs or maps where you control one hero/unit. Basically you create variables that have the same number of arrays as players in the the game and you save data using the player number.

So something like unit kills could be saved like this:
  • Set Unit_Kill(Owner of killing Unit) = [Unit_Kill(Owner of killing Unit) + 1]
That would eliminate the use of Unit Indexing in one hero/unit maps. Basically making the player the unit being controlled. I personally want to use this to keep track of resources and guild points. This would work with save/ load systems to because you would just pick every player and save the variables using the player numbers. When they are loaded you would have a variable that would be the new player number to save too.

Does this make sense and would it be efficient?
Level 8
Mar 19, 2017
Yes it makes sense and you can use the integer variable Player Number (returns a Jass function GetPlayerId(player)+1, starting at player Red and onwards). But even in RPGs there will be creeps, bosses, mobs, etc; should you need to store data on them (ie. get the amount of kills a creep had done) you will end up returning (or using your player indexing method in conjunction with) to a Unit Indexer or another massive way of storing data (ie. hashtable).