• 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.

[General] Destroying Events

Status
Not open for further replies.
Level 26
Joined
Aug 18, 2009
Messages
4,099
It does create new events, destroying them maybe. That is, you cannot destroy an event directly but the trigger it is attached to. Then you may recreate the trigger and register the remaining events anew. Events only exist mounted to a trigger though, so there is no simple TriggerRegisterEvent(event e), you have to have new ones and therefore call the various create functions + remember the parameters depending on the case.

It is not effective to do this all the time. But the use of destroying events is rather limited anyway. Do you want it for cleaning up memory or to disable the events? First can be handled in blocks, like count the needed removals and only do it once it exceeds 500. To disable events, often filters in the target trigger are sufficient or you can read about Custom Events in my signature, where you virtually decouple yourself from the standard engine.

Another variant is to simply have an individual trigger object per event and delete that one, yet GUI does not allow you to create/destroy events and nothing of all of this is a task for GUI.
 
I'll be very specific then. This is involved with Destructables.
I want to create a Destructable system that loads all Dest in the map and register them into an event where I can retrieve them when they died. I don't recall an event existed that automatically retrieves Destructables that dies like UNIT_IS_ATTACKED, UNIT_TAKES_DAMAGE and so on. I might be wrong.

Anyway, I take some looks into Custom Event of yours and consider some alternatives :)
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
There is not really an event that tells when a destructable enters the game...
However, I don't really know if it can be done without triggers.

So on map initialization, pick every destructable in the entire map.
Give picked destructable the event "<destructable> dies".
When you create a destructable through triggers, add that same event to those as well.

Once in a while, you destroy the trigger and recreate it. (removing all events)
Now you pick every destructable in the entire map and add the events again.
(Because there are way more destructables than units in a map (probably) you could experience lagg.

That does not answer the question why you have to destroy those events.
Memory leak removal.
However, destructables are not created in-game that much so it is not that big of a problem.
 
@WaterKnight : Wietlol explains it very well. Also, in addition, I need them so I can manipulate the environment near the trees to my needs. Still, I guess I can use Custom Events for my need if I could execute it well, else I guess a little trick might do.

@Wielol : thanks for the explanation. I guess I have to get hard way then.

Thanks to both of you :)
 
Level 26
Joined
Aug 18, 2009
Messages
4,099
With GUI, you leak all sorts of stuff anyway.

What I describe in the Custom Events thread does not avoid the need of the native destructable death event because you most likely do not have another sure-fire way of saying "this destructable is to die now", rather get told it by the game directly.

However, the concept adds an abstration layer. You can practically have a single entry point where you really detect the native destructable death event but propagate this signal automatically to other triggers registering for it. So you can e.g. build your own "any destructable dies" event and have much more control since this permits to create/enable/disable/remove the dynamic linkage freely.
 
@WaterKnight thanks, though I kinda decide go with the brutal way since my Jass knowledge lacks for this stuff. I better improve then :)

I use the most certain way that whenever Dest is entering, I register them to the death event, since I don't really master trigger create and destroy mechanics yet (gotta learn to figure them out), I leave the event there for now. Doesn't seems to lag the map, for now.
 
Status
Not open for further replies.
Top