Is there a downside to many events?

afisakov

You can change this now in User CP.
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?
 

GFreak45

I didnt slap you, i high 5'd your face.
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
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
1 Like = 1 rep. It's the same increase for everyone now; you don't add more rep for having more rep.
 

Accname

2D-Graphics enthusiast
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.
 

GFreak45

I didnt slap you, i high 5'd your face.
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
 

GFreak45

I didnt slap you, i high 5'd your face.
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
 

afisakov

You can change this now in User CP.
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?
 

Imp Midna

Active Member
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).
 

chukky-jr

Member
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?
 

Accname

2D-Graphics enthusiast
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.
 

GFreak45

I didnt slap you, i high 5'd your face.
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.
  • The Helper The Helper:
    they did not winterize any of the plants and they froze
  • The Helper The Helper:
    it is not that power consumption went up it was available capacity went down with power plants freezing
  • Varine Varine:
    What a fucking disaster. Are all of the Texas people okay? I see TH is, are we the only two?
  • Varine Varine:
    How have the other states held up? I just got power back so I have no idea what's going on, we didn't get warning
  • Varine Varine:
    Why the fuck didn't they fix this ten years ago when it happened?
  • Blackveiled Blackveiled:
    I'm in it with you and TH as well. My power has been in and out, and I have a ruptured pipe that I need to fix, shouldn't be too bad to fix myself.
  • Varine Varine:
    I hope you're staying warm! Apparently the supply is coming up so hopefully we can get back to normal power soon, mine has been on for six hours now.
  • M Mulciberxp:
    My power has been off most of the last 2 days. We had a generator installed 3 years ago though, so we're staying warm. Water is another issue...
  • The Helper The Helper:
    Where I live has a pool so we are using that to get water to flush the toilets. We have enough bottled water to drink and brush teeth and stuff but it has been a few days and no shower though....
  • Varine Varine:
    I had some water in gallon jugs, and got our water back on yesterday. We don't seem to have any leaks, but I haven't crawled down there to look yet.
  • The Helper The Helper:
    still no water I cannot remember when I last showered now I know how they felt in the old west lol
  • Varine Varine:
    My poor plants are happy, they aren
  • Varine Varine:
    aren't used to going this long without water or lights or normal heat. I think a couple of them froze, but they look like they'll make it
  • Varine Varine:
    Well one of them is pretty rough but I think it was sick to begin with, that one always had some problems.
  • jonas jonas:
  • jonas jonas:
    ???
  • Ghan Ghan:
    That is such a Texas thing to say lol
  • midnight8 midnight8:
    a positive could come out of this. So many people trapped at home could put a dent in the covid numbers in Texas
  • Varine Varine:
    That dude, Tom Boyd, is really upset about the backlash from his "it's your fault you're freezing" thing because he claims he resigned before saying it, so it wasn't like he said it in his official capacity or anything.
  • jonas jonas:
    Almost as if he was saying "screw you guys, I'm going home"
  • Varine Varine:
    I'm fairly new here still but that seems to be the analogous message by several of our politicians.
  • vypur85 vypur85:
    Nobody?
  • jonas jonas:
    Hi vypur85, long time no see
  • tom_mai78101 tom_mai78101:
    Hi vypur85, long time no see.
  • The Helper The Helper:
    We are all somebody

    Members online

    Affiliates

    Hive Workshop NUON Dome
    Top