The Undaddy
Creating with the power of rage
- Reaction score
- 55
Well,not really something someone can't do himself/herself,but here are some functions I find very useful.
1.function AbsAngle takes real angle returns real
Sometimes,when calculating angles,you may get the angle of -138 or maybe 456,which sometimes messes up my calculations.And so this function returns the angle in range [0,360).The other thing I have noticed about angles is,that when you get a unit's facing angle (or was it angle between points?) you get the angle like [-180,180).So anyways,here it is:
2.function AngleBetweenCoords takes real locAx,real locAy,real locBx,real locBy returns real
Basically blizzard's AngleBetweenPoints,but uses coordinates,as not to force you to create variables for some single thing to prevent leaks.
3.function DistanceBetweenCoords takes real locAx,real locAy,real locBx,real locBy returns real
Same as above
4.function GetReflectAngle takes unit target,unit projectile returns real
Well,some people might want one unit to bounce off another,so this here is the thing - returns the new angle of movement for the bouncing off unit.The function is defined for 2 units,and if the projectile (or the unit that will bounce off) is moving towards its facing angle.
This will not make anything bounce off something that is randomly shaped,works correctly if the unit it bounces against is circular or has a circular shield around itself.
If someone wants it predefined so it uses something else instead of units,just post.
Uses some of the functions above
5.function SetAnyUnitHeight takes unit u,real z,real rate returns nothing
Why add crow form yourself and save a function call?Let me do it for you .
Sets the flying height of any unit.
6.function GetUnitZ takes unit u returns real
Returns the Z of a unit.
7.function SetUnitZ takes unit u,real z returns nothing
Sets the Z position of a unit.This is absolute from the (sea?) level (Z = 0).
Check out the --u17ra 1337 h4xx0rz t3s7 m4p-- below.
Method fails if cliff height > z
1.function AbsAngle takes real angle returns real
Sometimes,when calculating angles,you may get the angle of -138 or maybe 456,which sometimes messes up my calculations.And so this function returns the angle in range [0,360).The other thing I have noticed about angles is,that when you get a unit's facing angle (or was it angle between points?) you get the angle like [-180,180).So anyways,here it is:
JASS:
2.function AngleBetweenCoords takes real locAx,real locAy,real locBx,real locBy returns real
Basically blizzard's AngleBetweenPoints,but uses coordinates,as not to force you to create variables for some single thing to prevent leaks.
JASS:
3.function DistanceBetweenCoords takes real locAx,real locAy,real locBx,real locBy returns real
Same as above
JASS:
4.function GetReflectAngle takes unit target,unit projectile returns real
Well,some people might want one unit to bounce off another,so this here is the thing - returns the new angle of movement for the bouncing off unit.The function is defined for 2 units,and if the projectile (or the unit that will bounce off) is moving towards its facing angle.
This will not make anything bounce off something that is randomly shaped,works correctly if the unit it bounces against is circular or has a circular shield around itself.
JASS:
function GetReflectAngle takes unit target,unit projectile returns real
local real alpha = AbsAngle(GetUnitFacing(projectile))
local real beta = AbsAngle(AngleBetweenCoords(GetUnitX(projectile),GetUnitY(projectile),GetUnitX(target),GetUnitY(target)))
local real x = AbsAngle(alpha - beta)
local real y = AbsAngle(90 - x)
local real gamma = alpha + 2*y
return gamma
endfunction
If someone wants it predefined so it uses something else instead of units,just post.
Uses some of the functions above
5.function SetAnyUnitHeight takes unit u,real z,real rate returns nothing
Why add crow form yourself and save a function call?Let me do it for you .
Sets the flying height of any unit.
JASS:
function SetAnyUnitHeight takes unit u,real z,real rate returns nothing
call UnitAddAbility(u,039;Amrf039;)
call UnitRemoveAbility(u,039;Amrf039;)
call SetUnitFlyHeight(u,z,rate)
endfunction
6.function GetUnitZ takes unit u returns real
Returns the Z of a unit.
JASS:
function GetUnitZ takes unit u returns real
local location l = GetUnitLoc(u)
local real z = GetLocationZ(l)
if u != null then
call RemoveLocation(l)
set l = null
return z + GetUnitFlyHeight(u)
endif
set l = null
return 0.
endfunction
7.function SetUnitZ takes unit u,real z returns nothing
Sets the Z position of a unit.This is absolute from the (sea?) level (Z = 0).
Check out the --u17ra 1337 h4xx0rz t3s7 m4p-- below.
JASS:
function SetUnitZ takes unit u,real z returns nothing
local location l = GetUnitLoc(u)
if u != null then
call UnitAddAbility(u,039;Amrf039;)
call UnitRemoveAbility(u,039;Amrf039;)
call SetUnitFlyHeight(u,z - GetLocationZ(l),0)
call RemoveLocation(l)
endif
set l = null
endfunction
Method fails if cliff height > z