library GetAuraBuffLevel initializer Init
//****==============================================================****//
//*** ***//
//** How to use **//
//* *//
// All you need to do to get a the level of an aura buff is calling
// my function and filling the right parameters.
// Lets assume we have a Dreadlord ingame and we want to get the
// buff level of Vampire Aure from a near ghoul.
//Parameter List:
//¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// -abil : The rawcode of the main ability which provides the buff. In
// our case this would be the rawcode of Vampire aura.
//
// -x/y : The x/y coordinates of the ghoul.
//
// -r : The range of the aura. If a unit has a buff provided by an
// aura it is indeed in range of the aura.
//
// -p : The player who is the owner of the unit which has the main
// ability. In our case that´s the Dreadlords owner.
//
// -pos/neg : You can set these values to true or false, the returned
// value depends on the combination.
// true,false = Will return the highest ability level of an
// allied unit.
// false,true = Will return the highest ability level of an
// enemy unit.
// true,true = Will return the hightst ability level of an
// allied OR enemy unit.
// false,false = Returns zero, because an aura which does
// neither affect allies nor enemys does not
// really exists and therefore it can´t be
// detected.
//Note:
//¯¯¯¯
// If there is no unit in range of the x/y coordinates who has the main
// ability the function will return zero. If there is more than one unit
// near the coordinates with the matching conditions the function will
// return the level of the highest ability.
//* *//
//** End of manual and begin of script **//
//*** ***//
//****==============================================================****//
//Do not edit here
globals
private integer TempLevel
private integer TempAbil
private boolean Negative
private boolean Positive
private player Owner
private filterfunc BuffSearchFilter
private constant group SearchGroup = CreateGroup()
endglobals
function GetAuraBuffLevel takes integer abil, real x, real y, real r, player p, boolean pos, boolean neg returns integer
if neg or pos then
set TempLevel = 0
set TempAbil = abil
set Negative = neg
set Positive = pos
set Owner = p
call GroupEnumUnitsInRange(SearchGroup,x,y,r,BuffSearchFilter)
return TempLevel
endif
return 0
endfunction
private function BuffSearch takes nothing returns boolean
local unit u = GetFilterUnit()
local integer lv = GetUnitAbilityLevel(u,TempAbil)
if lv != 0 then
if IsUnitEnemy(u,Owner) == Negative and lv > TempLevel then
set TempLevel = lv
endif
if IsUnitEnemy(u,Owner) != Positive and lv > TempLevel then
set TempLevel = lv
endif
endif
set u = null
return false
endfunction
private function Init takes nothing returns nothing
set BuffSearchFilter = Filter( function BuffSearch)
endfunction
endlibrary