• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Pick Every Destructible in Entire Map

Status
Not open for further replies.
Level 5
Joined
Dec 12, 2011
Messages
116
Hello Guys.

Just wondering a way to reduce memory cost of the trigger 2, to avoid old computers having problems with my map.

  • Map Initialization I
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- Many other actions here --------
      • Trigger - Run Map Initialization II <gen> (ignoring conditions)
  • Map Initialization II
    • Events
    • Conditions
    • Actions
      • -------- Many other actions here --------
      • Destructible - Pick every destructible in (Entire map) and do (Actions)
        • Loop - Actions
          • Destructible - Make (Picked destructible) Invulnerable
Perhaps, put a small wait...

Ideas?
 
Well, you have a few options:

1) Make all the destructibles you are using invulnerable via the object editor. It will prevent you from needing to run the trigger.
2) Break up the map into 4 or so regions. Then have the first region set at about 0.25 second elapsed game time, the second at 0.5, the third at 0.75, and the fourth at 1.00 elapsed game time. (or whatever times you want) This will split up the actions to be executed "over-time", which essentially reduces the chance of having a lag spike.

so far as i know there is no leak in destructibles.

There is no "leak" since you still need the destructibles, but it still takes up memory. ;)

But overall, the memory isn't going to be what you are worrying about. The main concern is avoiding the initial lag spike that most maps get. However, you don't really have to worry about it too much since it only happens in the beginning. But if you want to make the lag less spikey, then I suggest that you create a fade filter in the beginning making everything pitch black and disable user control. (under the category, "Cinematic") Then split up all your actions to be executed over time, eg: one portion at 0.00 seconds, the next at 0.25 seconds, etc..) And once everything has been completed, you can fade in and reenable user control.

Good luck. =)
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
Hello Guys.

Perhaps, put a small wait...

If you are referring to the use of wait inside the Pick action then NEVER do this. Waits in loops and picking action are hell and causes the trigger to go buggy from what I have tried. PurgeandFire111 tips are awesome and very helpful.



Well, you have a few options:
....
Good luck. =)

Those are good tips that I didn't know of, thanks.
 
Level 11
Joined
Nov 15, 2007
Messages
800
Yea... you also cant pick EVERY destructible in the map, it stops picking them after it picks 64 have no idea why i think it says this in the trigger tho.

Fairly certain this isn't accurate. Only the Event - Destructible In Region Dies has a cap of 64 for whatever reason.
 
Level 5
Joined
Dec 12, 2011
Messages
116
Huge thanks everyone.
That information about the 64 is interesting.

Hey PurgeandFire111, perhaps this is a huge noob question, but:

How, exactly, I proceed, if I want to follow your first suggestion (working at the OE) ?
 
Oops, I don't have the World Editor on this comp so I don't remember whether they are able to become invulnerable through the object editor. I figured they were if they had a trigger for it. Anyway, if you can't find a field for it, then you can either:

1) Hold shift and double click the hit points field. Then set it to something really high like 1000000. This will make it so that the destructibles are "kind of" invulnerable. They will still be able to be attacked, but they most likely won't die in a regular length game.
2) If you want them to have all of the characteristics of invulnerability, then you will probably have to do the second trigger option I mentioned. Sorry, I don't have the editor on this computer so I am not of too much help with the specifics. =(
 
Level 11
Joined
Nov 15, 2007
Messages
800
You can set the field Combat - Targeted As to "None" to make destructibles "invulnerable" in the object editor, since it will prevent them from being targeted by attacks.
 
Some things you might want to consider:

1) if you cut out the 0.00 second stuff and instead make it run on map initialization, it will be done during the loading screen and thus generates no 'lag'. The increase of loading time of your map might not be noticable.

2) the amount of 'lag' it will create doesn't matter anyway, as it is done only once.

3) Your map shouldn't start directly after loading anyway. Add a small moment of a black fadefilter before the actual action starts.

4) If the enumeration hits the operation limit, you clearly have way to much destructables on your map. Are you sure you need that many? Destructables should only be used when you actually want to destroy them ... as destructables take up much more memory and cpu power than ordinary doodads. My suggestions: replace your destructables with doodads when you don't need them walkable or need to destroy them.
 
Level 5
Joined
Dec 12, 2011
Messages
116
Your ideas are very nice. The idea of having trees in my map is just to ornament.
I am thinking of apply your fourth idea.
Anyways, could you explain better your third idea? I mean, what is a black fadefilter?

And other thing: I read, somewhere, that using Thunder Clap abilities at maps with too many doodads causes huge amounts of lag. I have a Thunder Clap ability in my map. Does this apply to destructables too? Or: if I apply your fourth idea, do you think my map will hugely lag at Thunder Claps?

thanks already

hamsterpellet

EDIT: Meticulous, I will test your ideas with AOE damage, I'll post here soon what I got. Thank you. (=
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
Anyways, could you explain better your third idea? I mean, what is a black fadefilter?

  • Cinematic - Fade in over 0.00 seconds using texture Black Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
This will blacken the screen if inserted in the initialization trigger.


<<< EDIT >>>
sorry, its Fade Out not Fade In
  • Cinematic - Fade out over 0.00 seconds using texture Black Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
then
  • Cinematic - Fade in over 3.00 seconds using texture Black Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
Hmmm, nice.
May I put this at the "Time - Elapsed game time is 0.00 seconds", or it should be at the Map Initialization?

No problem, I tested it to see if it will be ugly or not and it worked fine for me.


<<< EDIT >>>
Again I am sorry, It will leave a delay and will be ugly I double tested it to make sure.
 
Last edited:
And other thing: I read, somewhere, that using Thunder Clap abilities at maps with too many doodads causes huge amounts of lag. I have a Thunder Clap ability in my map. Does this apply to destructables too? Or: if I apply your fourth idea, do you think my map will hugely lag at Thunder Claps?
First: Why should it? Doodads contain much less data than destructables. And I don't see any relation between thunder clap and doodads.
My map contains over 35000 doodads and there is no noticable lag or fps drop when using an ability.

One should never use destructables over doodads if you don't want to actually 'destroy' them, walk over them or adress them with triggers. Doodads are way more performant.
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
And other thing: I read, somewhere, that using Thunder Clap abilities at maps with too many doodads causes huge amounts of lag. I have a Thunder Clap ability in my map. Does

ok maybe that thunder clap was custom ability, if u preload every custom ability then i dont think its lag, or atleast not huge lagg, else a not preloaded custom ability could lagg on smaller map too
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
Sorry, I didn't understand any word :X

What's there no to understand, you asked what a black fade filter is so I answered you then you asked again if it can be used with game time 0.0 instead of initialization so I said yes but when I tested if it can be done without any glitches I found there was a delay when the game starts and when the screen go black so it looked ugly and I told you no don't use it with game time 0.0
 
Level 9
Joined
Apr 23, 2011
Messages
460
If you insist on having destructables and they are needed to be invulernable I have a script for you to use, however I do not know how many types you have. Or how many you are switching to doodads if you aren't switching them all. If you need the script I'll post it here.
 
Level 9
Joined
Apr 23, 2011
Messages
460
Here is the coding for destructable, I give credits to Bribe who helped me with it. This is the most simplified version and full credit is given to Bribe. However I'll give you a unit invulnerable script that i modified as well just in case ; )

JASS:
struct InvulnerableDestructables extends array

    private static hashtable ht = InitHashtable()
    private static rect world = bj_mapInitialPlayableArea
    
    private static method declareTypes takes nothing returns nothing
        call SaveBoolean(.ht, 'ZTtw', 0, true)
        call SaveBoolean(.ht, 'B001', 0, true)
    endmethod
    
    private static method makeInvulnerable takes nothing returns nothing
        call SetDestructableInvulnerable(GetEnumDestructable(), LoadBoolean(.ht, GetDestructableTypeId(GetEnumDestructable()), 0))
    endmethod
    
    private static method onInit takes nothing returns nothing
        call .declareTypes()
        call EnumDestructablesInRect(.world, null, function thistype.makeInvulnerable)
        call FlushParentHashtable(.ht)
        set .ht = null
    endmethod
endstruct

and the unit one is annoted.

JASS:
struct InvulUnits extends array

    private static hashtable ht = InitHashtable() //Declare the Hashtable and save to .ht
    private static rect world //Declare the rect world.
    
    private static method declareTypes takes nothing returns nothing
        call SaveBoolean(.ht, 'vigi', 0, true) //Save the value of true to invul units that match the parent key.
        call SaveBoolean(.ht, 'ewsp', 0, true) // And again.
    endmethod
    
    private static method makeInvulnerable takes nothing returns nothing
        call SetUnitInvulnerable(GetEnumUnit(), LoadBoolean(.ht, GetUnitTypeId(GetEnumUnit()), 0))
        //Checks the Enum unit to see if it's unitId matches a parent key in hashtable and if so it will set invul to true.
    endmethod
    
    private static method onInit takes nothing returns nothing
        local group g = CreateGroup() // Create the group and store to local group g.
        set world = bj_mapInitialPlayableArea //Set world to a rect. This can be changed to Your_Rect.
        call GroupEnumUnitsInRect(g,world,null) //Adds all units in world to group g. replace null with a 
        //boolexp filter to pick only certain units. If done, remember to destroy the boolexp filter.
        call .declareTypes() //Run the function to store all booleans to the hashtable.
        call ForGroup(g, function thistype.makeInvulnerable) //Check all units in group g for parent key and make invul 
        // the correct ones.
        call FlushParentHashtable(.ht)// clear the hashtable
        set .ht = null //Delete the hashtable
        call DestroyGroup(g) // Clear the group
        set g = null //Delete the group.
    endmethod
endstruct

Edit: in the destructable snippet, if it isn't already clear to you. Simply CnP the line call SaveBoolean(.ht, 'ZTtw', 0, true) in private static method declareTypes takes nothing returns nothing and change the value in ' ' to the raw data code for the destructable you want to invul.
 
Status
Not open for further replies.
Top