• 🏆 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!

Building order trigger

Status
Not open for further replies.
Level 7
Joined
Jan 11, 2022
Messages
108
Hey, I wanted to make a worker build something above the trees (I already changed building's collision and path to none, and a trigger that after finishing construction it deletes itself and places a unit that has the same model as building and is placed above the trees) but the problem is - a worker can't go through trees so can't start a construction!! Because of that I thought that maybe I can make a trigger that as soon as I place the destination of the building, the worker will stop, dummy will be created and the dummy will begin the construction... but I can't find right Event (with this event the worker has to get to the place of construction)

  • Dummy build
    • Events
      • Unit - A unit begins Building
    • Conditions
      • (Unit-type of (Constructing structure)) Equal to Skyreaper
    • Actions
      • Set Tempunit = (Triggering unit)
      • Set Temppoint = (Position of (Constructing structure))
      • Set Tempplayer = (Triggering player)
      • Unit - Order Tempunit to Stop
      • Unit - Create 1 Dummy for Tempplayer at Temppoint facing default building facing degrees
      • Set Dummy = (Last created unit)
      • Unit - Order Dummy to build a Skyreaper at Temppoint
      • Unit - Add a 0.20 second generic expiration timer to Dummy
      • Custom script: call RemoveLocation(udg_Temppoint)
 
Level 39
Joined
Feb 27, 2007
Messages
4,994
When a unit is ordered to build, it is issued a point order. This order only exists as an integer (it does not have a string counterpart when converted to a string), and the integer matches whatever the rawcode of the constructing structure is (converted to an integer). For example: ordering a peasant to create a Scout Tower produces the order 1752659063, which is the rawcode 'hwtw' converted from base-256 to base-10.

GUI cannot interact with OrderIds directly and even though a rawcode is an integer (thus requires no conversion) it will not let you use one in an integer comparison condition. Thus the only way to check something like this must be done like so and cannot happen in a trigger condition:
  • Events
    • Unit - A unit is issued an order targeting a point
  • Conditions
    • -------- a condition like this can help filter out most other irrelevant orders --------
    • (Unit-type of (Triggering Unit)) equal to YOUR_WORKER_THAT_CAN_BUILD_THESE_STRUCTURES
  • Actions
    • -------- the variable below, IssuedOrder, is actually a UNIT-TYPE variable in the variable editor --------
    • Custom script: set udg_IssuedOrder = GetIssuedOrderId() //keep the udg_ prefix but change the name to match your variable
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • IssuedOrder equal to Scout Tower
      • Then - Actions
        • -------- do whatever here --------
      • Else - Actions
 
Level 7
Joined
Jan 11, 2022
Messages
108
Am I supposed to type something in "()" at the custom script? No idea if it should look like this
  • Dummy build
    • Events
      • Unit - A unit is issued an order targeting a point
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Faceless Worker
    • Actions
      • Custom script: set udg_IssuedOrder = GetIssuedOrderId()
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IssuedOrder Equal to Skyreaper
        • Then - Actions
          • Set Tempunit = (Triggering unit)
          • Set Temppoint = (Position of (Ordered Unit))
          • Set Tempplayer = (Triggering player)
          • Unit - Order Tempunit to Stop
          • Unit - Create 1 Dummy for Tempplayer at Temppoint facing default building facing degrees
          • Set Dummy = (Last created unit)
          • Unit - Order Dummy to build a Skyreaper at Temppoint
          • Unit - Add a 0.20 second generic expiration timer to Dummy
          • Custom script: call RemoveLocation(udg_Temppoint)
        • Else - Actions
Also by mistake I've set now Temppoint to Position of Ordered Unit, gonna fix tomorrow because already have closed the editor
 
Last edited:
Level 7
Joined
Jan 11, 2022
Messages
108
Hmm then something is still not working, because the worker still starts building, nothing happens
 
Level 39
Joined
Feb 27, 2007
Messages
4,994
Debug messages are your best tool in figuring out what is running and what is not. I believe that ordering a unit to do another order in response to an event triggered by an order will not really go through (in this case the stop order). It may be necessary to delay the order with a 0.00 timeout timer or to Pause the unit, issue the order, then unpause it again. Honestly I can't remember which method is correct.
 
Level 7
Joined
Jan 11, 2022
Messages
108
I fixed it. It was my mistake that I used a dummy that couldn't build anything, wasnt a worker dummy. Anyways with this trigger (pausing and unpausing) everything works perfectly, thank you for the help!!
 
Status
Not open for further replies.
Top