• 🏆 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!

[Trigger] I have a question?

Status
Not open for further replies.
Level 29
Joined
Oct 24, 2012
Messages
6,543
As far as I know, it's impossible to remove events.

Yes events can't be destroyed. They are never removed.

@TO
Why would you want to use custom script when there is a GUI action for it ?
Also all GUI actions have a custom script.


The only way to remove / destroy an event is to destroy the trigger that that event belongs to.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,178
Unfortunately the developers forgot to include a "RemoveEvent" native. They even went as far as to include the "event" type which is only ever returned by all the event creating natives.

The only solution to remove events is to destroy the trigger they are attached to. As long as there are no pointers to the event handle (which there should be) it will be completely removed. Do note that destroying triggers under certain conditions (not sure which) will result in the game client crashing.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,178
well, is there a possibility to desync players when you over populated the event of a trigger? if I add 1 event to a trigger for every second... will it cause the player to desync?
No it will not cause the game to desynchronize. However there is a good chance it might start to degrade performance and eventually cause the game to crash.
 
Level 13
Joined
Dec 21, 2010
Messages
540
JASS:
No it will not cause the game to desynchronize. However there is a good chance it might start to degrade performance and eventually cause the game to crash.

..well I don't experience crashing and it's not degrading performance.... I just can't find what causes other players to desync...grr..I've created variables for playergroups and removed leaks.. how about pan camera? does it make players to desync?

What event are you needing to add to a trigger every second?
The event I add to a trigger is when unit enters entire map...add unit to this trigger with event unit takes damage... and I have 5 creeps spawning every 30 seconds...
 
Level 12
Joined
Oct 16, 2010
Messages
680
The event I add to a trigger is when unit enters entire map...add unit to this trigger with event unit takes damage... and I have 5 creeps spawning every 30 seconds...

what mythic said is a good solution. If you still want to make it from scratch ( I did the same coz thats how it can fit the best way in your map:) ) then do this.

create a whole new trigger for every damage event u want to register
and save the trigger handle in hashtable or somewhere
when unit dies destroy trigger
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
1.) If you use a Damage Modification/Detection System, use one of the existing ones from
our database. They are very reliable, because many people tested them and reported bug issues over a long time.

2.) Which event are you adding so regulary? Unless your script does support trigger rebuilding,
it's probably avoidable to register so many events.
Without seeing your trigger I can't tell it for sure, but a single UNIT_PLAYER_EVENT and a filter condition should be enough, or?
UNIT_PLAYER_EVENT runs that trigger for every unit on the map. In you example it's always evaluated when a unit is attacked.
For the Filter (if needed) you could use an hashtable. A Unit Is Attcked --> If HaveSavedInteger(hashtable, GetUnitTypeId(attacked), 0) then
or if you have to check for each unit --> If HaveSavedInteger(hashtable, GetHandleId(attacked), 0) then.

What you are trying to do (UNIT_EVENT), should only be done with a complex trigger rebuild implementation. You will need vJass/wurst/zinc knowledge for it.

3.) One of the main issues for a desync is, when you use non local code (net traffic) within a GetLocalPlayer() block.
This always results in a crash. You may also find the reason within folder errors of in your wc3 directory.
Each time a game crashes a textdocument is created, sometimes you can comprehend the cause from it.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
You want to make something like I have.
I use this instead of the DDS that Mythic showed you.
You can use this or at least you can see how I remove an event from a trigger.
You can also see how much "Unit takes damage" events will eventually lagg the game.

Just take a look at it :)
 

Attachments

  • Damage Detection System Stress Test.w3x
    19.6 KB · Views: 45
  • Damage Detection System v1.w3x
    18.1 KB · Views: 89
Level 24
Joined
Aug 1, 2013
Messages
4,657
True but you can recreate the trigger and add the events you want.

That is what I do:
I have an empty trigger 'gg_trg_Taking_Damage' which is modified by the other triggers.
I have another trigger 'gg_trg_Add_Units' which add units to the taking damage trigger once they enter the entire map area.
Then there is the third and last trigger that runs once every ... seconds (in the stress test map it is 35 but you can change that to 15 minutes or half an hour or whatever you want).
This trigger removes the old trigger and creates a new one, adds all units in the map as an event to that trigger and add the action to the trigger.
JASS:
local group g = GetUnitsInRectAll(GetEntireMapRect())
    call DestroyTrigger(gg_trg_Taking_Damage)
    set gg_trg_Taking_Damage = CreateTrigger()
    call ForGroupBJ(g,function Add_Unit)
    call DestroyGroup(g)
    call TriggerAddAction(gg_trg_Taking_Damage, function Taking_Damage)

In the stress test, the map starts to look buggy after 25 seconds and starts laggin after 30-35 seconds.
I however add the "unit takes damage" event so many times per second that in a real melee game, 12 players require 5.000 barracks each that all continuasly train footmen (which require infinite resources and food) to actually keep up with that amount.
If you create 1 unit per second for each player (12 players), you can play without problems for 2 hours before you have to reset it.

But as you said, you cannot destroy an event but you can re-iniialize a trigger.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
12 players having a total of 60 thousand barrackses training footman continuasly that is a map which runs slow anyway XD
But indeed it was on my laptop and some might run slow on 15 seconds and others wont have problems for a few minutes, but that doesn't take away the point that I reset the trigger and thus remove all events and re-initialize it.
 
Level 12
Joined
Oct 16, 2010
Messages
680
yep that's okay. I chosed to create separate triggers for every event end destroy on units death coz I wrote my unit indexer , DDS and some other systems linked together and that way it was better to have this in there rather then creating a separate method to clear out unneeded events.
 
Status
Not open for further replies.
Top