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

Universal - Order Tracking

Status
Not open for further replies.

NEL

NEL

Level 6
Joined
Mar 6, 2017
Messages
113
Part 1

Create a trigger that should detect any order a unit does, and print the unit's name and the issued order id on screen.

Part 2

Now it should also print the order's equivalent string or the name of issued object id being ordered (in same line). For example 851983 should also print "attack", and 'hbar' should also print "Barracks", so the user can easily see which order is behind the id.

vJASS:
//! zinc
library OrderTracking {
    private function onInit() {
        trigger trgOrder = CreateTrigger();
        integer Index = 0;
           
        while( Index < bj_MAX_PLAYERS ) {
            TriggerRegisterPlayerUnitEvent( trgOrder, Player( Index ), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null );
            TriggerRegisterPlayerUnitEvent( trgOrder, Player( Index ), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null );
            TriggerRegisterPlayerUnitEvent( trgOrder, Player( Index ), EVENT_PLAYER_UNIT_ISSUED_ORDER, null );
               
            Index = Index + 1;
        }
           
        TriggerAddAction( trgOrder, function(){
            unit u = GetOrderedUnit();
            integer orderId = GetIssuedOrderId();
           
            ClearTextMessages();
            DisplayTextToPlayer( GetLocalPlayer(), 0, 0, 
                "Unit Name: " + I2S( GetUnitTypeId( u ) ) + " | " + GetUnitName( u ) + "\n" +
                "OrderID: " + I2S( orderId ) + " | " + OrderId2String( orderId )
            );
               
            u = null;
        });
           
        trgOrder = null;
    }
}
//! endzinc
 

Attachments

  • [Missions] Universal - Order Tracking.w3x
    24.7 KB · Views: 80
Status
Not open for further replies.
Top