globals
effect CrushStrikeSFX = null
real CrushStrikeDist = 0.00
real CrushStrikeFlyHeight = 0.00
timer CrushStrikeTimer = null
unit CrushStrikeCast = null
unit CrushStrikeTarg = null
endglobals
function CrushingStrike_Dmg takes nothing returns nothing
local real r = (10.00 * (I2R(GetUnitAbilityLevel(CrushStrikeCast, 'A00Q'))) + 40.00) + (1.20 * GetBonusAtkDmg(CrushStrikeCast))
call DestroyEffect(AddSpecialEffectTarget("MDX\\Effect_CrushingStrikeHit.mdx", CrushStrikeTarg, "chest"))
call UnitRemoveAbility(CrushStrikeCast, 'Avul')
call UnitRemoveAbility(CrushStrikeCast, 'A000')
call SetUnitFlyHeight(CrushStrikeCast, 0.00, 0.00)
call SetUnitPathing(CrushStrikeCast, true)
call DestroyEffect(CrushStrikeSFX)
if GetRandomInt(1, 100) <= GetHeroInt(CrushStrikeCast, true) then
call UnitAddAbility(CrushStrikeCast, 'A001')
if GetUnitAbilityLevel(CrushStrikeCast, 'A00K') >= 1 then
call UnitDamageTarget(CrushStrikeCast, CrushStrikeTarg, r * (2.10 + (0.30 * I2R(GetUnitAbilityLevel(CrushStrikeCast, 'A00K')))), true, false, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
else
call UnitDamageTarget(CrushStrikeCast, CrushStrikeTarg, r * 2.00, true, false, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call UnitRemoveAbility(CrushStrikeCast, 'A001')
endif
if GetUnitAbilityLevel(CrushStrikeCast, 'A016') >= 1 then
call TigersRage(CrushStrikeCast)
endif
else
set udg_AbilityPhysical = true
call UnitDamageTarget(CrushStrikeCast, CrushStrikeTarg, r, true, false, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
set udg_AbilityPhysical = false
endif
set udg_CombatActive = udg_CombatActive - 1
endfunction
function CrushingStrike_Move takes nothing returns nothing
local real castAX = GetUnitX(CrushStrikeCast)
local real castAY = GetUnitY(CrushStrikeCast)
local real targX = GetUnitX(CrushStrikeTarg)
local real targY = GetUnitY(CrushStrikeTarg)
local real targPX = PolarProjectionX(targX, 100.00, bj_RADTODEG * Atan2(castAY - targY, castAX - targX))
local real targPY = PolarProjectionY(targY, 100.00, bj_RADTODEG * Atan2(castAY - targY, castAX - targX))
local real castBX = PolarProjectionX(castAX, 18.00, bj_RADTODEG * Atan2(targPY - castAY, targPX - castAX))
local real castBY = PolarProjectionY(castAY, 18.00, bj_RADTODEG * Atan2(targPY - castAY, targPX - castAX))
local real r = 0.00
call SetUnitPosition(CrushStrikeCast, castBX, castBY)
call SetUnitFacing(CrushStrikeCast, bj_RADTODEG * Atan2(targY - castBY, targX - castBX))
set r = SquareRoot(((targPX - castAX) * (targPX - castAX)) + ((targPY - castAY) * (targPY - castAY)))
if r <= CrushStrikeDist * 0.5 then
set CrushStrikeFlyHeight = (CrushStrikeFlyHeight - 15.00)
else
set CrushStrikeFlyHeight = (CrushStrikeFlyHeight + 15.00)
endif
call SetUnitFlyHeight(CrushStrikeCast, CrushStrikeFlyHeight, 0.00)
if r <= 40.00 then
call PauseTimer(CrushStrikeTimer)
call CrushingStrike_Dmg()
endif
endfunction
function CrushingStrike_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00Q'
endfunction
function CrushingStrike_Cast takes nothing returns nothing
local real castX = 0.00
local real castY = 0.00
local real targX = 0.00
local real targY = 0.00
set udg_CombatActive = udg_CombatActive + 1
set CrushStrikeCast = GetTriggerUnit()
set CrushStrikeTarg = GetSpellTargetUnit()
set castX = GetUnitX(CrushStrikeCast)
set castY = GetUnitY(CrushStrikeCast)
set targX = GetUnitX(CrushStrikeTarg)
set targY = GetUnitY(CrushStrikeTarg)
set CrushStrikeDist = SquareRoot(((targX - castX) * (targX - castX)) + ((targY - castY) * (targY - castY)))
set CrushStrikeFlyHeight = 0.00
call UnitAddAbility(CrushStrikeCast, 'Amrf')
call UnitRemoveAbility(CrushStrikeCast, 'Amrf')
call SetUnitPathing(CrushStrikeCast, false)
set CrushStrikeSFX = AddSpecialEffectTarget("MDX\\Effect_CrushingStrike.mdx", CrushStrikeCast, "weapon")
call SetUnitAnimation(CrushStrikeCast, "attack slam")
call UnitAddAbility(CrushStrikeCast, 'Avul')
call UnitAddAbility(CrushStrikeCast, 'A000')
call TimerStart(CrushStrikeTimer, 0.03, true, function CrushingStrike_Move)
endfunction
//===========================================================================
function InitTrig_CrushingStrike takes nothing returns nothing
set gg_trg_CrushingStrike = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_CrushingStrike, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_CrushingStrike, Condition(function CrushingStrike_Conditions))
call TriggerAddAction(gg_trg_CrushingStrike, function CrushingStrike_Cast)
endfunction