1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] Units ignore order in certain trigger only

Discussion in 'Triggers & Scripts' started by The_Spellweaver, Jul 3, 2018.

  1. The_Spellweaver

    The_Spellweaver

    Joined:
    Feb 20, 2013
    Messages:
    95
    Resources:
    2
    Models:
    2
    Resources:
    2
    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.

    First trigger

    • 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)



    Second trigger

    • 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
     

    Attached Files:

    Last edited: Jul 3, 2018
  2. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,304
    Resources:
    7
    Models:
    1
    Icons:
    2
    Spells:
    3
    JASS:
    1
    Resources:
    7
    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.
     
  3. The_Spellweaver

    The_Spellweaver

    Joined:
    Feb 20, 2013
    Messages:
    95
    Resources:
    2
    Models:
    2
    Resources:
    2
    They do call it though, the floating text appears as I've noted already, which means the trigger is getting executed, but unit is totally ignoring the order. And I'm sure there is that specific unit inside it, because the text command trigger works normally.
     
  4. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,304
    Resources:
    7
    Models:
    1
    Icons:
    2
    Spells:
    3
    JASS:
    1
    Resources:
    7
    Perhaps posting the entire trigger would help?
     
  5. The_Spellweaver

    The_Spellweaver

    Joined:
    Feb 20, 2013
    Messages:
    95
    Resources:
    2
    Models:
    2
    Resources:
    2
    I posted all of the relevant triggers, it's mostly placeholder though. I wanted to solve it in a simple and efficient way,
    but in the meantime, I'll use "Wait for condition" to move, and checking every second for sightings in range.
     
  6. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,304
    Resources:
    7
    Models:
    1
    Icons:
    2
    Spells:
    3
    JASS:
    1
    Resources:
    7
    It looks like the event dynamically registered is only affixed to a certain unit. See the critical line that I pointed out. (System always registering to the same unit)
     
  7. The_Spellweaver

    The_Spellweaver

    Joined:
    Feb 20, 2013
    Messages:
    95
    Resources:
    2
    Models:
    2
    Resources:
    2
    But that's alright, it's intended behaviour. And it does fire off, the thing that bothers me is that within that trigger, the unit does not respond to the issued order. I can do pretty much everything else to it, and it happens.
    Now I'm not sure how order queue works so I really don't know what's happening there.
     
  8. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,304
    Resources:
    7
    Models:
    1
    Icons:
    2
    Spells:
    3
    JASS:
    1
    Resources:
    7
    Welp, I would like to see the triggers in physical form. Could you post the map?
     
  9. The_Spellweaver

    The_Spellweaver

    Joined:
    Feb 20, 2013
    Messages:
    95
    Resources:
    2
    Models:
    2
    Resources:
    2
    I made a separate map to see if it'll work. This time I put 3 footmen, and the result seems to be the same.
    The "attack" order is somehow prioritized over any move action made in that trigger.
    However, the command still works though.
     
  10. nedio95

    nedio95

    Joined:
    Mar 24, 2011
    Messages:
    1,055
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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:
    Code (vJASS):
    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: Jul 4, 2018
  11. The_Spellweaver

    The_Spellweaver

    Joined:
    Feb 20, 2013
    Messages:
    95
    Resources:
    2
    Models:
    2
    Resources:
    2
    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.
     
  12. pick-a-chew

    pick-a-chew

    Joined:
    Jul 15, 2007
    Messages:
    691
    Resources:
    4
    Icons:
    2
    Maps:
    2
    Resources:
    4
    Why not just add a 0.1 sec wait? Surely that would eliminate the possibility of "Unit Acquires target" event interacting badly with issued orders.
     
  13. nedio95

    nedio95

    Joined:
    Mar 24, 2011
    Messages:
    1,055
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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
     
  14. The_Spellweaver

    The_Spellweaver

    Joined:
    Feb 20, 2013
    Messages:
    95
    Resources:
    2
    Models:
    2
    Resources:
    2
    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?
     
  15. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,905
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Yes the AI tends to override orders given to units. They need to be controlled by Neutral Hostile or Neutral Passive.

    All the jass natives can be found here, for further reference: JASS Manual: API Browser - Functions in common.j

    The one you want is one of these:
    Code (vJASS):
    native IssueInstantPointOrder
    native IssueInstantPointOrderById
     
  16. The_Spellweaver

    The_Spellweaver

    Joined:
    Feb 20, 2013
    Messages:
    95
    Resources:
    2
    Models:
    2
    Resources:
    2
    I see, thank you

    Since I never used these two, what does make them different from these two?:
    Code (vJASS):
    native IssuePointOrder
    native IssuePointOrderById


    What's the widget "instantTargetWidget" parameter used for?
     
  17. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,905
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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.