scope DefilingTouch initializer Init
globals
public constant integer BUFF_ID = 'A047' //spell dummy
public constant integer BUFF_DE = 'A046' //spell dummy
public constant integer BUFF_SW = 'A04C' //slow
public constant integer LEARN = 'A045'
public constant string DeathEx = "Abilities\\Spells\\Undead\\RaiseSkeletonWarrior\\RaiseSkeleton.mdx"
public constant string ExpEx = "Objects\\Spawnmodels\\Orc\\OrcSmallDeathExplode\\OrcSmallDeathExplode.mdx"
endglobals
private function f takes nothing returns boolean
local unit c = GetEventDamageSource() //caster
local unit t = GetTriggerUnit() //target
local unit cor
if IsUnitEnemy(c, GetOwningPlayer(t)) == true/*
*/ and Damage_IsPhysical()/*
*/ and not ( IsUnitType(t, UNIT_TYPE_STRUCTURE)) == true /*
*/ and Damage_IsAttack()/*
*/ and GetUnitAbilityLevel(c, BUFF_ID) > 0 then
set TempInt = GetUnitAbilityLevel(c, LEARN)
call UnitRemoveAbility(c, BUFF_ID)
call UnitAddAbility(c, BUFF_DE)
call SetUnitAbilityLevel(c, BUFF_DE, TempInt)
call CreateDummy(c, BUFF_SW, TempInt, "slow", t)
set cor = CreateCorpse(Player(PLAYER_NEUTRAL_AGGRESSIVE), Minion_P1Melee, GetUnitX(t), GetUnitY(t), GetRandomReal(0, 360))
call SetUnitBlendTime(cor, 0)
call SetUnitAnimation(cor, "decay bone")
call GroupAddUnit(bj_suspendDecayBoneGroup, cor)
call DestroyEffect(AddSpecialEffect(ExpEx, GetUnitX(t), GetUnitY(t)))
set TempReal = I2R(10 + (20 * TempInt))
call Damage_Spell(c, t, TempReal)
endif
set c = null
set t = null
return false
endfunction
private function Init takes nothing returns nothing
local trigger t2 = CreateTrigger()
call TriggerAddCondition(t2, Condition(function f))
call Damage_RegisterEvent(t2)
endfunction
endscope
//*******************************************************************************************
scope DefilingTouchLearn initializer Init
private struct cache
unit caster
group g
endstruct
private function cond takes nothing returns boolean
return GetLearnedSkill() == DefilingTouch_LEARN and IsUnitIllusion(GetTriggerUnit()) == false and GetUnitAbilityLevel(GetTriggerUnit(), GetLearnedSkill()) == 1
endfunction
private function Loop takes nothing returns nothing
local cache data = GetTimerData(GetExpiredTimer())
local unit e = null
if GetUnitState(data.caster, UNIT_STATE_LIFE) <= 0. then
return
endif
if GetUnitAbilityLevel(data.caster, DefilingTouch_BUFF_ID) > 0 then
return
endif
set TempX = GetUnitX(data.caster)
set TempY = GetUnitY(data.caster)
//call GroupRefresh(data.g)
call GroupClear(data.g)
call GroupUnitsInArea(data.g, TempX, TempY, 100.)
loop
set e = FirstOfGroup(data.g)
exitwhen null == e
call GroupRemoveUnit(data.g, e)
if GetUnitAbilityLevel(data.caster, DefilingTouch_BUFF_DE) > 0 and GetUnitState(e, UNIT_STATE_LIFE) <= 0. and IsUnitType(e, UNIT_TYPE_HERO) != true and IsUnitType(e, UNIT_TYPE_STRUCTURE) != true and IsUnitType(e, ConvertUnitType(20)) != true then
call UnitRemoveAbility(data.caster, DefilingTouch_BUFF_DE)
call UnitAddAbility(data.caster, DefilingTouch_BUFF_ID)
call SetUnitAbilityLevel(data.caster, DefilingTouch_BUFF_ID, GetUnitAbilityLevel(data.caster, DefilingTouch_LEARN))
call RemoveUnit(e)
call DestroyEffect(AddSpecialEffect(DefilingTouch_DeathEx, GetUnitX(e), GetUnitY(e)))
//call GroupRefresh(data.g)
call GroupClear(data.g)
set e = null
return
endif
endloop
call GroupClear(data.g)
set e = null
endfunction
private function f takes nothing returns nothing
local cache data = cache.create()
local unit u = GetTriggerUnit()
local timer t = NewTimer()
set data.g = CreateGroup()//NewGroup()
set data.caster = u
call SetTimerData(t, data)
call TimerStart(t, 0.35, true, function Loop )
call UnitAddAbility(u, DefilingTouch_BUFF_ID)
call SetUnitAbilityLevel(u, DefilingTouch_BUFF_ID, GetUnitAbilityLevel(u, DefilingTouch_LEARN))
set t = null
set u = null
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call AddEvent(t, EVENT_PLAYER_HERO_SKILL)
call TriggerAddCondition(t, Condition( function cond) )
call TriggerAddAction(t, function f)
endfunction
endscope