This is very experimental code. With that said, I don't think it's dangerous.
JASS:
/*snippet by SanKakU*/
library DebugXYF uses optional MSGS
//A FAST WAY TO FIND ALL THE SPELLS YOU ARE DEBUGGING IS TO MAKE THE
//PRIVATE CONSTANT BOOLEAN DebugMode=false
//Save your map, then you should get errors. you will be directed to the
//triggers that are using these functions.
globals
private constant boolean DebugMode=true
endglobals
/*PLEASE NOTE: IF YOU COPY THE BELOW SCOPE GiveOrderStringForUnitType
FROM THIS LIBRARY, YOU CAN MAKE YOUR OWN.
IF YOU LOSE TRACK OF IT, JUST CHANGE THE ABOVE BOOLEAN TO false AND SAVE YOUR MAP.
YOU SHOULD BE TAKEN RIGHT TO WHERE IT IS.*/
static if DebugMode then
/*FUNCTION LIST
_______________
give order string
display x/y of item for 300 seconds
display x/y of unit for 300 seconds
display x/y of destructable for 300 seconds
display facing angle of unit for 300 seconds
display facing angle and x/y of unit for 300 seconds
display x/y of item for 5 seconds
display x/y of unit for 5 seconds
display x/y of destructable for 5 seconds
display facing angle of unit for 5 seconds
display facing angle and x/y of unit for 5 seconds
check rect/region of item
check rect/region of unit
check rect/region of destructable
check x/y of item (is it within bounds/is it within the rect)
check x/y of unit (is it within bounds/is it within the rect)
check x/y of destructable (is it within bounds/is it within the rect)
________________________________________________________________________
function gos takes string order, integer orderid returns nothing
function dxyi takes item x returns nothing
function dxyu takes unit x returns nothing
function dxyd takes destructable x returns nothing
function dfu takes unit x returns nothing
function dfxyu takes unit x returns nothing
function dxyis takes item x returns nothing
function dxyus takes unit x returns nothing
function dxyds takes destructable x returns nothing
function dfus takes unit x returns nothing
function dfxyus takes unit x returns nothing
function cri takes item x, rect y returns boolean
function cru takes unit x, rect y returns boolean
function crd takes destructable x, rect y returns boolean
function cxyi takes item x, real x1, real y1, real x2, real y2 returns boolean
function cxyu takes unit x, real x1, real y1, real x2, real y2 returns boolean
function cxyd takes destructable x, real x1, real y1, real x2, real y2 returns boolean
______________________
END OF FUNCTION LIST*/
/*OPTIONAL SECTION
________________*/
static if LIBRARY_MSGS then
else
function msgall5 takes string s returns nothing
local integer i = 0
loop
call DisplayTimedTextToPlayer(Player(i),0,0,5,s)
set i = i + 1
exitwhen i > 11
endloop
endfunction
function msgall300 takes string s returns nothing
local integer i = 0
loop
call DisplayTimedTextToPlayer(Player(i),0,0,300,s)
set i = i + 1
exitwhen i > 11
endloop
endfunction
endif
/*END OF OPTIONAL SECTION
_______________________*/
function gos takes string order, integer orderid returns nothing
call msgall5(order)
call msgall5(I2S(orderid))
endfunction
//you might want to export the following example
//make another trigger, called GiveOrderStringForUnitType and copy this scope to there
//don't forget to take off the /* and */ characters to remove it's status as a comment
/*scope GiveOrderStringForUnitType initializer I
//to debug dummy units or possibly your heroes, change the
//private constant integer UNITID=YourDummyOrHeroUnitId
globals
private constant integer UNITID='uloc'
endglobals
private function f takes nothing returns boolean
if GetUnitTypeId(GetOrderedUnit())==UNITID then
call msgall5("target order:")
call gos(OrderId2String(GetIssuedOrderId()),GetIssuedOrderId())
return false
else
return false
endif
endfunction
private function g takes nothing returns boolean
if GetUnitTypeId(GetOrderedUnit())==UNITID then
call msgall5("point order:")
call gos(OrderId2String(GetIssuedOrderId()),GetIssuedOrderId())
return false
else
return false
endif
endfunction
private function h takes nothing returns boolean
if GetUnitTypeId(GetOrderedUnit())==UNITID then
call msgall5("order:")
call gos(OrderId2String(GetIssuedOrderId()),GetIssuedOrderId())
return false
else
return false
endif
endfunction
private function I takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerAddCondition( t,Condition( function f))
set t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerAddCondition( t,Condition( function g))
set t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerAddCondition( t,Condition( function h))
endfunction
endscope*/
//this is where all the display xy stuff is at
//this displays the exact x and y coordinates
//of an item
function dxyi takes item x returns nothing
call msgall300(R2S(GetItemX(x))+","+R2S(GetItemY(x)))
endfunction
//of a unit
function dxyu takes unit x returns nothing
call msgall300(R2S(GetUnitX(x))+","+R2S(GetUnitY(x)))
endfunction
//of a destructable
function dxyd takes destructable x returns nothing
call msgall300(R2S(GetDestructableX(x))+","+R2S(GetDestructableY(x)))
endfunction
//displays the facing angle of a unit
function dfu takes unit x returns nothing
call msgall300(R2S(GetUnitFacing(x)))
endfunction
//displays both the x and y coordinates of a unit and the facing angle
function dfxyu takes unit x returns nothing
call msgall300(R2S(GetUnitX(x))+","+R2S(GetUnitY(x))+","+R2S(GetUnitFacing(x)))
endfunction
//end of standard verification functions
//the above functions are available for spell debugging also, 5 second messages instead of
//the mass collection style of 300 seconds
function dxyis takes item x returns nothing
call msgall5(R2S(GetItemX(x))+","+R2S(GetItemY(x)))
endfunction
function dxyus takes unit x returns nothing
call msgall5(R2S(GetUnitX(x))+","+R2S(GetUnitY(x)))
endfunction
function dxyds takes destructable x returns nothing
call msgall5(R2S(GetDestructableX(x))+","+R2S(GetDestructableY(x)))
endfunction
function dfus takes unit x returns nothing
call msgall5(R2S(GetUnitFacing(x)))
endfunction
function dfxyus takes unit x returns nothing
call msgall5(R2S(GetUnitX(x))+","+R2S(GetUnitY(x))+","+R2S(GetUnitFacing(x)))
endfunction
endif
/*Snippet Extension by SanKakU*/
//example:
/*
make a timer run every 1 second of game time.
then make it check
if cru(somespecialunit,somespecialregion) then
...do your thing.
or better yet...
a unit drops an item...(using GT)
if cri(GetManipulatedItem(),thestash) then
probably pull up some more conditions and make a recipe, or something like that.
it could also be used to remove items that are cluttering up the map if there are lots
of creeps and item drops on your map.
for example...
a unit drops an item...(using GT)
run a timer for 2 minutes, then check
if cri(GetManipulatedItem(),thebattlefield) then
remove the item.
these are just a few ideas off the top of my head.
*/
//use this function to check if an item is in a box/rect/region
function cxyi takes item x, real x1, real y1, real x2, real y2 returns boolean
if GetItemX(x) > x1 and GetItemX(x) < x2 and GetItemY(x) > y1 and GetItemY(x) < y2 then
return true
endif
return false
endfunction
//this one is same as above, but for a unit
function cxyu takes unit x, real x1, real y1, real x2, real y2 returns boolean
if GetUnitX(x) > x1 and GetUnitX(x) < x2 and GetUnitY(x) > y1 and GetUnitY(x) < y2 then
return true
endif
return false
endfunction
//this one is same as above, but for a destructable
function cxyd takes destructable x, real x1, real y1, real x2, real y2 returns boolean
if GetDestructableX(x) > x1 and GetDestructableX(x) < x2 and GetDestructableY(x) > y1 and GetDestructableY(x) < y2 then
return true
endif
return false
endfunction
//use this function to check if an item is in a box/rect/region
//you only give the item and the rect (region), no xyxy like the above functions
function cri takes item x, rect y returns boolean
if GetItemX(x) > GetRectMinX(y) and GetItemX(x) < GetRectMaxX(y) and GetItemY(x) > GetRectMinY(y) and GetItemY(x) < GetRectMaxY(y) then
return true
endif
return false
endfunction
//use this function to check if a unit is in a box/rect/region
//you only give the item and the rect, no xyxy like the above functions
function cru takes unit x, rect y returns boolean
if GetUnitX(x) > GetRectMinX(y) and GetUnitX(x) < GetRectMaxX(y) and GetUnitY(x) > GetRectMinY(y) and GetUnitY(x) < GetRectMaxY(y) then
return true
endif
return false
endfunction
//use this function to check if a destructable is in a box/rect/region
//you only give the item and the rect, no xyxy like the above functions
function crd takes destructable x, rect y returns boolean
if GetDestructableX(x) > GetRectMinX(y) and GetDestructableX(x) < GetRectMaxX(y) and GetDestructableY(x) > GetRectMinY(y) and GetDestructableY(x) < GetRectMaxY(y) then
return true
endif
return false
endfunction
endlibrary