Moderator
M
Moderator
15:02, 1st Jul 2013
PurgeandFire: Changes made. Approved!
PurgeandFire: Changes made. Approved!
|
//*************************************************************************************
//*
//* World Bounds Functions by Almia
//*
//*************************************************************************************
//*
//* API
//*
//* function IsXInMap takes real x returns boolean
//* function IsYInMap takes real y returns boolean
//* function IsPointInMap takes real x, real y returns boolean
//* - Checks if coordinates is in map.
//*
//* function BoundX takes real x returns real
//* function BoundY takes real y returns real
//* - Bounds the value of coordinate to min/max values if they are greater/less than min/max values.
//*
//* function SetUnitBoundedX takes unit u, real x returns nothing
//* function SetUnitBoundedY takes unit u, real y returns nothing
//* - Moves unit in a bounded coordinate
//*
//*************************************************************************************
function IsXInMap takes real x returns boolean
return x >= udg_WB_MinX and x < udg_WB_MaxX
endfunction
function IsYInMap takes real y returns boolean
return y >= udg_WB_MinY and y < udg_WB_MaxY
endfunction
function IsPointInMap takes real x, real y returns boolean
return IsXInMap(x) and IsYInMap(y)
endfunction
function BoundX takes real x returns real
if udg_WB_MinX > x then
return udg_WB_MinX
elseif udg_WB_MaxX < x then
return udg_WB_MaxX
endif
return x
endfunction
function BoundY takes real y returns real
if udg_WB_MinY > y then
return udg_WB_MinY
elseif udg_WB_MaxY < y then
return udg_WB_MaxY
endif
return y
endfunction
function SetUnitBoundedX takes unit u, real x returns nothing
call SetUnitX(u, BoundX(x))
endfunction
function SetUnitBoundedY takes unit u, real y returns nothing
call SetUnitY(u, BoundY(y))
endfunction