| 11-17-2008, 04:55 PM | #1 |
Is there any relatively simple way to reduce the value for a rawcode (well, ANY unit rawcodes) to something that would make the value legitimate for an array OR is there any value I could oversize the arrays by so that they would be capable of handling any possibly unit rawcode? I'm try to make my own experience system, and it would be pretty handy if I could just refer to the unit's EXP given through something like ExpData.ExpValue[GetUnitTypeId (whichUnit)] |
| 11-17-2008, 05:12 PM | #2 |
You we don't need the information 100 times a second, use table (script section). |
| 11-17-2008, 05:16 PM | #3 |
To reduce raw codes without any problem use only custom units based of same unit. I recommend 'ucry' as base. Then you will able to substract 'u000' from any raw code after substraction you will get short ID (1-2-3-4...for every custom unit used). There is no need of 8000 units soo you will fit single array. |
| 11-17-2008, 05:41 PM | #4 | ||
Quote:
Thanks Quote:
|
| 11-17-2008, 05:44 PM | #5 | |
I agree with Diod JASS:globals constant integer OFFSET = 'u000' endglobals function GetUnitReference takes unit who returns integer return GetUnitTypeId(who)-OFFSET endfunction Just remember not to use predefined unit types from the object editor i.e. 'Hpal', use them only on your custom unit types. EDIT Quote:
But it's faster and more cleaner, anyways gamecache will work just fine. |
| 11-18-2008, 03:41 AM | #6 |
Or you can use the index of the string to store the data in an array. JASS:function GetStringIndex takes string s returns integer return s return 0 endfunction |
| 11-18-2008, 05:41 AM | #7 |
I stand corrected, grim001's solution is the best thing to do, since the data is initialized at map initialization, you can use warcraft's internal string table to your advantage without worries. |
| 11-18-2008, 07:18 AM | #8 |
rb on string cause crush on loading saved game. |
| 11-18-2008, 07:42 AM | #9 |
yes, that method only works for multiplayer maps. |
| 11-18-2008, 11:53 AM | #10 |
Or you can use a basic hash table. JASS:function GetIndex takes integer id returns integer local integer i = id-(id/8191)*8191 loop if id == IndexID[i] then return i endif endloop endfunction Assumes everything is setup at init and you never try to get the index of something not setup. Pretty much O(1). |
