scope LifeAbsorb initializer InitTrig_LifeAbsorb
globals
private constant integer AbilID = 'A03R' //* The Spells MainAbility
private real array absorbLife[4]
endglobals
//* Extend your struct with the ChainAbility
struct LifeAbsorb extends ChainAbility
private real lifeAbsorbed=0.
integer level=0
//* Assign your own TargetFilter
//* Use ChainAbility.CurrentTarget instead of FilterUnit()
//* Use ChainAbility.CastingUnit as the Chains source unit
//* ! If this method is not declared in the Childstruct the standard filter will apply !
method targetFilter takes nothing returns boolean
return IsUnitEnemy(ChainAbility.CurrentTarget,GetOwningPlayer(ChainAbility.CastingUnit)) and not IsUnitType(ChainAbility.CurrentTarget, UNIT_TYPE_MAGIC_IMMUNE) and not IsUnitType(ChainAbility.CurrentTarget, UNIT_TYPE_STRUCTURE) and IsUnitVisible(ChainAbility.CurrentTarget,GetOwningPlayer(ChainAbility.CastingUnit)) and GetWidgetLife(ChainAbility.CurrentTarget)>0.405
endmethod
//* Assign what shall happen when a unit gets hit by a Chain
//* Use ChainAbility.CurrentTarget as the Unit that gets hit
//* Use ChainAbility.CastingUnit as the Chains source Unit
//* Use ChainAbility.CurrentHit to get the number of allready hit targets
//* ! If this method is not declared in the Childstruct nothing will happen when a unit is hit !
method onTargetHit takes nothing returns nothing
if ChainAbility.CurrentTarget==ChainAbility.CastingUnit then
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl",ChainAbility.CastingUnit,"origin"))
call SetWidgetLife(ChainAbility.CastingUnit,GetWidgetLife(ChainAbility.CastingUnit)+.lifeAbsorbed)
else
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DeathandDecay\\DeathandDecayDamage.mdl",ChainAbility.CurrentTarget,"chest"))
call UnitDamageTarget(ChainAbility.CastingUnit,ChainAbility.CurrentTarget,absorbLife[.level],true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
set .lifeAbsorbed=.lifeAbsorbed+absorbLife[.level]
endif
endmethod
//* The Life absorbed per level
static method lifeAbsorbSetup takes nothing returns nothing
set absorbLife[0]=25.
set absorbLife[1]=50.
set absorbLife[2]=75.
set absorbLife[3]=100.
endmethod
endstruct
//* The function that fires on SpellCast
private function SpellCast takes nothing returns nothing
local LifeAbsorb object
if GetSpellAbilityId()==AbilID then
//* Your Chain Setup:
//* Create the Chain with the source Unit, the target Unit and the Chains missile model path
set object=LifeAbsorb.create()
//* Change the Chains zArc to your value (makes the chain fly a parabola curve)
set object.useZArc=1.
//* Change the Chains model
set object.missileModel="Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilMissile.mdl"
//* Change the Chains Lightning model
set object.setLightningModel=DrainLife
//* Change the Chains movespeed
set object.missileSpeed=3700
//* Change the Chains detectionrange
set object.pickRange=600
//* Change the flag whether a unit gets hit more than once
set object.hitMoreThanOnce=false
//* Change the flag whether the chain shall move back to the source
set object.moveBackToSource=true
//* Change the Chains hitcount
set object.hitCount=8
//* Start the Chain
set object.level=GetUnitAbilityLevel(GetSpellAbilityUnit(),AbilID)-1
call object.Cast(GetSpellAbilityUnit(),GetSpellTargetUnit())
//* End Chain Setup
endif
endfunction
private function InitTrig_LifeAbsorb takes nothing returns nothing
local trigger t=CreateTrigger()
call LifeAbsorb.lifeAbsorbSetup()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(t,function SpellCast)
endfunction
endscope