JASS:
function P_ValidTarget takes unit t returns boolean
if IsUnitEnemy(t, GetOwningPlayer(GetSpellAbilityUnit())) == true then
return true
endif
if GetOwningPlayer(t) == Player(PLAYER_NEUTRAL_AGGRESSIVE) then
return true
elseif GetOwningPlayer(t) == Player(bj_PLAYER_NEUTRAL_VICTIM) then
return true
elseif GetOwningPlayer(t) == Player(bj_PLAYER_NEUTRAL_EXTRA) then
return true
elseif GetOwningPlayer(t) == Player(PLAYER_NEUTRAL_PASSIVE) then
return true
endif
return false
endfunction
function P_Actions takes nothing returns nothing
local unit target = GetSpellTargetUnit()
local unit u
local unit FrostCaster
local unit BloodCaster
local player p = GetOwningPlayer(GetSpellAbilityUnit())
local boolean HasFrost = (GetUnitAbilityLevel(target, 'B003') > 0)
local boolean HasBlood = (GetUnitAbilityLevel(target, 'B005') > 0)
local group g = CreateGroup()
call GroupEnumUnitsInRangeOfLoc(g, GetUnitLoc(target), 150.0, null)
if HasFrost or HasBlood then
loop
set u = FirstOfGroup(g)
exitwhen u == null
if P_ValidTarget(u) then
if HasFrost then
set FrostCaster = CreateUnitAtLoc(p, 'n002', GetUnitLoc(u), 270.0)
call ShowUnit(FrostCaster, false)
call IssueTargetOrder(FrostCaster, "frostnova", u)
call UnitApplyTimedLife(FrostCaster, 'BTLF', 3.0)
endif
if HasBlood then
set BloodCaster = CreateUnitAtLoc(p, 'n002', GetUnitLoc(u), 270.0)
call ShowUnit(BloodCaster, false)
call IssueTargetOrder(BloodCaster, "acidbomb", u)
call UnitApplyTimedLife(BloodCaster, 'BTLF', 3.0)
endif
endif
call GroupRemoveUnit(g, u)
endloop
endif
endfunction
function P_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00L'
endfunction
//===========================================================================
function InitTrig_Pestilence takes nothing returns nothing
local trigger P = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( P, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( P, Condition(function P_Conditions) )
call TriggerAddAction( P, function P_Actions )
set P = null
endfunction
I'm trying to emulate the Pestilence ability of Death Knight from WoW. 'B003' is Frost Fever buff, 'B005' is Blood Plague buff - those two we need to spread in a 150 AoE of the target of the spell.
'A00L' is the ability Pestilence, and 'n002' is a dummy caster unit that has 0 cost 0 cooldown abilities that will place the buffs needed.
Now for some reason, the expiration timer applies to the caster of Pestilence, not to the dummy. What am I doing wrong?