/*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 unit 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 destructable 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