HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

OrderDebug

10-05-2008, 03:16 PM#1
DioD
This library used to display information about issued orders.
It have no options and use no "external" functions.

Formed string display as:

Code:
Unit Name[Handle]Order Type(String)[ID]Target Name[Handle]
                                       Location X---Y
                                       Nothing

Collapse JASS:
library OrderDebug initializer INIT
//v3
globals

    private integer TYPE_WHOKNOWS = 0
    
    private integer TYPE_NOTHING  = 1
    private integer TYPE_LOCATION = 2
    private integer TYPE_WIDGET   = 3
    
    private integer TYPE_UNIT         = 4
    private integer TYPE_ITEM         = 5
    private integer TYPE_DESTRUCTABLE = 6

    private string array FLAG_DATA
    
    private trigger TRIGGER = null
    private integer ERRORID = 0

endglobals

function ERROR takes string String returns string
    set ERRORID = ERRORID + 1
    return "|cFFFF0000ERROR " + I2S(ERRORID) + ": " + String + "|r"
endfunction

private function Echo takes string String returns nothing
    call DisplayTimedTextToPlayer(GetLocalPlayer(),0.0,0.0,12.0,String)
endfunction

private function Echo_DOL1 takes integer Integer returns nothing
    call Echo(FLAG_DATA[Integer])
endfunction

private function OrderType2String takes integer Integer returns string
    if Integer >= 0 and Integer <= 7 then
        return FLAG_DATA[Integer]
    endif
    return FLAG_DATA[7]
endfunction

private function H2I takes handle Handle returns integer
    return Handle
    return 0
endfunction

private function MAIN takes nothing returns nothing
    local integer RETURN = 0
    local integer EVENT = H2I(GetTriggerEventId())
    
    local integer ID    = GetIssuedOrderId()
    local string  NAME  = OrderId2String(ID)
    local string  UNIT  = UnitId2String(ID)
    local string  GENN  = GetObjectName(ID)
    local string WIDGET = ""
    local string  ARG0  = ""
    local string  ARG1  = ""
    
    if NAME != null then
        set ARG0 = "(" + NAME + ")" + "[" + I2S(ID) + "]"
    elseif UNIT != null then
        set ARG0 = "(" + UNIT + ")" + "[" + I2S(ID) + "]"
    elseif GENN != GetObjectName(0) then
        set ARG0 = "(" + GENN + ")" + "[" + I2S(ID) + "]"
    else
        set ARG0 = "{" + I2S(ID) + "}"
    endif
    
    if EVENT > 37 and EVENT < 41 then
        set RETURN = EVENT - 37
        if GetOrderTargetUnit() != null then
            set RETURN = 4
            set WIDGET = "  " + GetUnitName(GetOrderTargetUnit()) + "[" + I2S(H2I(GetOrderTargetUnit())) + "]"
        elseif  GetOrderTargetItem() != null then
            set RETURN = 5
            set WIDGET = "  " + GetItemName(GetOrderTargetItem()) + "[" + I2S(H2I(GetOrderTargetItem())) + "]"
        elseif  GetOrderTargetDestructable() != null then
            set RETURN = 6
            set WIDGET = "  " + GetDestructableName(GetOrderTargetDestructable()) + "[" + I2S(H2I(GetOrderTargetDestructable())) + "]"
        endif
    endif
    
    if RETURN == 1 then
        set ARG1 = "  Nothing"
    elseif RETURN == 2 then
        set ARG1 = "  X:" + R2S(GetOrderPointX()) + "---" + "Y:" + R2S(GetOrderPointY())
    else
        set ARG1 = WIDGET
    endif
    
    call Echo(GetUnitName(GetTriggerUnit())+"["+I2S(H2I(GetTriggerUnit()))+"]"+OrderType2String(RETURN)+ARG0+ARG1)
endfunction

private function INIT takes nothing returns nothing

    set FLAG_DATA[0] = ERROR("NULL DATA")
    set FLAG_DATA[7] = ERROR("OUT OF RANGE")
    
    set FLAG_DATA[1] = "Target Nothing"
    set FLAG_DATA[2] = "Target Location"
    set FLAG_DATA[3] = "Target Widget"
    
    set FLAG_DATA[4] = "Target Unit"
    set FLAG_DATA[5] = "Target Item"
    set FLAG_DATA[6] = "Target Destructable"
    
    set TRIGGER = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( TRIGGER, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
    call TriggerRegisterAnyUnitEventBJ( TRIGGER, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
    call TriggerRegisterAnyUnitEventBJ( TRIGGER, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerAddAction(TRIGGER,function MAIN)
    
endfunction

endlibrary
10-11-2008, 09:45 PM#2
Vexorian
Ok.

Though I am not sure if people will prevent this over their own lower quality order debug stuff.

Some things are missing, like train, upgrade and learn orders, they could show the rawcode, that would be useful sometimes.
11-05-2008, 12:27 PM#3
azwraith_ftL
Cool, can be used for an -afk system like DotA's one. Though adding the other stuff like Vex said could be nice too.
01-05-2009, 07:57 PM#4
Troll-Brain
You should make the difference between an order with no target and a one with a target location, and then display the X/Y of the TargetLoc.
01-06-2009, 03:37 AM#5
DioD
Ok.

I will improve debug function as soon as possible.
01-07-2009, 09:16 PM#6
Troll-Brain
Oh and also if AGR2 != null you should display it.
Actually i need it, i can edit the code ofc, but i mean someone else could also need it too.
01-08-2009, 04:33 AM#7
DioD
Currently i working on "Order type detection".

Every of 7 possible types will have its own output string with as much data as possible.
01-08-2009, 03:34 PM#8
Troll-Brain
Quote:
Originally Posted by DioD
Currently i working on "Order type detection".

Every of 7 possible types will have its own output string with as much data as possible.

You don't get it, ARG2 is never displayed even if it isn't null, so in case of a train order we get only the id of the trained unit type, but not the string order.
01-08-2009, 05:17 PM#9
DioD
With GetObjectName() i can detect normal orders and "object related orders".

Such orders will show object name and possibly its type.

Object type is hard to detect but this looks possible.
01-08-2009, 05:35 PM#10
Troll-Brain
You still don't get it :p

Ok more explanations :

UnitId2String (unitid) returns a string which can be used with the function GroupEnumUnitsOfType.

It returns the English default name of the unit if it is not a custom id, if it is a custom it returns "custom_<id>"

For example : UnitId2String('h000') will return "custom_h000" and UnitId2String('hpea') == "peasant"

And you never display it.

Oh wait, we get an easy way to convert an unitid in is string "equivalent" , for custom id only ofc.

It should be useful for debugging purpose, since this function returns null if the unitid doesn't exist.
01-09-2009, 04:09 PM#11
DioD
Just w8 some time, soon it will be done.
01-11-2009, 08:59 AM#12
DioD
Fixed and updated.
01-11-2009, 01:15 PM#13
Troll-Brain
You should add more spaces and colour the strings.

EDIT : and you display two times the X of the target point but not the Y.
01-24-2009, 07:53 PM#14
Troll-Brain
you forgot the "private" attributes
11-01-2009, 02:56 PM#15
Troll-Brain
Update it for 1.24.
GetHandleId instead of the return bug.