function BackstabId takes nothing returns boolean
return GetUnitAbilityLevel(GetAttacker(),'A01L')>0
endfunction
function BackstabActions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit a = GetAttacker()
local real x1 = GetUnitX(a)
local real x2 = GetUnitX(u)
local real y1 = GetUnitY(a)
local real y2 = GetUnitY(u)
local location l2 = GetUnitLoc(u)
local location l1 = GetUnitLoc(a)
local real angle = AngleBetweenPoints(l1, l2)
//local real angle = Atan2(y2-y1, x2-x1)
local real facing = GetUnitFacing(u)
if IsUnitType(u, UNIT_TYPE_STRUCTURE) == false and RAbsBJ(ModuloReal(angle, 360) - ModuloReal(facing, 360))>90 and RAbsBJ(ModuloReal(angle, 360)-ModuloReal(facing, 360))<270 then
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl",u,"origin"))
call UnitDamageTarget(a, u, 25+15*I2R(GetUnitAbilityLevel(a,'A01L')), true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_SPIRIT_LINK, WEAPON_TYPE_WHOKNOWS)
endif
call RemoveLocation(l1)
call RemoveLocation(l2)
set u = null
set a = null
set l2 = null
set l1 = null
endfunction
//===========================================================================
function InitTrig_Backstab takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddCondition(t, Condition(function BackstabId))
call TriggerAddAction(t, function BackstabActions)
set t = null
endfunction