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

[Trigger] "Shift" Order

Status
Not open for further replies.
Level 12
Joined
Mar 23, 2008
Messages
942
How can I do the "Shift order" by trigger?
I mean, when you press shift and click to move to a target, the unit will only move to that after doing all other orders before.

Because I need to make a unit follow a path by triggers, so how can I make it so it only moves to the next point after moving to the first point?
(Cannot use waits or anything like that because its a spell)
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
I think this will help:
IssuePointOrder (unit whichUnit, string order, real x, real y)
Not sure, not tested at all. But since the other thing is issue immediate order i think this will que them.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
IssueImmediateOrder is just an order with no target.

Yes, it's Jass, but GUI isn't friendly for some things.

I never completed it, but I could always go back to polishing it.

EDIT: Here's a compiled version of the code (syntax errors fixed - forgot some .s in front of some method calls), though still untested:

JASS:
library OrderQueue initializer init
globals
    group oq_queuedUnits = CreateGroup() //to reduce lag, only check for order queues for units in this group
endglobals
struct Order
    integer orderId
    Order next = -1
    integer orderType = 0
    //0 = no target
    //1 = point target
    //2 = widget target
    real x //point target
    real y //point target
    widget w //order target
    static method create takes integer orderId, real x, real y, widget target returns Order
        local Order o = Order.allocate()
        set o.orderId = orderId
        if x != 0 or y != 0 then
            set o.orderType = 1
        elseif target != null then
            set o.orderType = 2
        endif
        set o.x = x
        set o.y = y
        set o.w = target
        return o
    endmethod
    method Issue takes unit subject returns nothing
        if .orderType == 0 then
            call IssueImmediateOrderById(subject,.orderId)
        elseif .orderType == 1 then
            call IssuePointOrderById(subject,.orderId,.x,.y)
        else
            call IssueTargetOrderById(subject,.orderId,.w)
        endif
    endmethod
endstruct

struct UnitData
    Order first = -1
    Order last = -1 //for faster allocation of new orders
    static method create takes unit attach returns UnitData
        local UnitData dat = UnitData.allocate()
        call SetUnitUserData(attach,dat)
        return dat
    endmethod
    method QueueOrder takes integer orderId, real x, real y, widget target returns nothing
        local Order o = Order.create(orderId,x,y,target)
        if .first == -1 then
            set .first = o
        else
            set .last.next = o
        endif
        set .last = o
    endmethod
    method QueueOrderStringNoTarget takes string orderString returns nothing
        call .QueueOrder(OrderId(orderString),0,0,null)
    endmethod
    method QueueOrderStringWidgetTarget takes string orderString, widget target returns nothing
        call .QueueOrder(OrderId(orderString),0,0,target)
    endmethod
    method QueueOrderStringPointTarget takes string orderString, real x, real y returns nothing
        call .QueueOrder(OrderId(orderString),x,y,null)
    endmethod
    method QueueOrderNoTarget takes integer orderId returns nothing
        call .QueueOrder(orderId,0,0,null)
    endmethod
    method QueueOrderWidgetTarget takes integer orderId, widget target returns nothing
        call .QueueOrder(orderId,0,0,target)
    endmethod
    method QueueOrderPointTarget takes integer orderId, real x, real y returns nothing
        call .QueueOrder(orderId,x,y,null)
    endmethod
endstruct

private function CheckOrders_Child takes nothing returns nothing
    local unit u = GetEnumUnit()
    local UnitData dat = GetUnitUserData(u)
    local Order o
    if GetUnitCurrentOrder(u) == 0 then //I think the null order is 0... or is it "stop"?
        set o = dat.first
        call o.Issue(u)
        set dat.first = o.next
        call o.destroy()
    endif
    set u = null
endfunction

private function CheckOrders takes nothing returns nothing
    call ForGroup(oq_queuedUnits,function CheckOrders_Child)
endfunction

private function init takes nothing returns nothing
    call TimerStart(CreateTimer(),.25,true,function CheckOrders)//change interval as you will; the higher, the less lag, the lower, the more precise.
endfunction
endlibrary

EDIT2: Tested, it works
 
Status
Not open for further replies.
Top