• 🏆 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] This trigger is giving me a headache

Status
Not open for further replies.
Level 2
Joined
Feb 15, 2018
Messages
8
I don't know why this trigger isn't working

  • Part 1
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Trap
    • Actions
      • Set Index = (Index + 1)
      • Set TrapUnits[Index] = (Units in No region)
      • Wait 1.00 game-time seconds
      • Set TrapUnitsInRange[Index] = (Units within 64.00 of (Position of (Attacking unit)))
      • Unit Group - Pick every unit in TrapUnitsInRange[Index] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A ground unit) Equal to True
              • ((Picked unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True
            • Then - Actions
              • Unit Group - Add (Picked unit) to TrapUnits[Index]
            • Else - Actions
      • Trigger - Turn on Part 2 <gen>
      • Trigger - Turn on Part 3 <gen>
  • Part 2
    • Events
      • Time - Elapsed game time is 1.10 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in TrapUnits[Index] and do (Actions)
        • Loop - Actions
          • Unit - Pause (Picked unit)
          • Unit - Add Crow Form to (Picked unit)
          • Unit - Remove Crow Form from (Picked unit)
          • Animation - Change (Picked unit) flying height to 2000.00 at 2000.00
          • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
  • Part 3
    • Events
      • Time - Elapsed game time is 1.50 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in TrapUnits[Index] and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
I was trying at first with pre-placed units nearby the trap and it worked, but when I was using a unit walking through the trap it didn't do anything.

The idea of the trigger is that when a unit comes near the trap (the trap attack the unit) it waits a second and then launch all the units in a radius of 64 very high and remove them from the map.
 
The indexing (Index + 1) is also physically seperated with its usage (Set TrapUnitsInRange[Index]... ) with using the "Wait 1" seconds, which may lead to unwanted behaviour. Within the wait, the trigger might fire again, and might instantly increase the index again, before usage of first instance applied.

"Elapsed Game Time" event will only fire exactly once.

Have a look into "Dynamic indexing" tutorial from my signature's links. It is what can help.
 
Level 2
Joined
Feb 15, 2018
Messages
8
Sorry for the late response and thanks for the patience, I was busy with some things

Using the dynamic indexing tutorial I end up with something like this:

  • Part 1
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Trap
    • Actions
      • Set Index = (Index + 1)
      • Set TrapUnits[Index] = (Units in No region)
      • Set TrapUnitsInRange[Index] = (Units within 300.00 of (Position of (Attacking unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Index Equal to 1
        • Then - Actions
          • Trigger - Turn on Part 2 <gen>
          • Trigger - Turn on Part 3 <gen>
          • Trigger - Turn on Part 4 <gen>
        • Else - Actions
  • Part 2
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer LoopInteger) from 1 to Index, do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in TrapUnitsInRange[LoopInteger] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is A ground unit) Equal to True
                  • ((Picked unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True
                • Then - Actions
                  • Unit Group - Add (Picked unit) to TrapUnits[Index]
                • Else - Actions
  • Part 3
    • Events
      • Time - Every 1.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer LoopInteger) from 1 to Index, do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in TrapUnits[LoopInteger] and do (Actions)
            • Loop - Actions
              • Unit - Pause (Picked unit)
              • Unit - Make (Picked unit) Invulnerable
              • Unit - Add Crow Form to (Picked unit)
              • Unit - Remove Crow Form from (Picked unit)
              • Animation - Change (Picked unit) flying height to 2000.00 at 2000.00
              • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
  • Part 4
    • Events
      • Time - Every 1.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer LoopInteger) from 1 to Index, do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in TrapUnits[LoopInteger] and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (TrapUnits[LoopInteger] is empty) Equal to True
                • Then - Actions
                  • Set TrapUnits[LoopInteger] = TrapUnits[Index]
                  • Set Index = (Index - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Index Equal to 0
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                      • Trigger - Turn off Part 2 <gen>
                      • Trigger - Turn off Part 3 <gen>
                    • Else - Actions
                • Else - Actions
But for some reason this isn't working either
 
Status
Not open for further replies.
Top