| 03-29-2006, 09:33 AM | #1 |
Is there any way to create an array of an array? I have a really weird complex leveling system that I'm trying to implement, and I can't quite figure out the best way to do it yet. Essentially, I'm trying to emulate the Hero Ability Choosing system. The reason I'm not actually using the built-in WC3 version is because I want each hero to have six abilities that they level as time goes on (not 5). Does anyone know how to create an array of an array? Suppose I wanted to make an array of item arrays (2D array). Is that data-type possible? |
| 03-29-2006, 10:21 AM | #2 |
The easiest way is to use Game Cache, you could also emulate 2D arrays. [0,0] = 0 [1,0] = 1 [2,0] = 2 [0,1] = 3 [1,1] = 4 [2,1] = 5 [0,2] = 6 [1,2] = 7 [2,2] = 8 |
| 03-29-2006, 11:41 AM | #3 |
Eventually you can simulate 2d array on 1d array by 4x6 array: array[6*x+y] = 123 |
| 03-29-2006, 03:17 PM | #4 |
or u could just do this: array[00 01]=5 array[00 02]=5 array[00 03]=8 array[00 04]=1 ... array[01 01]=9 array[01 01]=5 array[01 01]=9 array[01 01]=3 ... array[99 99]=12 this array allow u to have 2D array, with each 1D array can contain 100 different values (100*100). The space i made was just to show u the concept, they will become like array[0235] in wc3. since array in wc3 doesn't accept infinite array integer, so u can only use 4 numbers i think. With this you can also make 4d arrays, but then u can only have up to 10 values in each array. example: array[0 5 3 4] = 5 array[2 5 3 1] = 4 ---- I used this method on making lvl spawn: lvl=1 unit_type[lvl*100+0]=tauren unit_type[lvl*100+1]=grunt unit_type[lvl*100+2]=peon ... if you look at this as array it will be unit_type[01 00]=tauren unit_type[01 01]=grunt unit_type[01 02]=peon so for lvl 2 i just set lvl=lvl+1 then the next array will be unit_type[02 00]=unit1 unit_type[02 01]=unit2 unit_type[02 02]=unit3 As you can see, i can have 100 (0 to 99) different unit types for each lvl ----- But if you want to use 2D array with bigger amount of values, then you can always use gamecache, which is amazing for arrays. And since gamecache can contain big integers, so you can actualy fake big dimensional array, maybe up to 100*100*100*100, or even higher than that |
| 03-29-2006, 03:30 PM | #5 | |
Quote:
Anyway, this is rather simplified, as Zoxc already pointed out, when simulating 2d arrays, you can have any array sizes, not just powers of ten, as long as the total number of items you can store in it is below 8000+something. |
| 03-29-2006, 03:35 PM | #6 |
Valid array indexes goes from 0-8191. |
| 03-29-2006, 05:09 PM | #7 |
Thanks, that makes very logical sense. I can't believe I didn't think of that myself. How do i give "rep" to you guys? |
| 03-29-2006, 05:34 PM | #9 |
thanks! great work on the spell contest, btw |
