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

Status
Not open for further replies.
Level 5
Joined
Aug 24, 2010
Messages
133
I've been trying to make a spell that creates n number of illusions in a circle.
I found that last created unit doesn't count illusions so I've made another trigger.

When I run this it displays the numbers: 2,1,1,2,1,2,1,1,1,3,3,3

Can someone please explain how triggers are added to the stack and how they are executed.

Seeing how 2 only appeared 3 out of 6 times and 3 appeared at all considering the group should be empty until at least 1 run through of the trigger.

  • omnislash
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Summon Illusion
    • Actions
      • For each (Integer A) from 1 to ((Level of Summon Illusion for (Triggering unit)) + 5), do (Actions)
        • Loop - Actions
          • Unit - Create 1 blank dummy dummy for (Triggering player) at (Position of (Triggering Unit)) facing Default building facing degrees
          • Unit - Add illusion regular for dummy to (Last created unit)
          • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
          • Trigger - Turn on illusion <gen>
          • Custom script: call IssueTargetOrderById(GetLastCreatedUnit(), 852274, GetTriggerUnit())
          • Trigger - Turn off illusion <gen>
          • Game - Display to (All players) the text: 1
      • Unit Group - Pick every unit in illusgroup and do (Actions)
        • Loop - Actions
          • Unit - Add bonus damage skill to (Picked unit)
          • Unit - Set level of bonus damage skill for (Picked unit) to (Level of Damage Bonus hero for (Triggering unit))
          • Game - Display to (All players) the text: 3
  • illusion
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
    • Actions
      • Unit Group - Add (Summoned unit) to illusgroup
      • Game - Display to (All players) the text: 2
 
Level 5
Joined
Aug 24, 2010
Messages
133
What's wrong with triggering player?
I've just never had a problem with turning a trigger on and off like that before, to make sure it only triggers for that instance. I guess yours works much better under high speeds
 
Level 5
Joined
Aug 24, 2010
Messages
133
Last created unit only refers to units created via Create a unit function. I'm not entirely sure what's going on in this trigger of yours, but would it not be better to just add the last created unit to the group instead of having it in a seperate trigger?

It's putting illusions into a variable.

Why people never check Tutorials??

I looked through the tutorials and couldn't find the answer to my question.
 
Level 5
Joined
Aug 24, 2010
Messages
133
Oh, I meant because you can't refer to an illusion with last created unit, I made a second trigger to add it to a unit group, using the event 'A unit Spawns a summoned unit', so I could refer to it later
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Oh, I meant because you can't refer to an illusion with last created unit
Weell... like I said, Last created unit only refers to units that are created via by the Create X unit function.

I made a second trigger to add it to a unit group, using the event 'A unit Spawns a summoned unit', so I could refer to it later

Whats wrong with this? You can change Playable map area to be a more specific location.

  • Set TempGroup = (Units in (Playable map area) matching (((Matching unit) is an illusion) Equal to True))
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
There could potentially already be other illusions in the area and if it has a pathing issue on spawn it could appear outside the area.

What I suggested above would only be a problem if there are multiple units that use that same ability that are owned by 1 player. Would that be a possible scenario in your map?
 
Level 5
Joined
Aug 24, 2010
Messages
133
Hmm, thinking about it I can make it even if there are other illusions there by making a group at the start of the spell then looping for all illusions in the area not in the group.
Cool thanks.

Back to my original question though, lol. Do you know how triggers are added to the queue.

Suppose I have these 2 triggers
I would expect that the 2nd trigger procs n times because of the loop
but it doesn't.

  • Spawn unit
    • Events
      • Some event
    • Conditions
    • Actions
      • For each (Integer A) from 1 to n, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
  • On unit spawn
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Game - Display to (All players) the text: 1
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Back to my original question though, lol. Do you know how triggers are added to the queue.

Suppose I have these 2 triggers
I would expect that the 2nd trigger procs n times because of the loop
but it doesn't.

  • Spawn unit
    • Events
      • Some event
    • Conditions
    • Actions
      • For each (Integer A) from 1 to n, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
  • On unit spawn
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Game - Display to (All players) the text: 1

Well the for loop events are happening simultaneously, so it would only display the text once.
 
Level 5
Joined
Aug 24, 2010
Messages
133
After more testing. There appears to be a maximum speed that a trigger can proc.
Initially the 2nd trigger procs about a third of n times for the loop but then if I add a 0.01 wait to the loop it procs the full n times.

Sometimes though, it will create 2 units then display '1' twice instead of
create, display, create, display.
 
Status
Not open for further replies.
Top