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

182 lines
6.2 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
____exports.glaives_of_wisdom = __TS__Class()
local glaives_of_wisdom = ____exports.glaives_of_wisdom
glaives_of_wisdom.name = "glaives_of_wisdom"
glaives_of_wisdom.____file_path = "scripts/vscripts/abilities/heroes/silencer/glaives_of_wisdom.lua"
__TS__ClassExtends(glaives_of_wisdom, BaseAbility)
function glaives_of_wisdom.prototype.GetIntrinsicModifierName(self)
return ____exports.modifier_glaives_of_wisdom.name
end
glaives_of_wisdom = __TS__Decorate(
glaives_of_wisdom,
glaives_of_wisdom,
{registerAbility(nil)},
{kind = "class", name = "glaives_of_wisdom"}
)
____exports.glaives_of_wisdom = glaives_of_wisdom
____exports.modifier_glaives_of_wisdom = __TS__Class()
local modifier_glaives_of_wisdom = ____exports.modifier_glaives_of_wisdom
modifier_glaives_of_wisdom.name = "modifier_glaives_of_wisdom"
modifier_glaives_of_wisdom.____file_path = "scripts/vscripts/abilities/heroes/silencer/glaives_of_wisdom.lua"
__TS__ClassExtends(modifier_glaives_of_wisdom, BaseModifier)
function modifier_glaives_of_wisdom.prototype.____constructor(self, ...)
BaseModifier.prototype.____constructor(self, ...)
self.ricochetAttackDepth = 0
self.ricochetProjectileSpeed = 1250
end
function modifier_glaives_of_wisdom.prototype.IsPurgable(self)
return false
end
function modifier_glaives_of_wisdom.prototype.DeclareFunctions(self)
return {MODIFIER_PROPERTY_PROCATTACK_BONUS_DAMAGE_PURE, MODIFIER_PROPERTY_PROJECTILE_NAME, MODIFIER_EVENT_ON_ATTACK_LANDED}
end
function modifier_glaives_of_wisdom.prototype.GetModifierProcAttack_BonusDamage_Pure(self, event)
if not IsServer() then
return 0
end
if event.attacker ~= self:GetParent() then
return 0
end
if not event.target then
return 0
end
local caster = self:GetCaster()
local ability = self:GetAbility()
if not caster or not ability then
return 0
end
local damage = caster:GetIntellect(true) * (ability:GetSpecialValueFor("intellect_damage_pct") / 100)
SendOverheadEventMessage(
nil,
OVERHEAD_ALERT_BONUS_SPELL_DAMAGE,
event.target,
damage,
nil
)
EmitSoundOn("Hero_Silencer.GlaivesOfWisdom.Damage", event.target)
return damage
end
function modifier_glaives_of_wisdom.prototype.GetModifierProjectileName(self)
return "particles/units/heroes/hero_silencer/silencer_glaives_of_wisdom.vpcf"
end
function modifier_glaives_of_wisdom.prototype.OnAttackLanded(self, event)
if not IsServer() then
return
end
if self.ricochetAttackDepth > 0 then
return
end
local attacker = self:GetParent()
local ability = self:GetAbility()
if not attacker or not ability then
return
end
if event.attacker ~= attacker then
return
end
local primaryTarget = event.target
if not primaryTarget or not IsValidEntity(primaryTarget) or not primaryTarget:IsAlive() then
return
end
if primaryTarget:GetTeamNumber() == attacker:GetTeamNumber() then
return
end
if attacker:PassivesDisabled() then
return
end
local talent = attacker:FindAbilityByName("special_bonus_unique_silencer_glaives_bounces")
if not talent or talent:GetLevel() <= 0 then
return
end
local ricochetCount = talent:GetSpecialValueFor("bonus_bounce_count")
if ricochetCount <= 0 then
return
end
local ricochetRange = attacker:Script_GetAttackRange() + 150
local enemies = FindUnitsInRadius(
attacker:GetTeamNumber(),
primaryTarget:GetAbsOrigin(),
nil,
ricochetRange,
DOTA_UNIT_TARGET_TEAM_ENEMY,
bit.bor(DOTA_UNIT_TARGET_HERO, DOTA_UNIT_TARGET_BASIC),
DOTA_UNIT_TARGET_FLAG_NO_INVIS,
FIND_CLOSEST,
false
)
local launched = 0
for ____, enemy in ipairs(enemies) do
do
if launched >= ricochetCount then
break
end
if enemy == primaryTarget then
goto __continue21
end
if not enemy:IsAlive() then
goto __continue21
end
if enemy:GetTeamNumber() == attacker:GetTeamNumber() then
goto __continue21
end
self:LaunchRicochetProjectile(attacker, primaryTarget, enemy)
launched = launched + 1
end
::__continue21::
end
end
function modifier_glaives_of_wisdom.prototype.LaunchRicochetProjectile(self, attacker, source, target)
local ability = self:GetAbility()
if not ability then
return
end
ProjectileManager:CreateTrackingProjectile({
Source = source,
Target = target,
Ability = ability,
EffectName = self:GetModifierProjectileName(),
iMoveSpeed = self.ricochetProjectileSpeed,
bDodgeable = true,
bVisibleToEnemies = true,
bReplaceExisting = false,
bProvidesVision = false
})
Timers:CreateTimer(
0.2,
function()
if not attacker:IsAlive() or not target:IsAlive() then
return
end
self.ricochetAttackDepth = self.ricochetAttackDepth + 1
attacker:PerformAttack(
target,
true,
true,
true,
false,
false,
false,
false
)
self.ricochetAttackDepth = math.max(0, self.ricochetAttackDepth - 1)
end
)
end
modifier_glaives_of_wisdom = __TS__Decorate(
modifier_glaives_of_wisdom,
modifier_glaives_of_wisdom,
{registerModifier(nil)},
{kind = "class", name = "modifier_glaives_of_wisdom"}
)
____exports.modifier_glaives_of_wisdom = modifier_glaives_of_wisdom
return ____exports