Files
Dota-Zombie-Invasion/scripts/vscripts/abilities/heroes/luna/ability_luna_eclipse_custom.lua
T
2026-05-29 15:11:31 +07:00

183 lines
6.8 KiB
Lua

local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
local __TS__Decorate = ____lualib.__TS__Decorate
local ____exports = {}
local ____dota_ts_adapter = require("lib.dota_ts_adapter")
local BaseAbility = ____dota_ts_adapter.BaseAbility
local BaseModifier = ____dota_ts_adapter.BaseModifier
local registerAbility = ____dota_ts_adapter.registerAbility
local registerModifier = ____dota_ts_adapter.registerModifier
local ____luna_lucent_beam_shared = require("abilities.heroes.luna.luna_lucent_beam_shared")
local applyLucentBeamHit = ____luna_lucent_beam_shared.applyLucentBeamHit
local getLunaLucentBeamAbility = ____luna_lucent_beam_shared.getLunaLucentBeamAbility
____exports.ability_luna_eclipse_custom = __TS__Class()
local ability_luna_eclipse_custom = ____exports.ability_luna_eclipse_custom
ability_luna_eclipse_custom.name = "ability_luna_eclipse_custom"
ability_luna_eclipse_custom.____file_path = "scripts/vscripts/abilities/heroes/luna/ability_luna_eclipse_custom.lua"
__TS__ClassExtends(ability_luna_eclipse_custom, BaseAbility)
function ability_luna_eclipse_custom.prototype.Precache(self, context)
PrecacheResource("particle", "particles/units/heroes/hero_luna/luna_eclipse.vpcf", context)
PrecacheResource("particle", "particles/units/heroes/hero_luna/luna_lucent_beam.vpcf", context)
end
function ability_luna_eclipse_custom.prototype.GetBehavior(self)
return DOTA_ABILITY_BEHAVIOR_NO_TARGET
end
function ability_luna_eclipse_custom.prototype.OnUpgrade(self)
if not IsServer() then
return
end
local caster = self:GetCaster()
local lucentBeam = getLunaLucentBeamAbility(nil, caster)
if not lucentBeam or lucentBeam:GetLevel() > 0 then
return
end
if self:GetLevel() > 0 then
self:SetLevel(0)
if caster:IsRealHero() then
local heroCaster = caster
heroCaster:SetAbilityPoints(heroCaster:GetAbilityPoints() + 1)
end
end
end
function ability_luna_eclipse_custom.prototype.OnSpellStart(self)
if not IsServer() then
return
end
local caster = self:GetCaster()
local duration = self:GetSpecialValueFor("eclipse_duration")
local radius = self:GetSpecialValueFor("eclipse_radius")
local eclipsePfx = ParticleManager:CreateParticle("particles/units/heroes/hero_luna/luna_eclipse.vpcf", PATTACH_ABSORIGIN_FOLLOW, caster)
ParticleManager:SetParticleControl(
eclipsePfx,
0,
caster:GetAbsOrigin()
)
ParticleManager:SetParticleControl(
eclipsePfx,
1,
Vector(radius, 0, 0)
)
Timers:CreateTimer(
duration + 0.5,
function()
ParticleManager:DestroyParticle(eclipsePfx, false)
ParticleManager:ReleaseParticleIndex(eclipsePfx)
return nil
end
)
caster:AddNewModifier(caster, self, ____exports.modifier_luna_eclipse_active.name, {duration = duration})
EmitSoundOn("Hero_Luna.Eclipse", caster)
end
ability_luna_eclipse_custom = __TS__Decorate(
ability_luna_eclipse_custom,
ability_luna_eclipse_custom,
{registerAbility(nil)},
{kind = "class", name = "ability_luna_eclipse_custom"}
)
____exports.ability_luna_eclipse_custom = ability_luna_eclipse_custom
____exports.modifier_luna_eclipse_active = __TS__Class()
local modifier_luna_eclipse_active = ____exports.modifier_luna_eclipse_active
modifier_luna_eclipse_active.name = "modifier_luna_eclipse_active"
modifier_luna_eclipse_active.____file_path = "scripts/vscripts/abilities/heroes/luna/ability_luna_eclipse_custom.lua"
__TS__ClassExtends(modifier_luna_eclipse_active, BaseModifier)
function modifier_luna_eclipse_active.prototype.____constructor(self, ...)
BaseModifier.prototype.____constructor(self, ...)
self.beamsDone = 0
end
function modifier_luna_eclipse_active.prototype.IsHidden(self)
return false
end
function modifier_luna_eclipse_active.prototype.IsPurgable(self)
return false
end
function modifier_luna_eclipse_active.prototype.GetAttributes(self)
return MODIFIER_ATTRIBUTE_MULTIPLE
end
function modifier_luna_eclipse_active.prototype.OnCreated(self)
if not IsServer() then
return
end
local interval = self:GetAbility():GetSpecialValueFor("beam_interval")
self:StartIntervalThink(interval)
self:OnIntervalThink()
end
function modifier_luna_eclipse_active.prototype.OnIntervalThink(self)
if not IsServer() then
return
end
local ability = self:GetAbility()
local parent = self:GetParent()
if not ability or not parent then
self:Destroy()
return
end
local facetWaves = parent:HasScepter() and math.floor(ability:GetSpecialValueFor("eclipse_facet_wave_count")) or 0
local maxBeams = facetWaves > 0 and facetWaves or math.floor(ability:GetSpecialValueFor("eclipse_beam_count"))
if self.beamsDone >= maxBeams then
self:Destroy()
return
end
local radius = ability:GetSpecialValueFor("eclipse_radius")
local lucentBeam = getLunaLucentBeamAbility(nil, parent)
local hasLeveledLucentBeam = not not lucentBeam and lucentBeam:GetLevel() > 0
local damage = hasLeveledLucentBeam and lucentBeam:GetSpecialValueFor("lucent_beam_damage") or 0
local stun = hasLeveledLucentBeam and lucentBeam:GetSpecialValueFor("stun_duration") or 0
local enemies = FindUnitsInRadius(
parent:GetTeamNumber(),
parent:GetAbsOrigin(),
nil,
radius,
DOTA_UNIT_TARGET_TEAM_ENEMY,
DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BASIC,
DOTA_UNIT_TARGET_FLAG_NONE,
FIND_ANY_ORDER,
false
)
if #enemies == 0 then
self.beamsDone = self.beamsDone + 1
return
end
if facetWaves > 0 then
for ____, victim in ipairs(enemies) do
do
if not victim or not victim:IsAlive() then
goto __continue23
end
applyLucentBeamHit(
nil,
parent,
ability,
victim,
damage,
stun
)
end
::__continue23::
end
else
local victim = enemies[RandomInt(0, #enemies - 1) + 1]
if not victim or not victim:IsAlive() then
self.beamsDone = self.beamsDone + 1
return
end
applyLucentBeamHit(
nil,
parent,
ability,
victim,
damage,
stun
)
end
self.beamsDone = self.beamsDone + 1
end
modifier_luna_eclipse_active = __TS__Decorate(
modifier_luna_eclipse_active,
modifier_luna_eclipse_active,
{registerModifier(nil)},
{kind = "class", name = "modifier_luna_eclipse_active"}
)
____exports.modifier_luna_eclipse_active = modifier_luna_eclipse_active
return ____exports