globals
constant integer DUMMY_ID = 039;h000039; //dummy unit's code
constant integer UNIT_TARGET_SPELL = 039;A000039; //spell code for an ability that can only target units
constant string ORDER_STRING = "channel" //UNIT_TARGET_SPELL's order string
endglobals
function IsWidgetUnit takes widget whichWidget returns boolean
local unit dummy = CreateUnit(Player(12), DUMMY_ID, GetWidgetX(whichWidget), GetWidgetY(whichWidget), 0)
local boolean result
call UnitAddAbility(dummy, UNIT_TARGET_SPELL)
set result = IssueTargetOrder(dummy, ORDER_STRING, whichWidget)
call KillUnit(dummy)
set dummy = null
return result
endfunction
library WidgetType
globals
constant integer WIDGET_NULL = 0
constant integer WIDGET_UNIT = 1
constant integer WIDGET_DESTRUCTABLE = 2
constant integer WIDGET_ITEM = 3
endglobals
public function W2U takes widget w returns unit
return w
return null
endfunction
public function W2D takes widget w returns destructable
return w
return null
endfunction
public function W2I takes widget w returns item
return w
return null
endfunction
function GetWidgetType takes widget w returns integer
if w == null then
return WIDGET_NULL
endif
if GetUnitTypeId(W2U(w)) != 0 then
return WIDGET_UNIT
endif
if GetDestructableTypeId(W2D(w)) != 0 then
return WIDGET_DESTRUCTABLE
endif
if GetItemTypeId(W2I(w)) != 0 then
return WIDGET_ITEM
endif
return WIDGET_NULL
endfunction
endlibrary