Rheias
New Helper (I got over 2000 posts)
- Reaction score
- 232
Just a few simple function to help you do things faster - I'll keep this updated since every function that I will write and find useful I'll add here.
RF_IsEven - If an integer is even it will return true, else return false. 0 is considered odd (false).
RF_R2I - Converts a real to integer, however unlike the regular conversion, it won't be rounded down, but rounded to the closet integer (e.g. 3.1 = 3, 3.7 = 4). X.5 = X.
RF_Destination - Assuming the unit will keep walking in the same direction this will return the location it will reach after "wait" number of seconds.
Very little so far, but I hope soon enough more functions will be added, anyway, have fun with it.
JASS:
// if SubString(l-1,l) is just annoying
function RF_IsEven takes integer subject returns boolean
local integer check = subject / 2
local integer test = check * 2
if test < subject or subject < 2 then
return false
endif
return true
endfunction
function RF_R2I takes real subject returns integer
local real check = subject - .5
local integer test = R2I(subject)
if test >= check then
return test
endif
return test + 1
endfunction
// Too bad we can't return two reals
function RF_Destination takes unit subject, real wait returns location
local real facing = GetUnitFacing(subject)
local real speed = GetUnitMoveSpeed(subject)
local real distance = wait * speed
local location current = GetUnitLoc(subject)
local location returned = PolarProjectionBJ(current,distance,facing)
// Leakz
call RemoveLocation(current)
set current = null
return returned
endfunction
//Forced by WE - Not relevant
function InitTrig_RFunctions takes nothing returns nothing
endfunction
RF_IsEven - If an integer is even it will return true, else return false. 0 is considered odd (false).
RF_R2I - Converts a real to integer, however unlike the regular conversion, it won't be rounded down, but rounded to the closet integer (e.g. 3.1 = 3, 3.7 = 4). X.5 = X.
RF_Destination - Assuming the unit will keep walking in the same direction this will return the location it will reach after "wait" number of seconds.
Very little so far, but I hope soon enough more functions will be added, anyway, have fun with it.