scope BlinkStrike
globals
private real Damage
private real Interval
private integer NumberOfHits
//! -------------- SETUP STARTS --------------
// Should trigger Preload spell in initialization
private constant boolean preload = false
// Spell Raw Code in object Editor
private constant integer SpellId = 'A009'
// Attack sound label
private constant string soundlabel = "MetalHeavySliceMetal"
// Bloodeffect model path
private constant string bloodeffect = "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl"
// Blink Target model path
private constant string blinktarget = "Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl"
// Blink Caster model path
private constant string blinkcaster = "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl"
endglobals
private function Setup takes integer ability_level,integer hero_level, integer str,integer agi,integer int returns nothing
// Damage done per attack
set Damage = 50.0 + ability_level*20.0 + 0*hero_level + str*0 + agi*0 + int*0
// TimeDelay between attacks
set Interval = 0.15 + ability_level*0 +0*hero_level + str*0 + agi*0 + int*0
// How many times caster will attack target
set NumberOfHits = 5 + ability_level*2 +0*hero_level + str*0 + agi*0 + int*0
endfunction
// ability_level = Ability Level of the Spell
// hero_level = Level of Casting Hero
// str = Strenght of Casting Hero
// agi = Agility of Casting Hero
// int = Intelligence of Casting Hero
//! ---------- SETUP ENDS -------------
private struct BlinkStrikeTimer
unit caster
unit target
integer count
real damage
real startx
real starty
endstruct
function Blink_Strike_TimerFunc takes nothing returns nothing
local timer t = GetExpiredTimer()
local BlinkStrikeTimer tags = GetCSData(t)
local real dir = Atan2(GetUnitY(tags.target)-tags.starty,GetUnitX(tags.target)-tags.startx)
local sound snd = null
set tags.count = tags.count -1
if tags.count <= 0 or GetUnitState(tags.target, UNIT_STATE_LIFE) <= 0.405 then
call DestroyEffect(AddSpecialEffect(blinkcaster,GetUnitX(tags.caster),GetUnitY(tags.caster)))
call SetUnitX(tags.caster,tags.startx)
call SetUnitY(tags.caster,tags.starty)
call SetUnitTimeScale(tags.caster,1)
call PauseUnit(tags.caster,false)
call IssueImmediateOrder(tags.caster,"stop")
call UnitRemoveAbility(tags.caster,'Avul')
call SetUnitAnimation(tags.caster,"stand")
call DestroyEffect(AddSpecialEffect(blinktarget,GetUnitX(tags.caster),GetUnitY(tags.caster)))
call tags.destroy()
call DestroyTimer(t)
return
endif
set snd = CreateSoundFromLabel(soundlabel,false,true,true,0,0)
call SetSoundPosition(snd,GetUnitX(tags.target),GetUnitY(tags.target),50)
call StartSound(snd)
call KillSoundWhenDone(snd)
set snd = null
call SetUnitX(tags.caster,GetUnitX(tags.target)-Cos(dir)*100)
call SetUnitY(tags.caster,GetUnitY(tags.target)-Sin(dir)*100)
call SetUnitFacingTimed(tags.caster,bj_RADTODEG*dir+GetRandomReal(-90,90),0)
call SetUnitAnimation(tags.caster,"attack")
call UnitDamageTarget(tags.caster,tags.target,tags.damage,true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNKNOWN,WEAPON_TYPE_WHOKNOWS)
call DestroyEffect(AddSpecialEffectTarget(bloodeffect,tags.target,"origin"))
set t = null
endfunction
private function SpellCast takes nothing returns nothing
local unit caster = GetTriggerUnit()
local BlinkStrikeTimer sets = BlinkStrikeTimer.create()
local timer t = CreateTimer()
local integer level = GetUnitAbilityLevel(caster,GetSpellAbilityId())
local integer hlevel = GetHeroLevel(caster)
local integer agi = GetHeroAgi(caster,true)
local integer int = GetHeroInt(caster,true)
local integer str = GetHeroStr(caster,true)
local real dir
local sound snd = CreateSoundFromLabel(soundlabel,false,true,true,0,0)
call Setup(level,hlevel,str,agi,int)
call UnitAddAbility(caster,'Avul')
call DestroyEffect(AddSpecialEffect(blinkcaster,GetUnitX(caster),GetUnitY(caster)))
call SetUnitTimeScale(caster,3)
set sets.target = GetSpellTargetUnit()
set sets.damage = Damage
set sets.caster = caster
set sets.count = NumberOfHits
set sets.startx = GetUnitX(caster)
set sets.starty = GetUnitY(caster)
call SetCSData(t,sets)
call TimerStart(t,Interval,true,function Blink_Strike_TimerFunc)
call PauseUnit(caster,true)
call SetSoundPosition(snd,GetUnitX(sets.target),GetUnitY(sets.target),50)
call StartSound(snd)
call KillSoundWhenDone(snd)
set snd = null
set dir = Atan2(GetUnitY(sets.target)-sets.starty,GetUnitX(sets.target)-sets.startx)
call SetUnitX(sets.caster,GetUnitX(sets.target)-Cos(dir)*100)
call SetUnitY(sets.caster,GetUnitY(sets.target)-Sin(dir)*100)
call SetUnitFacingTimed(sets.caster,bj_RADTODEG*dir+GetRandomReal(-90,90),0)
call SetUnitAnimation(sets.caster,"attack")
call UnitDamageTarget(sets.caster,sets.target,sets.damage,true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNKNOWN,WEAPON_TYPE_WHOKNOWS)
call DestroyEffect(AddSpecialEffectTarget(bloodeffect,sets.target,"origin"))
call DestroyEffect(AddSpecialEffect(blinktarget,GetUnitX(caster),GetUnitY(caster)))
set t = null
set caster = null
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SpellId
endfunction
//===========================================================================
function InitTrig_Blink_Strike takes nothing returns nothing
local trigger spell = CreateTrigger()
local integer i = 0
local sound snd
loop
exitwhen i == 16
call TriggerRegisterPlayerUnitEvent(spell,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
set i = i+1
endloop
call TriggerAddAction(spell,function SpellCast)
call TriggerAddCondition(spell,Filter(function Conditions))
if preload then
call Preload(blinkcaster)
call Preload(blinktarget)
call Preload(bloodeffect)
set snd = CreateSoundFromLabel(soundlabel,false,true,true,0,0)
call StartSound(snd)
call KillSoundWhenDone(snd)
endif
set spell = null
set snd = null
endfunction
endscope