| 06-28-2007, 03:23 AM | #1 |
It's a bit like a creep respawn, but I don't want to go so in-depth as to need to get someone's system, and so on. I've got a bunch of rects (21 + 8 special ones) that, at certain intervals, will replace the units that have died there, if all have died. All I need to know is how to replace those specific units with ones of their own type? The only method I could think of was adding all the units to a group array, but is it possible to create all the units in a group with a couple functions? Another method, just thought up, was to loop through each group, compare the unit-type ID's of each one, and create a unit accordingly. But it sounds slow and bulky. I'll take anyone's input, but I'd rather not resort to a system. I'm trying to get my map done myself, without the help of systems. Thanks for your time. |
| 06-28-2007, 03:36 AM | #2 |
You could keep track of which units die, store the unit-types in an array/group of sorts, and then create them during the re-spawn cycle. I would try a 2D unit-type array (1 array for the spawns, and the second for the units of the spawns) and then loop through it and create any units that exist there. |
| 06-28-2007, 04:49 AM | #3 |
I thought up an idea. At the beginning of each game, a trigger runs that grabs every unit owned by Neutral Hostile and sets them to a global unit array. Every cycle, a loop goes through each unit, and if it's dead, a unit of the same type is placed where the old one died (There would be a second array that stored their locations). It sounds REALLY bulky and slow though, and I'm afraid of an impending lag from it. It'd only be once every 2-3 minutes or so, but it'd be bad nontheless. Yet, I'll test it. EDIT: What if, since I'm using JASS, I made the trigger run at initialization and used local arrays, then, after a PolledWait of whatever the interval is, it runs the action function of the trigger? (Thus repeating the cycle). I'm worried about leaks though. Hmm. |
| 06-28-2007, 05:24 AM | #4 |
A simple method would be to use a trigger that runs when any of your creeps dies (use condition for neutral player). Store all the info on the unit in local variables and get the trigger to sleep for X seconds. After the wait, you can then check to see if its ready to respawn (no hero in the area) and then create the unit from the info stored in the locals (may not even require local variables, not sure how triggering unit works if the unit it references is removed). I have seen this used many times in RPGs and it works nicely. |
| 06-28-2007, 05:38 AM | #5 |
It's a nice idea, but the only thing is, all the food (im referring to creeps when i say this) are supposed to respawn at the same time (kinda like new herds of prey are migrating in), which is why it needs to be done at the same time. Under other circumstances, the method you showed would work great. Worst comes to worst, I can modify that idea some. |
| 06-28-2007, 07:40 AM | #6 |
On map init, simply pick all relevant units you want to respawn and add them to different indexes of a unit-group array that correspond with your rects (which would also be in arrays). Then, if you suspend corpse decay, you can loop through every unit on the map with health > 0.406 (AKA: dead) of your deer-type units owned by neutral hostile and simply check to see which of the global groups the unit is in. After you've found the group (using an index-increasing loop), simply remove the old unit from the group, spawn a new unit at the group, and add the new one to the group. |
| 06-28-2007, 12:10 PM | #7 |
You could have a trigger which detects when your 'animals' or whatever die and appends them to a 'list' (simply a global array with an integer to keep track of the number of entries in it). Every X minutes you loop from 0 to your integer, restore all the units and then set your tracking integer back to 0. |
