// Technically, we can choose to return nothing, but since
// the trigger is registered to a GUI variable, it's likely that
// this trigger might be referenced somewhere else, so
// have it behave normally.
function Viceclaws_OnDamage takes nothing returns boolean
local unit source = GetEventDamageSource()
local unit target = GetTriggerUnit()
local integer abilLvl = GetUnitAbilityLevel(source, 'A02H')
local real angleDiff
// You filter out the following conditions:
// If the target is a structure, mechanical, or
// if the source does not have the desired ability,
// then we terminate execution here.
if (IsUnitType(target, UNIT_TYPE_STRUCTURE) or IsUnitType(target, UNIT_TYPE_MECHANICAL) or (abilLvl == 0)) then
set source = null
set target = null
return false
endif
set angleDiff = RAbsBJ(GetUnitFacing(target) - GetUnitFacing(source))
// I added another condition that considers edge cases at quadrants 1 and 4 in the cartesian coordinate system.
// Not to worry, the effect should still be the same.
if (angleDiff <= 105.0) or (angleDiff >= 255.0) then
call DisableTrigger(GetTriggeringTrigger())
call UnitDamageTarget( source, target, ( ( 80.00 * I2R(abilLvl) + 1.00 ), true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, null)
call DestroyEffect( AddSpecialEffectTargetUnit("Objects\\Spawnmodels\\Critters\\Albatross\\CritterBloodAlbatross.mdl", target, "chest"))
call EnableTrigger(GetTriggeringTrigger())
set source = null
set target = null
return true
endif
set source = null
set target = null
return false
endfunction
//===========================================================================
function InitTrig_Viceclaws takes nothing returns nothing
set gg_trg_Viceclaws = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Viceclaws, EVENT_PLAYER_UNIT_DAMAGED )
call TriggerAddCondition( gg_trg_Viceclaws, Condition( function Viceclaws_OnDamage) )
endfunction