library AuraOfDeath initializer init requires TimerUtils
globals
private constant integer S_ID = 'A000' // Spell Id (rawcode)
private constant integer D_ID = 'dum0' // the dummy in the object editor
private constant attacktype A = ATTACK_TYPE_NORMAL
private constant damagetype D = DAMAGE_TYPE_NORMAL
private constant weapontype W = WEAPON_TYPE_WHOKNOWS
private constant real D_TIME = 1. // Every D_TIME the spell deals damage
private constant real C_TIME = 3. // The spell need C_TIME channle tiem
private constant string D_SFX = "Abilities\\Spells\\Undead\\CarrionSwarm\\CarrionSwarmDamage.mdl" // An aditional effect
private constant real SFX_AMOUNT = 18. // Aditional effect amount
private constant boolean SFX_BOOLEAN = true // show the aditional effect?
private constant boolean DUM_BOOLEAN = true // show the dummy from the object editor?
// Don't change the constants below
private constant real L_TIME = 0.04
private constant group G = CreateGroup()
endglobals
private function damage takes integer level returns real
return 250. + 75. * level
endfunction
private function area takes integer level returns real
return 300.
endfunction
private function duration takes integer level returns real
return 4. + 1. * level
endfunction
// Configuration ends here \\
private struct AuraOfDeath
static thistype TEMP
unit caster = null
unit dummy = null
real x = 0.
real y = 0.
real c = 0. //Counter
real d = 0.
real a = 0.
real t = 0. // timer
real dur = 0.
boolean b = true
private static method filter takes nothing returns boolean
local thistype this = TEMP
local unit u = GetFilterUnit()
if GetWidgetLife(u) > 0.405 and IsUnitEnemy(u,GetOwningPlayer(.caster)) and IsUnitType(u,UNIT_TYPE_STRUCTURE) == false and IsUnitType(u,UNIT_TYPE_MAGIC_IMMUNE) == false then
call UnitDamageTarget(.caster,u,.d,true,false,A,D,W)
endif
return false
endmethod
private static method Loop takes nothing returns nothing
local timer t = GetExpiredTimer()
local thistype this = GetTimerData(t)
local integer i = 0
local real x
local real y
if DUM_BOOLEAN == true then
call SetUnitX(.dummy,GetUnitX(.caster))
call SetUnitY(.dummy,GetUnitY(.caster))
endif
if .b == true then
set .c = .c + L_TIME
if .c >= C_TIME then
set .b = false
set .c = 0.
call SetUnitX(.caster,.x)
call SetUnitY(.caster,.y)
call PauseUnit(.caster,false)
if DUM_BOOLEAN == true then
set .dummy = CreateUnit(GetOwningPlayer(.caster),D_ID,GetUnitX(.caster),GetUnitY(.caster),0.)
endif
set TEMP = this
call GroupEnumUnitsInRange(G,GetUnitX(.caster),GetUnitY(.caster),.a,Condition(function AuraOfDeath.filter))
if SFX_BOOLEAN == true then
loop
exitwhen i == SFX_AMOUNT
set x = GetUnitX(.caster) + .a / 3 * Cos(360 / SFX_AMOUNT * i * bj_DEGTORAD)
set y = GetUnitY(.caster) + .a / 3 * Sin(360 / SFX_AMOUNT * i * bj_DEGTORAD)
call DestroyEffect(AddSpecialEffect(D_SFX,x,y))
set i = i + 1
endloop
set i = 0
loop
exitwhen i == SFX_AMOUNT
set x = GetUnitX(.caster) + .a / 2 * Cos(360 / SFX_AMOUNT * i * bj_DEGTORAD)
set y = GetUnitY(.caster) + .a / 2 * Sin(360 / SFX_AMOUNT * i * bj_DEGTORAD)
call DestroyEffect(AddSpecialEffect(D_SFX,x,y))
set i = i + 1
endloop
endif
endif
elseif .b == false then
set .c = .c + L_TIME
set .t = .t + L_TIME
if .c >= D_TIME then
set .c = 0.
if SFX_BOOLEAN == true then
loop
exitwhen i == SFX_AMOUNT
set x = GetUnitX(.caster) + .a / 3 * Cos(360 / SFX_AMOUNT * i * bj_DEGTORAD)
set y = GetUnitY(.caster) + .a / 3 * Sin(360 / SFX_AMOUNT * i * bj_DEGTORAD)
call DestroyEffect(AddSpecialEffect(D_SFX,x,y))
set i = i + 1
endloop
set i = 0
loop
exitwhen i == SFX_AMOUNT
set x = GetUnitX(.caster) + .a / 2 * Cos(360 / SFX_AMOUNT * i * bj_DEGTORAD)
set y = GetUnitY(.caster) + .a / 2 * Sin(360 / SFX_AMOUNT * i * bj_DEGTORAD)
call DestroyEffect(AddSpecialEffect(D_SFX,x,y))
set i = i + 1
endloop
endif
set TEMP = this
call GroupEnumUnitsInRange(G,GetUnitX(.caster),GetUnitY(.caster),.a,Condition(function AuraOfDeath.filter))
endif
if .t >= .dur then
call RemoveUnit(.dummy)
call .destroy()
call ReleaseTimer(t)
endif
endif
set t = null
endmethod
static method create takes unit caster, real x, real y returns thistype
local thistype this = .allocate()
local timer t = NewTimer()
local integer i = 0
set .caster = caster
set .x = GetSpellTargetX()
set .y = GetSpellTargetY()
set .d = damage(GetUnitAbilityLevel(.caster,S_ID))
set .dur = duration(GetUnitAbilityLevel(.caster,S_ID))
set .a = area(GetUnitAbilityLevel(.caster,S_ID))
call PauseUnit(.caster,true)
call SetTimerData(t,this)
call TimerStart(t,L_TIME,true,function AuraOfDeath.Loop)
set t = null
return this
endmethod
endstruct
private function cast takes nothing returns boolean
if GetSpellAbilityId() == S_ID then
call AuraOfDeath.create(GetTriggerUnit(),GetSpellTargetX(),GetSpellTargetY())
endif
return false
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i == 16
call TriggerRegisterPlayerUnitEvent(t,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
set i = i + 1
endloop
call TriggerAddCondition(t,Condition(function cast))
call Preload(D_SFX)
set t = null
endfunction
endlibrary