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

[Spell] SetVariable=CurrentOrder and now?

Status
Not open for further replies.
Level 16
Joined
Aug 7, 2009
Messages
1,406
All you need is a unitindexer and this:

JASS:
struct LastOrder extends array
    readonly item targetItem
    readonly unit targetUnit
    readonly destructable targetDest
    readonly real targetX
    readonly real targetY
    readonly integer orderId

    static boolean monitor=true
    
    static method operator [] takes unit u returns thistype
        return thistype(GetUnitUserData(u))
    endmethod
    private static method onOrder takes nothing returns boolean
        local thistype this=GetUnitUserData(GetOrderedUnit())

        if thistype.monitor then
            set this.targetItem=GetOrderTargetItem()
            set this.targetUnit=GetOrderTargetUnit()
            set this.targetDest=GetOrderTargetDestructable()
            set this.targetX=GetOrderPointX()
            set this.targetY=GetOrderPointX()
            set this.orderId=GetIssuedOrderId()
        endif
        return false
    endmethod
    private static trigger orderTrig=CreateTrigger()
    private static method onInit takes nothing returns nothing
        call TriggerRegisterAnyUnitEventBJ(thistype.orderTrig,EVENT_PLAYER_UNIT_ISSUED_ORDER)
        call TriggerRegisterAnyUnitEventBJ(thistype.orderTrig,EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
        call TriggerRegisterAnyUnitEventBJ(thistype.orderTrig,EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
        call TriggerAddCondition(thistype.orderTrig,Filter(function thistype.onOrder))
    endmethod

It's handwritten and I didn't test it, but this should keep track of each unit's last order. You can use this info to give them the same order again.

There are some last order snippets around though, you should definitely check them out.
 
Status
Not open for further replies.
Top