• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Units ignore order in certain trigger only

Status
Not open for further replies.
Hi, I've been dealing with this for a few hours now and I can't seem to understand why this is happening. I wanted to make a unit group travel to a certain point, and if any of them sees an enemy on the way, they all return to the base.


  • Town AI Initialization
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • -------- Setup potential scout destination points --------
      • Set SCOUT_DESTINATION[0] = (Position of Dummy 0035 <gen>)
      • Set SCOUT_DESTINATION[1] = (Position of Dummy 0039 <gen>)
      • Set SCOUT_DESTINATION[2] = (Position of Dummy 0036 <gen>)
      • Set SCOUT_DESTINATION[3] = (Position of Dummy 0033 <gen>)
      • Set SCOUT_DESTINATION[4] = (Position of Dummy 0038 <gen>)
      • Set SCOUT_DESTINATION[5] = (Position of Dummy 0037 <gen>)
      • -------- Setup potential scout destination points --------
      • Set SetupScoutActionsTrigger[0] = PatrolEncounterTL <gen>
      • Set SetupScoutActionsTrigger[1] = PatrolEncounterR <gen>
      • Set SetupScoutActionsTrigger[2] = PatrolEncounterB <gen>
      • -------- Setup Villagers and their homes --------
      • Trigger - Run StartOfDayActions <gen> (checking conditions)



  • StartOfDayActions
    • Events
      • Time - DayTimer expires
    • Conditions
    • Actions
      • -------- Loop through each of 3 towns --------
      • For each (Integer A) from 0 to (NUMBER_OF_CITIES - 1), do (Actions)
        • Loop - Actions
          • -------- This is used for the "Starting Phase", before demons are discovered --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DemonDiscoverSightings[(Integer A)] Equal to 0
            • Then - Actions
              • -------- If no demons were seen by scouts, or no warning messages came from other towns, keep sending one scout --------
              • -------- Create one scout, set it to a unit group array variable and start the "SetupOneScoutActions" timer --------
              • Set ScoutPatrolUnits[(Integer A)] = (Units owned by Player 12 (Brown) of type Scout)
              • Set ScoutRoutePoint[(Integer A)] = SCOUT_DESTINATION[(Random integer number between 0 and 5)]
              • Trigger - Add to SetupScoutActionsTrigger[(Integer A)] the event (Unit - Scout 0034 <gen> Acquires a target)
              • Countdown Timer - Start ScoutPatrolTimer[(Integer A)] as a One-shot timer that will expire in (Random real number between 0.00 and 10.00) seconds
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • DemonDiscoverSightings[(Integer A)] Equal to 1
                • Then - Actions
                  • -------- If demons were seen by scouts once, a single warning message came from other towns, send a small guard patrol (3 guards) --------
                  • -------- Create 3 guards, set them to a unit group variable and run the "SetupGuardPatrolActions" trigger on the end of this trigger --------
                • Else - Actions
                  • -------- Offense actions --------
      • Countdown Timer - Start DayTimer as a One-shot timer that will expire in 240.00 seconds


This sets them on their path, I've tried both Attack Move and Patrol:
  • SetupTownTLScoutActions
    • Events
      • Time - ScoutPatrolTimer[0] expires
    • Conditions
    • Actions
      • Game - Display to (All players) the text: Scout has departed!
      • Unit Group - Order ScoutPatrolUnits[0] to Patrol To ScoutRoutePoint[0]
And this should stop them from attacking further and make them come back. But it doesn't. The floating text appears normally, I can pause the unit and unpause it, but they just completely ignore all orders I give them.
  • PatrolEncounterTL
    • Events
    • Conditions
    • Actions
      • Floating Text - Create floating text that reads Demons! Run! at (Position of (Triggering unit)) with Z offset 50.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
      • Unit Group - Pick every unit in ScoutPatrolUnits[0] and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Move To (Position of Barracks 0014 <gen>)
I also tried this and it is working perfectly fine.
  • command
    • Events
      • Player - Player 1 (Red) types a chat message containing -return as An exact match
    • Conditions
    • Actions
      • Unit Group - Pick every unit in ScoutPatrolUnits[0] and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Move To (Position of Barracks 0014 <gen>)
I'd really appreciate any and all help

Edit: posted first and second trigger
 

Attachments

  • 123456.w3x
    19.1 KB · Views: 26
Last edited:
The critical line is this:

  • Trigger - Add to SetupScoutActionsTrigger[(Integer A)] the event (Unit - Scout 0034 <gen> Acquires a target)
If the triggers there do not call the following trigger,

  • [IMG]https://www.hiveworkshop.com/styles/default/ratrigger/base.gif[/IMG]PatrolEncounterTL
then there's your problem. Those triggers do not execute that particular trigger. Of course, this is all just speculation.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
Try doing this:
  • Set tUnit = (Picked Unit)
  • Custom script: call PauseUnit(udg_tUnit, true) //<-- Pauses the unit, should have GUI counterpart?
  • Custom script: call IssueImmediateOrderById(udg_tUnit, 851972) //<--- This orders stop
  • Custom script: call PauseUnit(udg_tUnit, false) //<-- UnPauses the unit, should also have GUI counterpart?
  • Unit - Order (Picked unit) to Move To (Position of Barracks 0014 <gen>)

I am not 100% sure, but I think most orders are not instant and ordering move to point would just slap it on a queue.
Just doing "stop" would slap the stop on a queue... ?
Pause > Stop > Unpause should clear the queue.

You could slap this into a functions like:
JASS:
function ClearOrderQueue takes unit u returns nothing
   call PauseUnit(u, true)
   call IssueImmediateOrderById(u, 851972)
   call PauseUnit(u, false)
endfunction
and then just do:
  • Set tUnit = (Picked Unit)
  • Custom script: call ClearOrderQueue(tUnit)
  • Unit - Order (Picked unit) to Move To (Position of Barracks 0014 <gen>)



Disclaimer: I may be 100% wrong on this. Also, my jass syntax may not be 100% accurate...

regards
-Ned
 
Last edited:
I tried pausing, issuing move, unpausing already, and it didn't work. I tried what you suggested, but not even "stop" works here. I am guessing because of nature of how trigger event has fired, any orders I give to units gets overwritten by the previous one, or just doesn't plainly stick. MyPad might be right, but not in the way I initially thought.

I stopped using this code, but for sake of clarifying, I wanted to know why this happens.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
I tried pausing, issuing move, unpausing already, and it didn't work. I tried what you suggested, but not even "stop" works here. I am guessing because of nature of how trigger event has fired, any orders I give to units gets overwritten by the previous one, or just doesn't plainly stick. MyPad might be right, but not in the way I initially thought.

I stopped using this code, but for sake of clarifying, I wanted to know why this happens.
Mmmmmmm... I'd assume, you've tried switching the positions of unpause and move like this?
  • Set tUnit = (Picked Unit)
  • Custom script: call PauseUnit(udg_tUnit, true) //<-- Pauses the unit, should have GUI counterpart?
  • Custom script: call IssueImmediateOrderById(udg_tUnit, 851972) //<--- This orders stop
  • Custom script: call PauseUnit(udg_tUnit, false) //<-- UnPauses the unit, should also have GUI counterpart?
  • Unit - Order (Picked unit) to Move To (Position of Barracks 0014 <gen>)
I'd assume one could do IssueImmediateOrderByID with Move To Point but I am not sure about the syntax. If it exists, it should be on the "API". If somebody could pitch in on this, even better.

And you have debugged to isolate specifically the order not working, instead of the unit group or the unit?

Otherwise, is it possible that you could have AI interfering ? Is the unit owned by non-player slot ?


regards
-Ned
 
I am not home so I cannot test, but I can confirm that unit belongs to player brown, and it is set to the computer. Could it be that AI inserts its own order before the one from my trigger starts to work? Is it because the event "Acquires a targe" fires off in middle or before AI script, unlike one like Player Message... Which is probably part of UI?
 
Level 39
Joined
Feb 27, 2007
Messages
5,031
It's been too long since I used either to tell you what the 'instant'-ness really changes other than possibly overriding the units existing order queue.

I would guess the targetwidget makes the unit face that target before doing the order for purposes of cinematics, but again no actual idea. Try with null in that argument and also with any other unit. Perhaps create an invisible dummy and use that to see if it makes a difference.
 
Status
Not open for further replies.
Top