scope SneakAttack initializer Init
globals
private constant integer SPELL = 'Bek1'
private constant integer BaseDamage = 75
private constant integer IncDamage = 75
endglobals
private struct caster
unit u
static method create takes unit casting returns caster
local caster Cas = caster.allocate()
set Cas.u = casting
return Cas
endmethod
endstruct
private function Unpause takes nothing returns nothing
local caster u = GetTimerData(GetExpiredTimer())
call PauseUnit(u.u, false)
call ReleaseTimer(GetExpiredTimer())
call u.destroy()
endfunction
private function Main takes nothing returns boolean
local caster u
if GetSpellAbilityId() == SPELL then
set u = caster.create(GetTriggerUnit())
call PauseUnit(GetTriggerUnit(), true)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl", GetTriggerUnit(), "origin"))
call SetUnitPosition(GetTriggerUnit(), GetUnitX(GetSpellTargetUnit()), GetUnitY(GetSpellTargetUnit()))
call SetUnitFacing(GetTriggerUnit(), bj_RADTODEG * Atan2(GetUnitY(GetSpellTargetUnit()) - GetUnitY(GetTriggerUnit()), GetUnitX(GetSpellTargetUnit()) - GetUnitX(GetTriggerUnit())))
call SetUnitAnimation(GetTriggerUnit(), "attack")
call UnitDamageTarget(GetTriggerUnit(), GetSpellTargetUnit(), BaseDamage + (IncDamage * GetUnitAbilityLevel(GetTriggerUnit(), SPELL)), true, false, ATTACK_TYPE_MELEE, DAMAGE_TYPE_ENHANCED, WEAPON_TYPE_METAL_LIGHT_SLICE)
call FadingText(null, I2S(BaseDamage + (IncDamage * GetUnitAbilityLevel(GetTriggerUnit(), SPELL))) + "!", 255, 20, 50, GetUnitX(GetSpellTargetUnit()), GetUnitY(GetSpellTargetUnit()), 0.04, 2, 5, 10)
if GetWidgetLife(GetSpellTargetUnit()) > 0.405 then
call IssueTargetOrder(GetTriggerUnit(), "attack", GetSpellTargetUnit())
endif
call TimerStart(NewTimerEx(u), .9, false, function Unpause)
endif
return false
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Main))
set t = null
endfunction
endscope