HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

DestroyEvent()?

07-26-2009, 11:49 PM#1
Cheezeman
Hey dudes.
I'm having a bit of an issue with my new spell.
See, I want something to fire off when an enemy gets within range of the targeted area. That's pretty simple, just create a dummy unit and a TriggerRegisterUnitInRange().
However it's a spell I plan on releasing later on, I want it to be somewhat optimized. Every time my spell is cast it creates this event, correct? Casting it 10 times creates 10 events, or 10 invincible triggers.
I don't want to overflow a map with disabled triggers and I don't want to overflow atrigger with events (which I don't think is a good idea, though I might be wrong).

Simply put, my question is if there's a way to destroy the event when I no longer need it?
I tried setting it to a variable which I null, but that doesn't work.
07-27-2009, 12:12 AM#2
Rising_Dusk
An event is not the same thing as a trigger. You can assign 10 events to the same trigger and even if the unit associated with a given event is removed from the game the event will persist. This minor leak is something inevitable in today's coding styles, since events are only cleaned upon destruction of the linked trigger. Destroying triggers is kind of taboo.
Quote:
Originally Posted by Cheezeman
Simply put, my question is if there's a way to destroy the event when I no longer need it?
Destroy the trigger.
07-27-2009, 12:17 AM#3
Cheezeman
I can disable the trigger, but never destroy it. So it will still leak...
At least that what I've heared, prove me wrong.
*Offline following 11h*
07-27-2009, 12:21 AM#4
Rising_Dusk
Disabling the trigger will not destroy the events associated with it. It will only prevent the trigger from running. The only way to remove the events is to destroy the trigger.
07-27-2009, 12:21 AM#5
Anitarf
Well, you either need to destroy the trigger or you'll leak, that's why nobody uses unit in range events these days. Instead of creating a unit in range detection trigger, you could just make an xecollider.
07-27-2009, 12:36 AM#6
Pyrogasm
No, you cannot remove an event. The best thing you can do is use dynamic triggers and just destroy each trigger when needed.

However, you could simulate a UnitInRange function with a periodic timer checking the units in range of the target point.


Edit: Fuck. I had this page open too long whilst I ignored it and this is what I get...
07-27-2009, 11:21 AM#7
Viikuna-
You could recycle those dummies maybe, if you dont need tom many different ranges for that event.
07-27-2009, 12:27 PM#8
chobibo
what does *Offline following 11h* mean?

Since your just doing a spell, I'll agree with pyro's solution, just use distance checks, or you could use groups+timed enumeration.
07-27-2009, 12:33 PM#9
Troll-Brain
And anyway it seems this event basically check every 0.1s the distance between units (did some tests about it)
07-27-2009, 01:08 PM#10
Cheezeman
chibibo, it means that I'm gonna sleep and you guys have time to write your answers.

anyway how do I destroy a trigger?
According to akolyt0r, this isn't possible:
Quote:
the reason why we dont have to null triggers is, that they wont be destroyed ever ...
So what do you mean Rising_Dusk? Something I don't know about?
07-27-2009, 01:24 PM#11
Viikuna-
You destroy triggers with DestroyTrigger -function.

What Dusk is saying there, is that we dont usually destroy triggers, so we dont usually have to null them either, because we only need to null those handles ( or agensts, or whatever ) that are going to get removed in some point of the game.
07-27-2009, 01:37 PM#12
Rising_Dusk
The concept of dynamic triggers sucks because it's taboo and causes strange handle corruptions, which really shouldn't matter in today's coding, but whatever. The idea is that a trigger for, say, a spell should never be destroyed because the spell can be cast at any point in a game.

If something is never destroyed, it doesn't have to be nullified. I still do it myself out of habit, but you don't have to.
07-27-2009, 02:58 PM#13
chobibo
Had blizzard made trigger destruction functional, dynamic triggers would be very useful.
07-27-2009, 03:33 PM#14
Cheezeman
huh, why do I always miss those functions...
I looked everywhere but the function list for something like DestroyTrigger()
fuck this I feel like I'm wasting you guys' time.
07-27-2009, 07:02 PM#15
Anitarf
Quote:
Originally Posted by chobibo
Had blizzard made trigger destruction functional, dynamic triggers would be very useful.
It is functional, there are just some obscure bugs associated with it, so we prefer not to use dynamic triggers because of that. DestroyTrigger might not even be the cause of those bugs, but since we can do most things without dynamic triggers anyway, noone has bothered to find out (did I meantion the bugs were like really obscure?).