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

Order Tracking - Submission

Status
Not open for further replies.
JASS:
function UnitOrder takes nothing returns nothing
   local integer orderId = GetIssuedOrderId()
   local string orderString = OrderId2String(orderId)
   local string targetName
   // Is Their a Target?
   if ( GetOrderTarget() != null ) then
       //Get Targets Name according to its type.
       if (GetOrderTargetUnit() != null) then
           set targetName = GetUnitName(GetOrderTargetUnit())
       else
           if GetOrderTargetItem() != null then
               set targetName = GetItemName(GetOrderTargetItem())
           else
               if ( GetOrderTargetDestructable() != null) then
                   set targetName = GetDestructableName(GetOrderTargetDestructable())
               endif
           endif
       endif
   endif
   // If no Order-String Avaible try to get Objects-Name
   if  orderString == null then
           set orderString = GetObjectName(orderId)
           // Replace Default string with " "
           if orderString == "Default string" then
               set orderString = " "
           endif
   endif
   // Print "-> targetName" ?
   if ( GetOrderTarget() != null ) then
       call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0, 8.00,  GetUnitName(GetTriggerUnit()) +  " - " +  orderString +" / "+ I2S(orderId) +  " -> " + targetName )
   else   
       call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0, 8.00,  GetUnitName(GetTriggerUnit()) +  " - " +  orderString +" / "+ I2S(orderId) )
   endif
endfunction

//===========================================================================
function InitTrig_UnitOrder takes nothing returns nothing
   local trigger tr = CreateTrigger(  )
   call TriggerRegisterAnyUnitEventBJ( tr, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
   call TriggerRegisterAnyUnitEventBJ( tr, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
   call TriggerRegisterAnyUnitEventBJ( tr, EVENT_PLAYER_UNIT_ISSUED_ORDER )
   call TriggerAddAction( tr, function UnitOrder )
   set tr = null
endfunction
Mission 1 - Print Orders.
I wonder if their is a getWidgetsID, would simplefy my first if else block.
Couldn't find one in the jass api.
 

Attachments

  • Jass Class 1 - Order.w3x
    19.7 KB · Views: 44
Good one. Keep it!

full
 
Status
Not open for further replies.
Top