scope deathpact initializer Init
globals
private constant integer SPELL = 'A00P'
private constant string EFFECT = "MDX\\NewDarkPillar.mdx"
private group caster = CreateGroup()
private sound SLEEP
endglobals
private struct data
//! runtextmacro PUI()
unit caster
unit target
unit dummy
timer t
static method create takes nothing returns data
local data d = data.allocate()
set d.caster = GetTriggerUnit()
set d.target = GetSpellTargetUnit()
set d.t = NewTimer()
set d.dummy = CreateUnit(GetOwningPlayer(d.caster),DUMMY,GetUnitX(d.target),GetUnitY(d.target),GetUnitFacing(d.target))
call UnitApplyTimedLife(d.dummy,'BTLF',3)
call PauseUnit(d.target,true)
call AddTimedEffectTarget(EFFECT,d.dummy,"origin",1)
call GroupAddUnit(caster,d.caster)
return d
endmethod
endstruct
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL
endfunction
private function Loop takes nothing returns nothing
local data d = data(GetTimerData(GetExpiredTimer()))
local unit u
local real TLife
local real TMana
local real x
local real y
loop
set u = FirstOfGroup(caster)
exitwhen u == null
set TLife = GetWidgetLife(d.target) * 0.20
set TMana = GetUnitState(d.target,UNIT_STATE_MANA) *0.20
set x = GetUnitX(d.target)
set y = GetUnitY(d.target)
call SetWidgetLife(u,GetWidgetLife(u)+ TLife)
call SetUnitState(u,UNIT_STATE_MANA,GetUnitState(u,UNIT_STATE_MANA) + TMana)
call GroupRemoveUnit(caster,u)
endloop
call ReleaseTimer(d.t)
call PauseUnit(d.target,false)
call d.destroy()
set u = null
endfunction
private function Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit t = GetSpellTargetUnit()
local data d
if GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT then
call StartSound(SLEEP)
set d = data.create()
set data[u] = d
call SetTimerData(d.t,d)
call TimerStart(d.t,3,false,function Loop)
set u = null
set t = null
elseif GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_ENDCAST then
call GroupRemoveUnit(caster,u)
set d = data[u]
call ShowUnit(d.dummy,false)
call StopEffect(1)
call RemoveUnit(d.dummy)
call d.destroy()
set u = null
endif
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_ENDCAST)
call TriggerAddAction( t, function Actions )
call TriggerAddCondition(t,Condition(function Conditions))
//set SLEEP = CreateSoundFromLabel("SleepBirth1",false,true,true,10,10)
set SLEEP = CreateSound("Internal\\Abilities\\Spells\\Undead\\SleepBirth1",false,true,true,10,10,"")
call StartSound(SLEEP)
call Preload("Internal\\Abilities\\Spells\\Undead\\SleepBirth1")
call SetSoundVolume(SLEEP,2000)
endfunction
endscope