JASS:
static method onCast takes nothing returns nothing
local thistype this
if effect[Spell.target.id] == null then
set effect[Spell.target.id] = AddSpecialEffectTarget(MODEL, Spell.target.unit, ATTACH)
endif
if IsUnitEnemy(Spell.target.unit, Spell.source.player) then
if offense[Spell.target.id] != 0 then
set this = offense[Spell.target.id]
else
set this = thistype.allocate()
set timer = NewTimerEx(this)
set id = Spell.target.id
set target = Spell.target.unit
set group = CreateGroup()
set defensive = false
set offense[id] = this
endif
set source = Spell.source.unit
set player = Spell.source.player
set level = Spell.level
set amount = GetBoltDamage(source, level)
set angle = GetAngle(source, level)
set aoe = GetAoE(source, level)
call TimerStart(timer, GetDuration(source, level), false, function thistype.onExpire)
else
if defense[Spell.target.id] != 0 then
set this = defense[Spell.target.id]
else
set this = thistype.allocate()
set timer = NewTimerEx(this)
set id = Spell.target.id
set target = Spell.target.unit
set group = CreateGroup()
set defensive = true
set amount = 0
set defense[id] = this
endif
set source = Spell.source.unit
set player = Spell.source.player
set level = Spell.level
set amount = amount + GetAmount(source, level)
set aoe = GetExplosionAoE(source, level)
call TimerStart(timer, GetDuration(source, level), false, function thistype.onExpire)
endif
endmethod
->
static method onCast takes nothing returns nothing
local thistype this
if effect[Spell.target.id] == null then
set effect[Spell.target.id] = AddSpecialEffectTarget(MODEL, Spell.target.unit, ATTACH)
endif
if IsUnitEnemy(Spell.target.unit, Spell.source.player) then
if offense[Spell.target.id] != 0 then
set this = offense[Spell.target.id]
else
set this = thistype.allocate()
set timer = NewTimerEx(this)
set id = Spell.target.id
set target = Spell.target.unit
set group = CreateGroup()
set defensive = false
set offense[id] = this
endif
set source = Spell.source.unit
set player = Spell.source.player
set level = Spell.level
set amount = GetBoltDamage(source, level)
set angle = GetAngle(source, level)
set aoe = GetAoE(source, level)
else
if defense[Spell.target.id] != 0 then
set this = defense[Spell.target.id]
else
set this = thistype.allocate()
set timer = NewTimerEx(this)
set id = Spell.target.id
set target = Spell.target.unit
set group = CreateGroup()
set defensive = true
set amount = 0
set defense[id] = this
endif
set source = Spell.source.unit
set player = Spell.source.player
set level = Spell.level
set amount = amount + GetAmount(source, level)
set aoe = GetExplosionAoE(source, level)
endif
call TimerStart(timer, GetDuration(source, level), false, function thistype.onExpire)
endmethod