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

Why does a "smart" GroupTargetOrder on a friendly unit not work?

As in the title. When I do this:
JASS:
    private function SquadTargetOrder takes nothing returns nothing
        local trigger trg = GetTriggeringTrigger()
    
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Target: " + OrderId2String(GetIssuedOrderId()))
    
        call DisableTrigger(trg) // Prevent infinite loop
        call GroupTargetOrder(UnitGetSquad(GetOrderedUnit()), OrderId2String(GetIssuedOrderId()), GetOrderTarget())
        call TriggerSleepAction(0.01)
        call EnableTrigger(trg)
    
        set trg = null
    endfunction

It works perfectly fine, except when right-clicking a friendly unit. Does anyone know why, or how to fix this?

Edit: well, "fixed" it by doing this:
JASS:
        if order == "smart" and targetUnit != null and IsPlayerAlly(GetOwningPlayer(orderedUnit), GetOwningPlayer(targetUnit)) then
            call GroupPointOrder(UnitGetSquad(orderedUnit), order, GetUnitX(targetUnit), GetUnitY(targetUnit))
        else
            call GroupTargetOrder(UnitGetSquad(orderedUnit), order, GetOrderTarget())
        endif
 
Last edited:
Top