- Joined
- Oct 3, 2008
- Messages
- 367
This is a fine debugging tool that simply prints order data. It will print the order ID in hex if it's a normal order, in ASCII if it's a rawcode. It also displays the type of order, the unit that was issued the order, and the name of the order (if any). Optionally, it can also display data on the target of an order if DISPLAY_TARGET_INFO is flipped to true.
It's excellent for finding order ID's, especially since it's much quicker to copy down the hex equivalents. Also used to create the wildly popular gg AutocastOrderEvent.
Requires ASCII.
It's excellent for finding order ID's, especially since it's much quicker to copy down the hex equivalents. Also used to create the wildly popular gg AutocastOrderEvent.
Requires ASCII.
JASS:
library PrintOrders initializer Init requires Ascii
static if DEBUG_MODE then
//Config
globals
private constant boolean CLEAR_BEFORE_PRINTING = false
//Setting this to true will clear the screen of text messages when printing order data.
private constant string ACTIVATE = "-printon"
//Typing this in-game will activate PrintOrder (it is activated by default).
private constant string DEACTIVATE = "-printoff"
//Typing this in-game will deactivate PrintOrder.
private constant boolean DISPLAY_TARGET_INFO = false
//When flipped to true, the system will display information on targets of orders.
endglobals
//End config
globals
private string array Hex_Values
private trigger t1 = CreateTrigger()
private trigger t2 = CreateTrigger()
private trigger t3 = CreateTrigger()
private constant integer OFFSET = 0xD0000
endglobals
private function Int2HexString takes integer i returns string
local string hex = ""
local integer r = 0
local string neg = ""
if (i<0) then
set neg = "-"
set i = -i
endif
loop
set r = i - (i / 16) * 16
set i = i/16
set hex = Hex_Values[r] + hex
exitwhen (i==0)
endloop
return neg+hex
endfunction
private function Rawcode2String takes integer i returns string
local string c = ""
loop
exitwhen i == 0
set c = Ascii2Char(i - (i / 256) * 256)+c
set i = i / 256
endloop
return c
endfunction
private function Target takes nothing returns boolean
local integer order = GetIssuedOrderId()
local string s
static if DISPLAY_TARGET_INFO then
local string n
endif
if order - OFFSET < 8191 then
set s = "0x" + Int2HexString(order)
else
set s = "'" + Rawcode2String(order) + "'"
endif
static if CLEAR_BEFORE_PRINTING then
call ClearTextMessages()
endif
static if DISPLAY_TARGET_INFO then
if GetOrderTargetUnit() != null then
set n = GetUnitName(GetOrderTargetUnit())
elseif GetOrderTargetDestructable() != null then
set n = GetDestructableName(GetOrderTargetDestructable())
else
set n = GetItemName(GetOrderTargetItem())
endif
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, GetUnitName(GetTriggerUnit()) +/*
*/" issued target object order.\n OrderId: " + s + "\n order name: " +/*
*/OrderId2String(order) + "\n\nTarget name: " + n + "\nTarget handle id: " + /*
*/I2S(GetHandleId(GetOrderTarget())) + "\n\n")
else
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, GetUnitName(GetTriggerUnit()) +/*
*/" issued target object order.\n OrderId: " + s + "\n order name: " +/*
*/OrderId2String(order) + "\n\n")
endif
return false
endfunction
private function Point takes nothing returns boolean
local integer order = GetIssuedOrderId()
local string s
if order - OFFSET < 8191 then
set s = "0x" + Int2HexString(order)
else
set s = "'" + Rawcode2String(order) + "'"
endif
static if CLEAR_BEFORE_PRINTING then
call ClearTextMessages()
endif
static if DISPLAY_TARGET_INFO then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, GetUnitName(GetTriggerUnit()) +/*
*/" issued target point order at (" + R2S(GetOrderPointX()) + "," + R2S(GetOrderPointY()) + ")"/*
*/ + ".\n OrderId: " + s + "\n order name: " +/*
*/OrderId2String(order) + "\n\n")
else
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, GetUnitName(GetTriggerUnit()) +/*
*/" issued target point order.\n OrderId: " + s + "\n order name: " +/*
*/OrderId2String(order) + "\n\n")
endif
return false
endfunction
private function Order takes nothing returns boolean
local integer order = GetIssuedOrderId()
local string s
if order - OFFSET < 8191 then
set s = "0x" + Int2HexString(order)
else
set s = "'" + Rawcode2String(order) + "'"
endif
static if CLEAR_BEFORE_PRINTING then
call ClearTextMessages()
endif
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, GetUnitName(GetTriggerUnit()) +/*
*/" issued order with no target.\n OrderId: " + s + "\n order name: " +/*
*/OrderId2String(order) + "\n\n")
return false
endfunction
private function Activate takes nothing returns boolean
call EnableTrigger(t1)
call EnableTrigger(t2)
call EnableTrigger(t3)
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "PrintOrder activated.")
return false
endfunction
private function Deactivate takes nothing returns boolean
call DisableTrigger(t1)
call DisableTrigger(t2)
call DisableTrigger(t3)
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "PrintOrder deactivated.")
return false
endfunction
private function Init takes nothing returns nothing
local integer i = 15
local trigger t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, GetLocalPlayer(), ACTIVATE, true)
call TriggerAddCondition(t, Condition(function Activate))
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, GetLocalPlayer(), DEACTIVATE, true)
call TriggerAddCondition(t, Condition(function Deactivate))
loop
call TriggerRegisterPlayerUnitEvent(t1, Player(i), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null)
call TriggerRegisterPlayerUnitEvent(t2, Player(i), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null)
call TriggerRegisterPlayerUnitEvent(t3, Player(i), EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
exitwhen i == 0
set i = i - 1
endloop
call TriggerAddCondition(t1, Filter(function Target))
call TriggerAddCondition(t2, Filter(function Point))
call TriggerAddCondition(t3, Filter(function Order))
set Hex_Values[0] = "0"
set Hex_Values[1] = "1"
set Hex_Values[2] = "2"
set Hex_Values[3] = "3"
set Hex_Values[4] = "4"
set Hex_Values[5] = "5"
set Hex_Values[6] = "6"
set Hex_Values[7] = "7"
set Hex_Values[8] = "8"
set Hex_Values[9] = "9"
set Hex_Values[10] = "A"
set Hex_Values[11] = "B"
set Hex_Values[12] = "C"
set Hex_Values[13] = "D"
set Hex_Values[14] = "E"
set Hex_Values[15] = "F"
endfunction
endif
endlibrary
Last edited: