- Joined
- Mar 3, 2006
- Messages
- 1,564
I need someone to check this trigger for any leak problem or some useless stuff. Its a Damage Over Time (DoT) spell,
the spell worked for me without any bugs but who knows may be somes flaws will be found.
~thanks in advance~
the spell worked for me without any bugs but who knows may be somes flaws will be found.
~thanks in advance~
JASS:
scope Immo initializer Init2
globals
Immolation filter
Immolation dmg
attacktype AT = ATTACK_TYPE_NORMAL
damagetype DT = DAMAGE_TYPE_FIRE
integer array temp_dat
integer ABIL_ID = 'A003'
integer index = 0
real DAMAGE = 0.50
real DURATION = 10.00
real INTERVAL = 0.10
real R = 300.00
string mdl = "Abilities\\Spells\\Other\\BreathOfFire\\BreathOfFireDamage.mdl"
string AttPoint = "chest"
timer interval = CreateTimer()
endglobals
struct Immolation
unit caster
location castpoint
timer duration
group targets
boolean done
integer Ntargets
integer int
effect array burning[30]
boolean array effectOnce[30]
static method Interval takes nothing returns nothing
local thistype dat = thistype.create()
local integer i = 0
loop
exitwhen i >= index
set dat = temp_dat[i]
set dmg = dat
if dat.done == false then
set dat.int = 0
call ForGroup(dat.targets, function Immolation.Damage)
endif
set i = i + 1
endloop
endmethod
static method Damage takes nothing returns nothing
local unit u = GetEnumUnit()
call UnitDamageTarget(dmg.caster,u,DAMAGE,true,false,AT,DT,null)
if dmg.effectOnce[dmg.int] == false then
set dmg.effectOnce[dmg.int] = true
set dmg.burning[dmg.int] = AddSpecialEffectTarget(mdl,u,AttPoint)
endif
set dmg.int = dmg.int + 1
endmethod
static method Duration takes nothing returns nothing
local thistype dat = thistype.create()
local integer i = 0
loop
exitwhen i >= index
set dat = temp_dat[i]
if TimerGetRemaining(dat.duration) <= 0.0 then
set index = index - 1
set temp_dat[i] = temp_dat[index]
set i = i - 1
set dat.done = true
call DestroyGroup(dat.targets)
call DestroyTimer(dat.duration)
set dat.caster = null
loop
exitwhen i >= dat.Ntargets
call DestroyEffect(dat.burning[i])
set i = i + 1
endloop
call dat.destroy()
if index == 0 then
call PauseTimer(interval)
endif
endif
set i = i + 1
endloop
endmethod
static method Setup takes unit u,location loc returns nothing
local thistype dat = thistype.create()
local real X
local real Y
local integer i = 0
set temp_dat[index] = dat
set dat.caster = u
set dat.castpoint = loc
set X = GetLocationX(loc)
set Y = GetLocationY(loc)
call RemoveLocation(dat.castpoint)
set dat.duration = CreateTimer()
set dat.targets = CreateGroup()
set dat.done = false
set dat.Ntargets = 0
set dat.int = 0
set filter = dat
call GroupEnumUnitsInRange(dat.targets,X,Y,R,Filter(function thistype.Match))
loop
exitwhen i >= dat.Ntargets
set dat.effectOnce[i] = false
set i = i + 1
endloop
call TimerStart(dat.duration, DURATION , false , function thistype.Duration )
if index == 0 then
call TimerStart(interval, INTERVAL , true , function thistype.Interval )
endif
set index = index + 1
endmethod
static method Match takes nothing returns boolean
if (IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(filter.caster))) then
set filter.Ntargets = filter.Ntargets + 1
return true
else
return false
endif
endmethod
endstruct
function t_Actions takes nothing returns nothing
//*
if (GetSpellAbilityId() == ABIL_ID) then
call Immolation.Setup(GetTriggerUnit(),GetSpellTargetLoc())
endif
//*/
/*
// MUI Testing
local integer i = 0
if (GetSpellAbilityId() == ABIL_ID) then
loop
exitwhen i >= 1
call Immolation.Setup(GetTriggerUnit(),GetSpellTargetLoc())
set i = i + 1
endloop
endif
*/
endfunction
function Init2 takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddAction( t, function t_Actions )
endfunction
endscope