Snippet IsIssuedOrderInterrupting

Troll-Brain

You can change this now in User CP.
Reaction score
85
I have the need to know if an issued order can interrupt the current order of an unit or not (like for example "defend" order doesn't interrupt current orders), i've found this solution.
Maybe it's not obvious for all, so i post this snippet.

But you should simply inline GetIssuedOrderId() == GetUnitCurrentOrder(GetOrderedUnit()), with an order event.
So, i dunno if it should go on graveyard or not, hmm maybe a "sample" ?

Also, as usual, i suppose the name of the library is lame, any better suggestion ?
JASS:
library IsIssuedOrderInterrupting

globals
    private constant boolean SAFE_CHECK = true
endglobals

globals
    private constant eventid EVD0 = EVENT_UNIT_ISSUED_ORDER
    private constant eventid EVD1 = EVENT_UNIT_ISSUED_POINT_ORDER
    private constant eventid EVD2 = EVENT_UNIT_ISSUED_TARGET_ORDER
    private constant eventid EVD3 = EVENT_PLAYER_UNIT_ISSUED_ORDER
    private constant eventid EVD4 = EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER
    private constant eventid EVD5 = EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER
    private constant eventid EVD6 = EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER // deprecated
endglobals

function IsIssuedOrderInterrupting takes nothing returns boolean
    static if SAFE_CHECK then
    
        local eventid evd = GetTriggerEventId()
        
        if evd==EVD0 or evd==EVD1 or evd==EVD2 or evd==EVD3 or evd==EVD4 or evd==EVD5 or evd==EVD6 then
            return GetIssuedOrderId() == GetUnitCurrentOrder(GetOrderedUnit())
        else
            debug call BJDebugMsg("IsIssuedOrderInterrupting : use this function with an order event only")
            return false
        endif
        
    else
    
        return GetIssuedOrderId() == GetUnitCurrentOrder(GetOrderedUnit())
    endif
    
endfunction

endlibrary


Note : Obviously it will fail inside a TriggerRegister boolexpr, since it's not GetOrderedUnit(), but GetFilterUnit().
Also, it could just not work like that inside a such boolexpr, i don't care, i won't use them anyway.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
To keep the track of possible workers (which peons have currently a build order).
I will post the code next week if you want to see a practical use.
I suppose it has other uses but to be honest that's the first time i need it.

EDIT :

To clarify a bit :

When an unit receive a not interrupting order, the previous order is not stopped, the unit keeps it, but the previous order doesn't fire order events one more time.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top