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

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
JASS:
scope OrderTracking initializer Init

    private function Actions takes nothing returns nothing
        local unit u  = GetTriggerUnit()
        local integer o = GetIssuedOrderId()
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, GetUnitName(u) + ": " + I2S(o)+" -> "+OrderId2StringBJ(o))
        set u = null
    endfunction
  
    private function Init takes nothing returns nothing
        local trigger trg = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(trg, EVENT_PLAYER_UNIT_ISSUED_ORDER)
        call TriggerRegisterAnyUnitEventBJ(trg, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
        call TriggerRegisterAnyUnitEventBJ(trg, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
        call TriggerAddAction(trg, function Actions)
        set trg = null
    endfunction
  
endscope

For example 851983 should also print "attack", and 'hbar' should also print "Barracks"
Is there a function to convert the unit id into the raw-code? I only get the integer value of the unit type.
(I know you could write one, but I doubt that belongs to mission 1)
 

Attachments

  • JASS Class Mission 1.w3m
    24.6 KB · Views: 38

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
I never heard of that function. Thanks for showing it to me. It even works with upgrades.

Using GetObjectName and if it returns "Default String" using OrderId2String instead will probably have the best results.

I guess it was just written 'hbar' in the mission description instead of the integer, because it's shorter.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
JASS:
scope OrderTracking initializer Init

    private function Actions takes nothing returns nothing
        local unit u  = GetTriggerUnit()
        local integer o = GetIssuedOrderId()
        local string s = GetObjectName(o)
        if(s=="Default string") then
            set s = GetUnitName(u) + ": " + I2S(o)+" -> "+OrderId2String(o)
        else
            set s = GetUnitName(u) + ": " + I2S(o)+" -> "+s
        endif
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0,s)
        set u = null
        set s = null
    endfunction
   
    private function Init takes nothing returns nothing
        local trigger trg = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(trg, EVENT_PLAYER_UNIT_ISSUED_ORDER)
        call TriggerRegisterAnyUnitEventBJ(trg, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
        call TriggerRegisterAnyUnitEventBJ(trg, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
        call TriggerAddAction(trg, function Actions)
        set trg = null
    endfunction
   
endscope

Seems to work fine now. Even learning skills has an object name.
Some orders have no name at all though. For example using items or swapping items in the inventory.

I am kind of confused, that I seem to be unable to detect certain orders.
The orders are: placing an item on the ground and selling an item.

I moved the posts into a new thread, because I plan do track all solved missions by all users.
Thanks, I will make new threads when I submit future missions.
 

Attachments

  • JASS Class Mission 1.w3m
    24.7 KB · Views: 29
I can't test right now, but your code looks good to me. I belive you can see it as completed; if not I would post again! :)

full
 
Last edited:
Status
Not open for further replies.
Top