• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Enuming destructables on map init

Status
Not open for further replies.
Level 19
Joined
Aug 8, 2007
Messages
2,765
Im making a custom inventory that enums all destructables in a region when the map initializes.

What I noticed was happening was that the first time you load warcraft and play the map, the init crashes when it tries to enum them. If u restart and play an infinite amount of times, the destructable enum works fine.

Anyone else experience a similar problem?
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
well, its blizzard isnt it?
for instance, if you try to use WorldBounds, for me at least, first time no problem, after map restart the map crashes

maybe try doing it on 0.00 seconds elapsed event

sigh.

ive even tried 2sec elapsed... i use EnumDestructables in playable map area and theres exactly ZERO

e/ Can anyone else confirm this? It seems on every test ive done so far, enuming destructables on the first run of warcraft results nil.
 
From what I had while testing this it selects 2,000 random desructables in that region then checks them.

For instance if you are trying to get 200 of a overparticular type of destructable in a region with 4000 in them you would probably only get 100 of them.

It is blizzard here we are talking about, I don't have access to WE at the moment(bored at school) so I can't be to sure.
 
The enum destructables operation can only enumerate up to a certain maximum of destructables. I think the limit was 6144 or 4096.

While Newgen allows to place more destructables, as soon as you exceed the limit, the enumeration fails.

I use destructable enumeration to remove all pathing blockers at map init (and replace them with static terrain pathing set to false) and it works fine. I'm only at 2000 destructables, though.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Well make sure your init runs after the destructables have been generated (in case you inject it into the main function). The normal map initialization of gui is appended at the end of the main function.

Its run off of a module init function that waits after a 2 second timer.

I'm not sure how many destructables there is (i know theres 16K doodads because of map loading, but i like to throw flowers everywhere), so is there any way to check?

and about the "random 100 out of the 200" statement, No its random 0 out of the 128 :)
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Doodads are not destructables nor are destructables doodads.

edit: I cannot confirm a limit for EnumDestructablesInRect (tested up to 34k) using:

JASS:
function b takes nothing returns nothing
    set udg_c=udg_c+1
endfunction

function a takes nothing returns nothing
    local integer i=1
    loop
        exitwhen (i>34000)
        call CreateDestructable('ATtr', 0, 0, 0, 0, 0)
        if ModuloInteger(i, 1000)==0 then
            call TriggerSleepAction(0)
        endif
        set i=i+1
    endloop
    set udg_c=0
    call EnumDestructablesInRect(GetWorldBounds(), null, function b)
    call BJDebugMsg(I2S(udg_c))
endfunction
 
Last edited:
Status
Not open for further replies.
Top