• 🏆 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] Trigger only work for 2 times??

Status
Not open for further replies.
Level 2
Joined
Jun 13, 2020
Messages
16
I had made these triggers below to order the player 7 unit to attack the specific unit(Surviver) of player 1 to player 6

1st trigger
Rich (BB code):
  • Untitled Trigger 002
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set Unit_integer = 0
      • For each (Integer Looping_integer) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player(Looping_integer)) slot status) Equal to Is playing
            • Then - Actions
              • Set Unit_integer = (Unit_integer + 1)
              • Set Player_VitalUnit[Unit_integer] = (Units owned by (Player(Looping_integer)) of type Surviver)
              • Set Targeted_Unit[Unit_integer] = (Random unit from Player_VitalUnit[Unit_integer])
              • Set Targeted_Unit_Point[Unit_integer] = (Position of Targeted_Unit[Unit_integer])
              • Custom script: set udg_attack_group[udg_Unit_integer] =CreateGroup()
              • Unit Group - Add Demon Hall 0000 <gen> to attack_group[Unit_integer]
            • Else - Actions
Code:

This first trigger is to check whether player 1 to player 6 slot status is unused or not and create the attack_group if the slot status is not unused.

2nd trigger
Rich (BB code):
  • Attack
    • Events
    • Conditions
    • Actions
      • For each (Integer Looping_integer) from 1 to Unit_integer, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (attack_group[Looping_integer] is empty) Equal to False
            • Then - Actions
              • Custom script: call RemoveLocation(udg_Targeted_Unit_Point[udg_Looping_integer])
              • Set Targeted_Unit_Point[Looping_integer] = (Position of Targeted_Unit[Looping_integer])
              • Set TemporaryGroup[1] = (Random (Random integer number between 4 and 6) units from PickableGroup)
              • Unit Group - Pick every unit in TemporaryGroup[1] and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is A structure) Equal to False
                      • (Owner of (Picked unit)) Equal to Player 7 (Green)
                      • ((Picked unit) is alive) Equal to True
                    • Then - Actions
                      • Unit Group - Add (Picked unit) to attack_group[Looping_integer]
                      • Unit Group - Remove (Picked unit) from PickableGroup
                      • Unit Group - Order attack_group[Looping_integer] to Attack-Move To Targeted_Unit_Point[Looping_integer]
                    • Else - Actions
              • Custom script: call DestroyGroup(udg_TemporaryGroup[1])
            • Else - Actions
Code:

The second trigger is to order the each attack_group to attack their enemy(SURVIVER)

3rd trigger
Rich (BB code):
  • Target dead
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • For each (Integer Looping_integer2) from 1 to Unit_integer, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering unit) Equal to Targeted_Unit[Looping_integer2]
            • Then - Actions
              • Unit Group - Add all units of attack_group[Looping_integer2] to PickableGroup
              • Unit Group - Remove all units from attack_group[Looping_integer2]
              • Custom script: call RemoveLocation(udg_Targeted_Unit_Point[udg_Looping_integer2])
              • Trigger - Run Attack <gen> (checking conditions)
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Triggering unit) is in attack_group[Looping_integer2]) Equal to True
                • Then - Actions
                  • Unit Group - Remove (Triggering unit) from attack_group[Looping_integer2]
                • Else - Actions

The third trigger is to detect whether the unit(SURVIVER) is dead or not.If so,all the units inside the attack group that are responsible to attack that unit(SURVIVER) will be removed ,so no more unit will be added into this attack_group anymore(through the second trigger).This trigger also remove the dying_unit from the attack group

So,basically when each wave of unit was spawned,wave of units will added into PICKABLE_Group variable so that these unit can picked and added to attack_group through second trigger.At the same time,the second trigger will be executed.

Below is the example of unit wave trigger that I have done.

Wave trigger
Rich (BB code):
  • Spawn 1
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • Unit - Create (3 x Unit_integer) Zergling for Player 7 (Green) at (Random point in ftfrr <gen>) facing Default building facing degrees
      • Unit Group - Add all units of (Last created unit group) to PickableGroup
      • Trigger - Run Attack <gen> (checking conditions)

So, why my second trigger malfunction after it was executed by second times???Sorry for my poor english and explanations btw.
 
Last edited:
Status
Not open for further replies.
Top