function PounceDistance takes integer lvl returns real
return 300. + lvl * 100.
endfunction
function PounceHeight takes integer lvl returns real
return 150. + lvl * 0
endfunction
function PounceHitDamage takes integer lvl returns real
return 40. * lvl
endfunction
function PounceSpeed takes integer lvl returns real
return 18. + 4. * lvl
endfunction
function PounceAOE takes integer lvl returns real
return 85.
endfunction
function PounceEffect takes nothing returns string
return "Abilities\\Weapons\\AvengerMissile\\AvengerMissile.mdl"
endfunction
function ParabolaZ takes real h, real d, real x returns real
return (4 * h / d) * (d - x) * (x / d)
endfunction
function RTimer takes timer t returns nothing
if t != null then
call PauseTimer(t)
set udg_Timers[udg_TimerN] = t
set udg_TimerN = udg_TimerN + 1
else
call BJDebugMsg("Tried to release a null timer")
endif
endfunction
function NTimer takes nothing returns timer
if udg_TimerN == 0 then
return CreateTimer()
endif
set udg_TimerN = udg_TimerN - 1
return udg_Timers[udg_TimerN]
endfunction
function PounceEnum takes nothing returns boolean
local unit u = GetFilterUnit()
local unit c = LoadUnitHandle(udg_PounceHash, udg_TempInt, 0)
if IsUnitEnemy(u, GetOwningPlayer(c)) and/*
*/ IsUnitType(u, UNIT_TYPE_STRUCTURE) == false and/*
*/ IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE) == false and/*
*/ GetWidgetLife(u) > 0.405 and/*
*/ IsUnitType(u, UNIT_TYPE_DEAD) == false then
return true
endif
set u = null
set c = null
return false
endfunction
function PounceLoop takes nothing returns nothing
local integer id = GetHandleId(GetExpiredTimer())
local real distx = LoadReal(udg_PounceHash, id, 6)
local real distance = LoadReal(udg_PounceHash, id, 1)
local real speed
local real aoe
local unit caster
local real cx
local real cy
local real nx
local real ny
local real height
local unit target
local real hitdmg
if distx < distance then
set caster = LoadUnitHandle(udg_PounceHash, id, 0)
set cx = GetUnitX(caster)
set cy = GetUnitY(caster)
set height = LoadReal(udg_PounceHash, id, 2)
set speed = LoadReal(udg_PounceHash, id, 4)
set aoe = LoadReal(udg_PounceHash, id, 5)
set hitdmg = LoadReal(udg_PounceHash, id, 3)
set nx = cx + speed * LoadReal(udg_PounceHash, id, 7)
set ny = cy + speed * LoadReal(udg_PounceHash, id, 8)
call SetUnitX(caster, nx)
call SetUnitY(caster, ny)
set distx = distx + speed
call SaveReal(udg_PounceHash, id, 6, distx)
call MoveLocation(udg_PounceLoc, nx, ny)
call SetUnitFlyHeight(caster, ParabolaZ(height, distance, distx) +/*
*/ GetLocationZ(udg_PounceLoc), 0.)
set udg_TempInt = id
call GroupEnumUnitsInRange(udg_EnumGroup, nx, ny, aoe, Filter(function PounceEnum))
set target = FirstOfGroup(udg_EnumGroup)
if target != null then
call UnitDamageTarget(caster, target, hitdmg, false, false, udg_Pounce_AT, udg_Pounce_DT, null)
call SetUnitOwner(udg_Pounce_Dummy, GetOwningPlayer(caster), false)
call SetUnitX(udg_Pounce_Dummy, nx)
call SetUnitY(udg_Pounce_Dummy, ny)
call SetUnitAbilityLevel(udg_Pounce_Dummy, udg_Pounce_DummyABILID, GetUnitAbilityLevel(caster, udg_Pounce_ABILID))
call IssueTargetOrder(udg_Pounce_Dummy, "acidbomb", target)
call SetUnitFlyHeight(caster, GetUnitDefaultFlyHeight(caster), 0.)
call UnitRemoveAbility(caster, 'Amrf')
call RTimer(GetExpiredTimer())
call DestroyEffect(LoadEffectHandle(udg_PounceHash, id, 9))
call PauseUnit(caster, false)
call FlushChildHashtable(udg_PounceHash, id)
endif
set caster = null
set target = null
else
set caster = LoadUnitHandle(udg_PounceHash, id, 0)
call SetUnitFlyHeight(caster, GetUnitDefaultFlyHeight(caster), 0.)
call UnitRemoveAbility(caster, 'Amrf')
call RTimer(GetExpiredTimer())
call DestroyEffect(LoadEffectHandle(udg_PounceHash, id, 9))
call PauseUnit(caster, false)
call FlushChildHashtable(udg_PounceHash, id)
set caster = null
endif
endfunction
function PounceCast takes nothing returns boolean
local timer t
local integer id
local integer lvl
local unit c
local real angle
if GetSpellAbilityId() == udg_Pounce_ABILID then
set c = GetTriggerUnit()
set t = NTimer()
set id = GetHandleId(t)
set lvl = GetUnitAbilityLevel(c, udg_Pounce_ABILID)
set angle = GetUnitFacing(c)
call SaveUnitHandle(udg_PounceHash, id, 0, c)
call SaveReal(udg_PounceHash, id, 1, PounceDistance(lvl))
call SaveReal(udg_PounceHash, id, 2, PounceHeight(lvl))
call SaveReal(udg_PounceHash, id, 3, PounceHitDamage(lvl))
call SaveReal(udg_PounceHash, id, 4, PounceSpeed(lvl))
call SaveReal(udg_PounceHash, id, 5, PounceAOE(lvl))
call SaveReal(udg_PounceHash, id, 6, 0.)
call SaveReal(udg_PounceHash, id, 7, Cos(angle * bj_DEGTORAD))
call SaveReal(udg_PounceHash, id, 8, Sin(angle * bj_DEGTORAD))
call SaveEffectHandle(udg_PounceHash, id, 9, AddSpecialEffectTarget(/*
*/PounceEffect(), c, "chest"))
call UnitAddAbility(c, 'Amrf')
call PauseUnit(c, true)
call TimerStart(t, 0.03, true, function PounceLoop)
set c = null
endif
return false
endfunction
//===========================================================================
function InitTrig_Pounce takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function PounceCast))
endfunction