• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Simple Patrol Trigger Not Working

The Idea is suposed to be very simple, after a short amount of time (5 Seconds), three different units start to patrol from Point B and then back to Point A, but I can't get it to work...

They should all stop if:
In range to attack enemy units;
If any of them start to being attacked;
And if they change owner.

Was checking on other similar threads, but they all seems to be more for a more complex task.

Can someone show me an exemple of a similar trigger to what I have described? or any ideas on how to make it? Have tried a couple times and nothing...
 
Whats your goal, step by step, and whats stopping you from that goal?
Hey @Duckfarter, the goal was only for more immersion, a simple patrol trigger for 3 units on it (same units, doing the same patrol), they dindt have to do anything more then the normal stuff a unit would do while patroling an area.

So basically, a trigger that will keep then moving from point A, towards point B and then back to A.

I have tried to create the trigger, but they don't move at all.

Have also found another trigger on the internet, but that one was broken, and the units on patrol was ignoring spells and attacks, so again, a trigger that would make then patrol an area, but keep the normal funcion of an unit (like defending themselves).
 
Level 30
Joined
Aug 29, 2012
Messages
1,383
Getting to move them from a point to another should be the easiest to do, you can try something like this with 2 regions

  • Patrol To A
    • Events
      • Unit - A unit enters Patrol B <gen>
    • Conditions
      • (Triggering unit) Equal to Footman 0000 <gen>
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
    • Actions
      • Unit - Order (Triggering unit) to Attack-Move To (Center of Patrol A <gen>)
  • Patrol To B
    • Events
      • Unit - A unit enters Patrol A <gen>
    • Conditions
      • (Triggering unit) Equal to Footman 0000 <gen>
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
    • Actions
      • Unit - Order (Triggering unit) to Attack-Move To (Center of Patrol B <gen>)
(Yes memory leaks yada yada it's an example), It's a simple yo-yo trigger.

The trickier part would be to make them reset if they are attacked. I'm thinking of something like this
  • Patrol Attacked
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Triggering unit) Equal to Footman 0000 <gen>
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
    • Actions
      • Set VariableSet Patrol_Is_Attacked[1] = True
      • Countdown Timer - Start Combat_Timer[1] as a One-shot timer that will expire in 5.00 seconds
      • Wait until (Patrol_Is_Attacked[1] Equal to False), checking every 1.00 seconds
      • Unit - Order (Triggering unit) to Attack-Move To (Center of Patrol A <gen>)
  • Patrol Reset
    • Events
      • Time - Combat_Timer[1] expires
    • Conditions
    • Actions
      • Set VariableSet Patrol_Is_Attacked[1] = False
When the unit is attacked, you start a hidden timer and you set a boolean to yes (= the unit is being attacked), that will refresh until combat stops and timer expires, then the unit is ordered to attack move back to the first trigger points.

I'm not sure how heavy it is performance wise, but unless you have hundreds of patrolers it should be fine. Also you'd need to find a way to apply it to as many units as you need
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,875
I'd suggest a Unit Indexer + a design like this:

Setup everything for this particular patrol group at the start of the game:
  • Events
    • Time - Elapsed game time is 0.00 seconds
  • Conditions
  • Actions
    • Set Variable Patrol_Point_AB[1] = (Center of Patrol Region A <gen>)
    • Set Variable Patrol_Point_AB[2] = (Center of Patrol Region B <gen>)
    • Set Variable Patrol_Group_AB = (Units in Patrol Starting Region AB <gen>)
    • Unit Group - Pick every unit in Patrol_Group_AB and do (Actions)
      • Loop - Actions
        • Set Variable Patrol_CV = (Custom value of (Picked unit))
        • Set Variable Patrol_Point[Patrol_CV] = Point_Point_AB[1]
Periodically update their orders to keep them from going idle in the middle of nowhere:
  • Events
    • Time - Every 10.00 seconds of game-time
  • Conditions
  • Actions
    • Unit Group - Pick every unit in Patrol_Group_AB and do (Actions)
      • Loop - Actions
        • Set Variable Patrol_CV = (Custom value of (Picked unit))
        • Unit - Order (Picked unit) to Attack-Move To Patrol_Point[Patrol_CV]
Update their next destination:
  • Patrol To B
    • Events
      • Unit - A unit enters Patrol Region A <gen>
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
    • Actions
      • Set Variable Patrol_CV = (Custom value of (Triggering unit))
      • Set Variable Patrol_Point[Patrol_CV] = Point_Point_AB[2]
      • Unit - Order (Triggering unit) to Attack-Move To Patrol_Point[Patrol_CV]
Update their next destination (again, necessary for each region):
  • Patrol To A
    • Events
      • Unit - A unit enters Patrol Region B <gen>
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
    • Actions
      • Set Variable Patrol_CV = (Custom value of (Triggering unit))
      • Set Variable Patrol_Point[Patrol_CV] = Point_Point_AB[1]
      • Unit - Order (Triggering unit) to Attack-Move To Patrol_Point[Patrol_CV]
Now the units know where they're going at all times. No matter what happens they will always know the correct next destination.
 
Top