generally speaking from what I know from reading some other posts and from other people's experience it's not great to split triggers up and have loads of small triggers. however, over 500 condition checks seems a little on the heavy side. what you could probably do is clean up or improve the way you are trying to solve your problem.
e.g. by using function(s) to break up some of the work etc
if you explain what you are doing in more detail then i'm sure others or my self can help more
Boolean checks in SC2 are pretty fast. However, 500 checks is quite a bunch. Are we talking about a one-time event or more like constantly checking 500+ conditions?
For one-time or occasionally fired triggers, this should not be a huge problem.
Quote:
Should I just break this single trigger into 500+ triggers? Would that make it run faster?
Maybe yes, maybe not. Depends on the specific situation. If you use a separate event for each trigger instead, it will theoretically use more memory, because of the additional trigger objects, but would be more performant in running the separate instances.
If you use the same event for all triggers, however, it might not improve anything.
Anyway, how does your trigger look like? What exactly do you need these checks for? Maybe there is a better alternative.
Here's what I am trying to do. In my map, I basically have many abilities available to a player. It's an RPG, so they also have an action bar. They can definite their hotkeys on the action bar with access to over 500 abilities (not actually 500, some will be passive)
I want it so that when they click on the hotkey on the action bar, that it won't check 500 different things to see what kind of ability is hotkeyed. I wish there was a "Action Definition" variable, as this would solve everything. Or if there were passable parameters through "Run Trigger" action. I can't figure out a good solution though.
when a player assigns a spell to position two for example, can you not set a variable like:
hotkey_var[player][hotkey number] = "flame wall";
then when a player presses this hotkey you can run an action definition passing hoykey_var and the triggering player and use a switch to then make the player cast flame wall etc
I am pretty sure, you can do that without any conditions at all. Like the Minister says, some smart use of variables, arrays or maybe even the data table should solve this easily.
However don't ask me, I would just use galaxy script xD
Quote:
Or if there were passable parameters through "Run Trigger" action. I can't figure out a good solution though.
Yes, I can do that, Xil. But that's ending up in the same thing I was just discussing, no? Because the switch will then run through a mass list of conditions searching for "flame wall".
Action definitions are indeed useful, however you can't assign a variable to them. Triggers can be assigned variables. What I was proposing, if hypothetically triggers had parameters, that I would just assign a trigger to a variable and run that variable(trigger) when the hotkey is pressed.
So instead, you could pass them using temporary globals as Kueken suggested. It would be simpler than doing a binary search by assigning integers to represent spells.
yes my method's only plus was to make the code a bit neater
I think the answer has pretty much been said over a few posts from what I can see though.
Set up a trigger called Flame Wall, make sure it has no event and make sure the trigger only references global vars, e.g. assign the players unit to a global var, assign the player into a global var when it presses the hotkey button etc. so now you have a trigger, assign it to a variable. now when someone chooses flame wall as hotkey 2, reference the trigger var to that hotkey and then when someone presses it, it will run the Flame Wall trigger.
that way should eliminate any mass condition if/elses or swtichs etc and having no events in the 500 triggers will make sure you are not wasting space with them.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Would over 500 condition checks running in a single thread slow down the trigger's process? Or would it still be near instantaneously fast? Thank you.
EDIT: Forgot to ask. Should I just break this single trigger into 500+ triggers? Would that make it run faster?
generally speaking from what I know from reading some other posts and from other people's experience it's not great to split triggers up and have loads of small triggers. however, over 500 condition checks seems a little on the heavy side. what you could probably do is clean up or improve the way you are trying to solve your problem.
e.g. by using function(s) to break up some of the work etc
if you explain what you are doing in more detail then i'm sure others or my self can help more
Boolean checks in SC2 are pretty fast. However, 500 checks is quite a bunch. Are we talking about a one-time event or more like constantly checking 500+ conditions?
For one-time or occasionally fired triggers, this should not be a huge problem.
Maybe yes, maybe not. Depends on the specific situation. If you use a separate event for each trigger instead, it will theoretically use more memory, because of the additional trigger objects, but would be more performant in running the separate instances.
If you use the same event for all triggers, however, it might not improve anything.
Anyway, how does your trigger look like? What exactly do you need these checks for? Maybe there is a better alternative.
@Kueken531: Go
Here's what I am trying to do. In my map, I basically have many abilities available to a player. It's an RPG, so they also have an action bar. They can definite their hotkeys on the action bar with access to over 500 abilities (not actually 500, some will be passive)
I want it so that when they click on the hotkey on the action bar, that it won't check 500 different things to see what kind of ability is hotkeyed. I wish there was a "Action Definition" variable, as this would solve everything. Or if there were passable parameters through "Run Trigger" action. I can't figure out a good solution though.
when a player assigns a spell to position two for example, can you not set a variable like:
hotkey_var[player][hotkey number] = "flame wall";
then when a player presses this hotkey you can run an action definition passing hoykey_var and the triggering player and use a switch to then make the player cast flame wall etc
I can of course elaborate more if you wish.
I am pretty sure, you can do that without any conditions at all. Like the Minister says, some smart use of variables, arrays or maybe even the data table should solve this easily.
However don't ask me, I would just use galaxy script xD
You can always pass values with global variables.
@Kueken531: Go
Yes, I can do that, Xil. But that's ending up in the same thing I was just discussing, no? Because the switch will then run through a mass list of conditions searching for "flame wall".
That's what action definitions are for. You should never need to use Run Trigger.
@LosTacos: Go
Action definitions are indeed useful, however you can't assign a variable to them. Triggers can be assigned variables. What I was proposing, if hypothetically triggers had parameters, that I would just assign a trigger to a variable and run that variable(trigger) when the hotkey is pressed.
I guess I didn't read close enough.
So instead, you could pass them using temporary globals as Kueken suggested. It would be simpler than doing a binary search by assigning integers to represent spells.
@Enexy: Go
yes my method's only plus was to make the code a bit neater
I think the answer has pretty much been said over a few posts from what I can see though.
Set up a trigger called Flame Wall, make sure it has no event and make sure the trigger only references global vars, e.g. assign the players unit to a global var, assign the player into a global var when it presses the hotkey button etc. so now you have a trigger, assign it to a variable. now when someone chooses flame wall as hotkey 2, reference the trigger var to that hotkey and then when someone presses it, it will run the Flame Wall trigger.
that way should eliminate any mass condition if/elses or swtichs etc and having no events in the 500 triggers will make sure you are not wasting space with them.