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

Detecting "unit ordered to build" event

Status
Not open for further replies.
Level 3
Joined
Aug 22, 2009
Messages
51
Hey, i am trying to find away to detect when ever a unit is ordered to build a building, i belive it would be under the event "Unit - A unit Is issued an order targeting a point"?
than how the order is called?

i am trying to create a system which enables to build buildings in range of a point... if some one have any suggestions they are welcome :]
 
Level 3
Joined
Aug 22, 2009
Messages
51
oh cool thx it works :], another one now i try to stop the unit from building, the result is the unit walks to build the building but as it starts it stops, i want it to stop from the beginning so it wont even walk to the direction
 
Yep, that is a bit tricky. You will need these triggers:
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Hash = (Last created hashtable)
  • Build1
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Issued order) Equal to (Order(farm))
    • Actions
      • Set Point1 = (Target point of issued order)
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at Point1 facing Default building facing degrees
      • Hashtable - Save Handle Of(Triggering unit) as (Key builder) of (Key (Last created unit)) in Hash
      • Unit - Add a 0.01 second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation (udg_Point1)
  • Build2
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Dummy
    • Actions
      • Set Builder = (Load (Key builder) of (Key (Triggering unit)) in Hash)
      • Game - Display to (Player group((Owner of Builder))) for 3.75 seconds the text: ...
      • Custom script: call IssueImmediateOrderById (udg_Builder, 0xD0008)
      • Unit - Order Builder to Stop
      • Hashtable - Clear all child hashtables of (Key(Triggering unit)) in Hash
References:
http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/hashtables-mui-133407/
http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/variables-5896/
http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/

Map Sample (you will notice that you cannot build a farm):
View attachment Disable Building.w3x

P.S. I will upload this as a system, along with more features.
P.S.2 The system is MUI.
 
Level 3
Joined
Aug 22, 2009
Messages
51
hehe you did it all for me :]. it works perfectly! exactly how i imagined it, although i never thought it would be so complex. hehe well really thx!
 
how does it work?
it creates a unit at the point where you want to build
but then it issues some secret cryptic order and then it issues a stop order
what for?
and it also is abuseable because it reveals a certain point

imho this would serve the same purpose but since I don't know how yours is working exactly I can't tell
I'm using an item with no model file so you can't pick it up and only see with drag selection
using a global item is better because every time you create a unit and remove it it will leak a little bit (leak can't be removed)

also blizzard is using this function to check if an order is a unit order it might be helpful for your system (just in case you don't know already)
JASS:
function String2OrderIdBJ takes string orderIdString returns integer
    local integer orderId
    
    // Check to see if it's a generic order.
    set orderId = OrderId(orderIdString)
    if (orderId != 0) then
        return orderId
    endif

    // Check to see if it's a (train) unit order.
    set orderId = UnitId(orderIdString)
    if (orderId != 0) then
        return orderId
    endif

    // Unrecognized - return 0
    return 0
endfunction
 

Attachments

  • Disable Building.w3x
    17 KB · Views: 41
Hah, really smart solution; never thought of that :))

Well, the visibility is not an issue; change the owner of the unit to Neutral Passive/Hostile.
By the way, your way doesn't seem to be MUI. The item can be moved once at a time. What if two/three/more units are issued the exact same order simultaneously? Where will the item move?

I tested it with shift-click/wisp-detonate-abuse and 3 workers at once so I think it works fine
however I'll make a few other tests just to make sure
edit:
even triggered spam-build-orders are blocked fine
 
Last edited:
Status
Not open for further replies.
Top