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

Destroy & Recreate Trigger

Status
Not open for further replies.
Level 11
Joined
Sep 14, 2009
Messages
284
I'm making a custom damage detection system in a map I'm working on.

The map uses a custom combat system where a group of player units enter an arena-like battlefield when fighting enemies, I call it instanced combat.
Anyway, so I'm adding event every time a new battle takes place for all enemy units created.
Sooner or later this would cuase over 1000 events (single-player map).

I have read there is a way to destroy trigger and then create it again to remove all added events.
I know how to destroy a trigger, but not recreate it.

My question is; What is the custom script for recreating a trigger, and, will recreating a trigger remove events/conditions/actions that was originally in the trigger (not added ingame)?
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
I'd really suggest that you just use one of the damage detection systems out there to save yourself the trouble. One example would be Bribe's GUI Damage Engine

Anyway, you would not really recreate the trigger; you would have to create a entirely new trigger and register all the conditions and actions again along with registering the damage events for units that still need damage detection.
JASS:
local trigger t // For purposes of demonstration

// Destroying the trigger
call DestroyTrigger(t)

// "recreating it"
set t = CreateTrigger()
call TriggerAddCondition(t, Condition(function YourDamageDetectCondition)) // You need to get the function name of your condition. It probably looks like Trig_TRIGGERNAME_Conditions
call TriggerAddAction(t, function YourDamageDetectionAction) // Same idea as getting function name for condition, probably Trig_TRIGGERNAME_Actions
call TriggerRegisterUnitEvent(t, u, EVENT_UNIT_DAMAGED) // This would probably be done in some kind of enumeration, like enuming all the living units that can be damaged on the map.
 
Alright thanks for the response but i have one more question. What are the side effects of to many events? We're talking about over 1000 after à few hours of gameplay

For most current computers, it won't make a difference. It just takes up more memory per event.

In general, leaks don't cause noticeable effects on most computers unless created periodically. (as in, leaks that occur in periodic triggers/timers with 0.03 or so timeouts) It is still good practice to remove them, however.

As watermelon said, I'd recommend that you use Bribe's system to ease the process, as it does all that for you. If you are doing it yourself, it is up to you whether or not you want to remove/recreate the events. Generally, if you don't think you will reach about 7000-12000+, then you probably don't need to worry about it. (unless you have a really old computer)
 
Status
Not open for further replies.
Top