//Here is the main condition
function SpeedBlast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'AHtb'
endfunction
//Here is the condition that says that the level of the ability being cast is equal to 1
function SpeedBlast_Actions takes nothing returns nothing
if GetUnitAbilityLevel( GetTriggerUnit(), 'AHtb' ) == 1 then
local unit Caster = GetTriggerUnit()
local unit Target_Unit = GetSpellTargetUnit()
local real SpeedBlast_Damage = ( GetHeroAgi( Caster, true ) + ( 0.20 * GetWidgetLife(Target_Unit) ) )
local texttag Damage_Taked = CreateTextTag()
call SetTextTagText(Damage_Taked, R2S(SpeedBlast_Damage+100), .023 )
call SetTextTagPosUnit( Damage_Taked, Target_Unit, 0 )
call SetTextTagColor( Damage_Taked, 255, 0, 0, 255 )
call UnitDamageTarget(Caster, Target_Unit, SpeedBlast_Damage, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
call SetTextTagPermanent(Damage_Taked, false)
call SetTextTagVelocity( Damage_Taked, 0, .0277 )
call TriggerSleepAction(2.00)
call DestroyTextTag(Damage_Taked)
set Damage_Taked = null
set Target_Unit = null
set Caster = null
elseif GetUnitAbilityLevel( GetTriggerUnit(), 'AHtb' ) == 2 then
local unit Caster = GetTriggerUnit()
local unit Target_Unit = GetSpellTargetUnit()
local real SpeedBlast_Damage = ( GetHeroAgi( Caster, true ) + ( 0.20 * GetWidgetLife(Target_Unit) ) )
local texttag Damage_Taked = CreateTextTag()
call SetTextTagText(Damage_Taked, R2S(SpeedBlast_Damage+100), .023 )
call SetTextTagPosUnit( Damage_Taked, Target_Unit, 0 )
call SetTextTagColor( Damage_Taked, 255, 0, 0, 255 )
call UnitDamageTarget(Caster, Target_Unit, SpeedBlast_Damage, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
call SetTextTagPermanent(Damage_Taked, false)
call SetTextTagVelocity( Damage_Taked, 0, .0277 )
call TriggerSleepAction(2.00)
call DestroyTextTag(Damage_Taked)
set Damage_Taked = null
set Target_Unit = null
set Caster = null
elseif GetUnitAbilityLevel( GetTriggerUnit(), 'AHtb' ) == 3 then
local unit Caster = GetTriggerUnit()
local unit Target_Unit = GetSpellTargetUnit()
local real SpeedBlast_Damage = ( GetHeroAgi( Caster, true ) + ( 0.20 * GetWidgetLife(Target_Unit) ) )
local texttag Damage_Taked = CreateTextTag()
call SetTextTagText(Damage_Taked, R2S(SpeedBlast_Damage+100), .023 )
call SetTextTagPosUnit( Damage_Taked, Target_Unit, 0 )
call SetTextTagColor( Damage_Taked, 255, 0, 0, 255 )
call UnitDamageTarget(Caster, Target_Unit, SpeedBlast_Damage, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
call SetTextTagPermanent(Damage_Taked, false)
call SetTextTagVelocity( Damage_Taked, 0, .0277 )
call TriggerSleepAction(2.00)
call DestroyTextTag(Damage_Taked)
set Damage_Taked = null
set Target_Unit = null
set Caster = null
endif
endfunction
// the trigger stuff
function InitTrig_SpeedBlast takes nothing returns nothing
local trigger SpeedBlast = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( SpeedBlast, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(SpeedBlast, Condition(function SpeedBlast_Conditions))
call TriggerAddAction(SpeedBlast, function SpeedBlast_Actions)
endfunction