• 🏆 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] how to make a trigger run first?

Status
Not open for further replies.
Level 6
Joined
Dec 8, 2016
Messages
127
A simple question,

I want to make a trigger with event 'starts effect of ability' that the action is to prepare dummies for other hundred spells that i want to make, how can i make sure this trigger runs first before the other 'starts effect of ability' triggers? or is there any better way to split trigger?

I know i can just make dummy for each spell but i want to make the actions to be as short as possible for each spell for easy reference.

thanks
 
Level 22
Joined
Aug 27, 2013
Messages
3,973
You can't decide which trigger runs first. If you have two triggers with same events, it depends on when and which event fires first.
Well, that's just how people usually do it. They make dummies for each spell and remove it when the spell is finished.
I know i can just make dummy for each spell but i want to make the actions to be as short as possible for each spell for easy reference.
Does that mean the dummy is re-use-able?
 
Level 6
Joined
Dec 8, 2016
Messages
127
You can't decide which trigger runs first. If you have two triggers with same events, it depends on when and which event fires first.
Well, that's just how people usually do it. They make dummies for each spell and remove it when the spell is finished.

Does that mean the dummy is re-use-able?
yes.. dummies are not removed after cast.
 
Level 10
Joined
Sep 16, 2016
Messages
269
A simple question,

I want to make a trigger with event 'starts effect of ability' that the action is to prepare dummies for other hundred spells that i want to make, how can i make sure this trigger runs first before the other 'starts effect of ability' triggers? or is there any better way to split trigger?

I know i can just make dummy for each spell but i want to make the actions to be as short as possible for each spell for easy reference. thanks

I assume you want to make a xecast like Vexorian's ? Then on map init - "Elapsed game in 0s" you can create those dummies and leave it for later use.
I don't really get why the event "unit starts effect" matters when the game first begins. If you still insist on that: in triggers with the same event, the one higher on the trigger list will run first.
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
triggers with the same event, the one higher on the trigger list will run first.
It's actually whichever one was created in the Trigger Editor first. Try reordering them and you'll see it doesn't change the execution order.

Something to keep in mind with reusing your dummy units is that even with max turn speed and 0 cast point/backswing a dummy unit must turn to face the target if it's not already doing so. This may delay casting some dummy spells (depending on where the targets are located and how the dummy is currently facing), and if you tell a dummy to cast multiple spells in rapid succession it may not cast all of them. Vex got around this in XE by having 12 dummy units with one facing 0, 30, 60, 90, etc. and then picking the proper one based on the angle to target.
 
Level 6
Joined
Dec 8, 2016
Messages
127
Assume in my map 10 players have played for 1 hour and each of the player has casted the same spell for 100 times. Traditional trigger would be "create 1 dummy" for each spell casted, that would equal to have created 1000 times. I think it is more efficient if the dummy for this spell to be created once and reused as many times as possible, since 1 dummy is enough for all players for this particular spell.

"Prepare" i mean to detect if there is any idling dummies available before creating one. If only one dummy needed then only create one. If need 50 dummies then create 50.
So i think the best way to detect idling dummies when casting spell is "start the effect of an ability". Yes i know that "elapse time is 0 second - create dummies" can be used but "starts effect of ability" can create the exact number of dummies needed. Lesser number of dummies is better for performance, i suppose?
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
Honestly you should just use Vexorian's xe; he wrote the system to make spellcasting easier, more efficient, and more intelligent under the hood. Everything you want and none of the hassle to make sure it works properly.

Probably xebasic + xedummy and xecast. Add in xefx too if you want to use it for easy peasy special effects, and xedamage makes damaging thing way simple too.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,199
Something to keep in mind with reusing your dummy units is that even with max turn speed and 0 cast point/backswing a dummy unit must turn to face the target if it's not already doing so. This may delay casting some dummy spells (depending on where the targets are located and how the dummy is currently facing), and if you tell a dummy to cast multiple spells in rapid succession it may not cast all of them. Vex got around this in XE by having 12 dummy units with one facing 0, 30, 60, 90, etc. and then picking the proper one based on the angle to target.
I thought making the dummy a ward or building solved this. Those do not need to turn to cast.

Assume in my map 10 players have played for 1 hour and each of the player has casted the same spell for 100 times. Traditional trigger would be "create 1 dummy" for each spell casted, that would equal to have created 1000 times. I think it is more efficient if the dummy for this spell to be created once and reused as many times as possible, since 1 dummy is enough for all players for this particular spell.
Dummy recycling is an old idea and is even recommended due to units having (hopefully had, needs retesting in 1.27b) a permanent memory leak. Additionally moving a dummy with SetUnitX/Y is a lot faster than creating a new one. Best is if dummy units are used by multiple systems. On the other hand timer recycling, group recycling etc are unnecessary as they do not leak and are fairly light weight.

I want to make a trigger with event 'starts effect of ability' that the action is to prepare dummies for other hundred spells that i want to make, how can i make sure this trigger runs first before the other 'starts effect of ability' triggers? or is there any better way to split trigger?
Do something like LordDz suggested.
Have a simple trigger that runs on "a unit starts the effect of an ability".
Then make that trigger run the two other triggers in which order you want.
This can be further extended to even improve scalability and performance. For example a hashtable could be used to map the ability type being cast to a trigger with O(1) performance. Casting such an ability would then have a complexity of O(1) as opposed to the standard O(n) where every triggered ability checks every ability cast if it is intended for them. I believe vexoirans caster system offers such functionality. In any case I would certainly recommend making this a system and recommend integrating it to all trigger enhanced abilities for maximum efficiency. The order in which the system evaluates bound triggers can be well defined and customized, such as by a priority system.
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
I thought making the dummy a ward or building solved this. Those do not need to turn to cast.
Wasn't aware of this; unfortunate you can't apply either classification dynamocally though. You should probably assume that if what I said doesn't make sense I am simply operating on years-old information that is somehow still knocking around in my brain. I'm no Aniki bringing up new stuff all the time.
 
Status
Not open for further replies.
Top