Weyrling
New Member
- Reaction score
- 25
I'm making a series of useful JASS scripts for me to call to save time, I wrote these after staying awake for many hours, so I'd appreciate somebody looking over them.
1) Determines how many enemies there are within X range
2) Sets inputted unit's flying height to match an actual Z.
1) Determines how many enemies there are within X range
JASS:
function CountGroup takes nothing returns nothing
set udg_Integer = udg_Integer+1
endfunction
function IsEnemyOf takes nothing returns boolean
return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true)
endfunction
function CheckforEnemies takes unit u, real dist returns integer
local location l = GetUnitLoc(u)
local group g = GetUnitsInRangeOfLocMatching(dist,l,Condition(function IsEnemyOf))
call ForGroup(g,function CountGroup)
return udg_Integer
endfunction
2) Sets inputted unit's flying height to match an actual Z.
JASS:
function SetUnitZ takes unit u, real z returns nothing
local location l = GetUnitLoc(u)
local real lz = GetLocationZ(l)
call SetUnitFlyHeight(u,z-lz,99999)
call RemoveLocation(l)
endfunction