Is there a downside to many events?

afisakov

You can change this now in User CP.
Reaction score
37
Is there any downside to having many events run from a single trigger?

In this case I am working on a map and the previous developer has a bunch of triggers that read

Event: A unit enters region X
condition: unit type equal to maze runner
action: remove entering unit from the game

I was thinking I could save space by making it one big trigger like

Events: a unit enters region x
a unit enters region y
a unit enters region z
a unit enters region x1
etc...
condition: unit type equal to maze runner
action: remove entering unit from the game

I know doing this should save a bit on mapsize and seems easier to look at, but is there any downside? Will it somehow take longer to process?
 
its actually prefered as long as you dont have 1 trigger with a million if statements and every event in the book... a good example of this would be PlayerUnitEvent by Magtheridon96, in which you can just do a simple call with each function adding all triggers to be run into one event (actually creates one trigger but puts all the actions into it), there is a GUI version, if you would like to search for it, it is on thehive
 
Thank you.
I changed it now

P.S. Is "like" the new +rep system?
 
1 Like = 1 rep. It's the same increase for everyone now; you don't add more rep for having more rep.
 
Of course there is.
Any additional events in your map will add slightly to the processing time of game actions.
I think you can very well imagine that if i have 100 triggers all with the event "a unit dies" compared to only a single trigger with that event, that if a unit actually dies in the game it will take slightly longer to activate all the triggers associated with the 100 events then it would for only a single trigger.

This overhead, however, is so minor that it is not really important and can be ignored if not done to ridiculous levels.
 
you are right accname, but the biggest issue that is fixed by doing this is execute count, the higher the execute count the harder the system will lag, this was tested in the forum for Magtheridon96's Library by, i believe, nestharus and bribe, could be wrong on that though.

Every execute = a new thread opened, more threads = more lag, 1 no-wait thread = less lag
 
yes they are or waits would cause issues, thats why the execute count is so important, essentially it is calling ExecuteFunction(function Trg_Somefunc), though i believe it is called using an underlying function not actually available in the editor. There is no way 2 instances of the same trigger can be run at the same time in the same thread if there are waits
 
There is no way 2 instances of the same trigger can be run at the same time in the same thread if there are waits
What happens if there is a "wait until" in a trigger that runs every 2 seconds?
will new instances activate and give orders or will the entire trigger be useless until the wait until function if fulfilled?
 
What happens if there is a "wait until" in a trigger that runs every 2 seconds?
will new instances activate and give orders or will the entire trigger be useless until the wait until function if fulfilled?
afaik, the trigger will be executet every 2 seconds, no matter what happens at the wait. evvery trigger gets its own "instance". I doubt though that every "instance" has its own actual thread, no real programm would ever allocate 20 threads just to do some calculations...

Also there is a side effect (at least a side effect i can think off), though a rather practical one: you can turn triggers off. If you have 2 triggers with the same event and you only need one, you can turn it off. If you, however, only have 1 trigger that goes through a few ifs emulating the conditions of the 2 seperate triggers, you could not turn them off. Well, you could make a boolean to skip those conditions, but i think a jass comparision will take longer then the evaluation if a trigger is off (which is done in hard code).
 
i'm not quite sure if i understand correctly, but does that mean if i want to create a triggered spell, it is better if all of triggered spell is fitted into one trigger that holds the event 'Unit - Starts the effect of an ability', rather having individual trigger for each triggered spell?
 
yes they are or waits would cause issues, thats why the execute count is so important, essentially it is calling ExecuteFunction(function Trg_Somefunc), though i believe it is called using an underlying function not actually available in the editor. There is no way 2 instances of the same trigger can be run at the same time in the same thread if there are waits
Do you have an actual idea how a thread in an OS actually works?
If that would be true the performance of wc3 would drop down below 0.
What might be is that blizzard is simulating a similar condition then threads for triggers but i can not believe they would actually create separate threads for ingame triggers. Alone the synching problems would kill any bigger custom map, not speaking about the context switching which would appear in thousands.
 
yes I understand how a thread in an os actually works, and i know that, i do believe they are simulating a thread system, but thats what i was meaning, that with "their thread system" thats how they create triggers that run properly with multiple instances, even event systems in C++, Java, Python, and many many more work like this, creating new threads for each instance of a function (trigger) ran off an event (C++ uses delegates which create new threads in and of themselves, in most cases)

I believe they would make their own version of a thread because thats just what blizzard does, take sc2 editor for example, it is a C language, but classes are severely limited to the point of being between C and C++, this is just one perfect example of this, while there are many others
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top