| 10-28-2004, 04:03 AM | #1 |
Greetings. The only functions that are available for dealing with multiple destructables in the GUI get all destructables within a region. With 4000 destructables, it's too much to sort through all of the dests in a region and test them. I'd like to be able to define a destructable group variable, although I don't see one in common.j. I'd appreciate being able to pick all destructables matching a condition, but again, nothing appears to be available for that. The basic gist of the situation is that I'm regrowing trees all over a moderately-large map. Every 10 or so seconds I test all the desructables in part of the map to see if any are of the appropriate type, and dead. The next time, I move to a different part of the map, etc. By doing this, I'm cutting down on some of the processing power that this requires. However, there's still too much. I'd like to find a way to isolate the dead tree destructables without having to "Pick" every dest in the region first. Thanks for any insight/ideas. |
| 10-28-2004, 04:46 AM | #2 |
Gar, I'm not savvy enough to figure out how to manipulate the "Matching a condition" part of this. Any help in figuring out what's going on? This is from blizzard.j: Code:
//===========================================================================
// Picks a random destructable from within a rect, matching a condition
//
function RandomDestructableInRectBJ takes rect r, boolexpr filter returns destructable
set bj_destRandomConsidered = 0
set bj_destRandomCurrentPick = null
call EnumDestructablesInRect(r, filter, function RandomDestructableInRectBJEnum)
call DestroyBoolExpr(filter)
return bj_destRandomCurrentPick
endfunction |
| 10-28-2004, 06:53 AM | #3 |
As the filter parameter you would pass in something like Filter(function YourFunction) Then filter function itself could look something like: function YourFunction takes nothing returns boolean return IsDestructableAlive(GetFilterDestructable()) endfunction But as you stated this is rather inefficient. I'd create a trigger that fires when a destructable dies, then checks the type of the dying dest in a condition. Then does whatever is necessary (recreate the destructable). Anyway I always wanted to create a destructable group class. Maybe I'll do so later todeay. |
| 10-28-2004, 11:32 AM | #4 |
You could use Lord Vexorian's Pools. They are efficient all purpose sets/groups that use gamecache. http://kattana.users.whitehat.dk/viewfunc.php?id=286 |
| 10-28-2004, 05:37 PM | #5 |
why not use the destrustible within region dies event. you could use the entire map for the region. then check if the destructible is a tree for your condition. if it was a tree, save the point where the center of the tree was in a point array. then you could just regrow those trees every 10 seconds using the points in the array. then just clean out the array so you could start the process over again. I guess it could miss a few every now and then using this method though, but i think it might be a lot easier on the ole processor. |
| 10-28-2004, 10:58 PM | #6 |
Indeed, storing points isn't bad, but it might as well be a destructable array if I'm going to use an array for it. |
| 10-29-2004, 08:38 AM | #7 |
yes a destructible array would work quite well. It would probably leak less than using points as well. Of course if you used a destructible array, you could just set your array at the begining of the map. Then you could just check any percentage of the array every x seconds and just move from section to section of that array. You would also have to replace the destructible in the array with the new one that you created so it would work forever. |
| 10-29-2004, 02:56 PM | #8 |
So, the "Destructable dies" event is for a specific destructable, and the "Destructable in Region dies" event only monitors the first 64 destructables in the region. With 4000+ dests, I can't make a region around every 64 of them. |
| 10-29-2004, 05:26 PM | #9 |
well i got bored so i made a test map. i put 3000 trees on this map and a unit to destroy them. I made a regrowth trigger based a destructible array defined at the start of the map. it will regrow any tree that is destroyed and only uses 2 triggers to do it. i included details about what i did and what you can edit to accomodate your map. the only bad part is the fact that you can't select destructibles matching conditions so it has to look at every destructible on the map the first time it fires. Due to that i made it fire .2 seconds after the map initalizes to reduce load time. After the first time it just looks at a specified number every x seconds. I have attached the map for you to check out. Let me know if it will work for you. I'm also thinking about putting it it the repository if enough people tell me that it is worth going there. |
| 10-29-2004, 06:02 PM | #10 |
Thanks, I'll have a look-see. |
| 10-29-2004, 06:26 PM | #11 |
i have found one problem though. if you add units that can build, when you build structures, the trees will grow right through them.. i'll have to look into that a little more. looks pretty interesting though. lol |
