| 07-14-2002, 03:32 PM | #1 |
Guest | It would make some of the basic parts of my map so much simpler to make with more advanced array features. I'm thinking of an RPG with both War3's hero leveling and SC-style unit upgrading to a new type. And the SC-style stuff is fairly complicated. The upgrade track is not linear, and there are a total of 8 upgrade locations. The maximum number of them that any given unit can upgrade to is 3. At the beginning, you have 4 unit paths to choos from, and then you can branch off and merge with other paths...for a total of 16 possible end units thanks to some randomization. But obviously, this makes for very complicated, if not terribly difficult, trigger work. It would be far easier to do this, as well as some other things I want (including letting units keep their attributes -- try that, it's a pain when you have multiple base types with different growth rates, and when units can switch to a new class anywhere between levels 5 and 10) if I could have a 2D array. And I know THAT's been mentioned before. But firstly, I would want it to include different datatypes, ideally. That way I could have the first column as 'unit type' and the others as vital stats of that unit, including base attributes and growth rates, as well as what a unit upgrades to at a given location. Of course, I could simply leave out the unit type column, and make another 1D array and just make the indexes correspond. But that array or reals would be 52x14 and filled with constants, just like a lookup table. And setting 728 values via triggers is not fun. So, in addition to 2D arrays, I think there should be some way to set initial values. But, if anybody has any thoughts on this, ways to make it easier, their ideas would be much appreciated. Currently, my plan is to have different starting triggers for each possible upgrade that set variables that are then used in a generic upgrade trigger. Within the starting triggers, I calculate how much of each attribute that unit gained, add it to a variable containing a running total (bonuses from tomes and quest rewards are obviously added in on the fly), then calculate how much more that is than the base of the unit that is being upgraded to. In the generic trigger...the hero uses that many tomes. Ugh. Why didn't Blizz include attribute triggers or functions? And I think I've adequately explained the other aspects of my upgrade system above. Please, if something pops into your head, I'd love your input. |
| 07-14-2002, 04:47 PM | #2 |
2D arrays that we all know and love are actually translated into 1D arrays when compiled into binary code. It works something like this: Int Array[size1][size2] Array[x][y] actually corresponds to Array[x*size1+y] Even though there are no macro defs or operator overloading, you can still use a function to get the desired effect. I am assuming certain things such as size1 is a variable you've already set. Code:
function index takes integer x, integer y returns integer
return (x*size1 + y)
endfunction
function blahblah_Actions takes nothing returns nothing
set Array[index(x,y)] = unit blah
endfunction |
| 07-14-2002, 06:11 PM | #3 |
Kick ass Mr123! That's going into my next map :) |
| 07-14-2002, 07:09 PM | #4 |
Err, where would I define this function so that I can use it in any trigger? |
| 07-14-2002, 07:26 PM | #5 |
Btw, I didn't fully test the function. I've only tried 1 parameter functions and it works fine and the above compiles so it should work also. I think to define it so it works everywhere, pick the first trigger or create a trigger and place it as the first trigger, in a category and convert it to custom text. Put it in there and it should work for the other triggers in the category. Try it out and report back if it doesn't work so we all know for sure. |
| 07-14-2002, 11:14 PM | #6 |
Eh, size1 represents the size of y, not x, right? |
| 07-15-2002, 02:39 AM | #7 |
Guest | Gah! I'm kicking myself, in all the console C++ programming I've been doing, I've been using screen buffers...which are conceptual 2D arrays in 1D form. I KNEW that. Thanks for reminding me. :D Now if only we could have some sort of table to set initial values in... |
| 07-15-2002, 02:42 AM | #8 |
size 1 represents the size of X |
| 07-15-2002, 02:47 AM | #9 |
Setting intial stats (I assume you mean of the heros) is in the unit editor you can set the growth rate of the hero and his starting stat points. |
| 07-15-2002, 03:00 AM | #10 |
EDIT: Err, now that I'm playing with it, Mr.123's works as long as you consider 0 to be meaningful on both x and y axis. |
| 07-15-2002, 03:58 AM | #11 |
Guest | Weaddar, I want the stats of the heros the players get to be variable based on the stats of their last hero. That way there's some incentive for delaying an upgrade. |
| 07-15-2002, 12:48 PM | #12 |
Well you can do it the fun way (not really fun). Where you know the intial stats of the unit. And you store all his stats to a variable and each time he levels you add the stats he gained to a variable when he uses a tomb etc. Bliz prolly did it this way as they don't want you loosing stat points. (if you loose enough agility to get to like 6 you'd get -1 armor.) |
