wraithseeker
Tired.
- Reaction score
- 122
JASS:
scope Necromancy initializer Init
globals
private constant integer SPELL = 039;A00J039;
private constant integer HEROID = 039;U000039;
private integer Count = 0
private timer TIMER = CreateTimer()
private constant real TIMEOUT = 1
private group Casters = CreateGroup()
private boolexpr b
private boolexpr unitcheck
endglobals
private struct data
implement AutoData
static data temp
unit target
boolean used
timer t
method onDestroy takes nothing returns nothing
endmethod
endstruct
private function CheckUnits takes nothing returns boolean
local data d
set d = d.temp
return GetOwningPlayer(GetFilterUnit()) == GetOwningPlayer(d.target) and not IsUnitType(GetFilterUnit(),UNIT_TYPE_HERO)
endfunction
private function Check takes nothing returns boolean
return GetUnitTypeId(GetFilterUnit()) == HEROID
endfunction
private function Conditions takes nothing returns boolean
return GetLearnedSkill() == SPELL
endfunction
private function Remove takes nothing returns nothing
local data d = GetTimerData(GetExpiredTimer())
set Damage[d.target] = Damage[d.target] - 5
set MaxMana[d.target] = MaxMana[d.target] - 50
call ReleaseTimer(d.t)
call BJDebugMsg("released")
set d.used = false
endfunction
private function DoEffect takes nothing returns nothing
local unit u = GetEnumUnit()
local unit t
local data d = data<u>
local data c
set d.temp = d
call GroupEnumUnitsInRange(ENUM_GROUP,GetUnitX(u),GetUnitY(u),600,unitcheck)
loop
set t = FirstOfGroup(ENUM_GROUP)
exitwhen t == null
set c = data[t]
if c == 0 then
set c = data.create()
set c.used = false
set c.target = t
set c.t = NewTimer()
set data[t] = d
endif
if not c.used then
set c.used = true
set Damage<u> = Damage<u> + 5
set MaxMana<u> = MaxMana<u> + 50
call BJDebugMsg("adding")
call SetTimerData(c.t,d)
call TimerStart(c.t,5,false,function Remove)
endif
call GroupRemoveUnit(ENUM_GROUP,t)
endloop
set u = null
endfunction
private function Loop takes nothing returns nothing
call ForGroup(Casters,function DoEffect)
endfunction
private function Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local data d
if not IsUnitInGroup(u,Casters) then
set d = data.create()
set d.target = u
set data<u> = d
endif
if FirstOfGroup(Casters) == null then
call TimerStart(TIMER,TIMEOUT,true,function Loop)
endif
call GroupAddUnit(Casters,d.target)
set u = null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_HERO_SKILL)
call TriggerAddCondition(t,Condition(function Conditions))
call TriggerAddAction(t,function Actions )
set b = Filter(function Check)
set unitcheck = Filter(function CheckUnits)
endfunction
endscope</u></u></u></u></u></u>
JASS:
if not c.used then
set c.used = true
set Damage<u> = Damage<u> + 5
set MaxMana<u> = MaxMana<u> + 50
call BJDebugMsg("adding")
call SetTimerData(c.t,d)
call TimerStart(c.t,5,false,function Remove)
endif</u></u></u></u>
This part is running 2 times although it's supposed to run once.