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

349 lines
13 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.ability_juggernaut_omnislash_custom = __TS__Class()
local ability_juggernaut_omnislash_custom = ____exports.ability_juggernaut_omnislash_custom
ability_juggernaut_omnislash_custom.name = "ability_juggernaut_omnislash_custom"
ability_juggernaut_omnislash_custom.____file_path = "scripts/vscripts/abilities/heroes/juggernaut/ability_juggernaut_omnislash_custom.lua"
__TS__ClassExtends(ability_juggernaut_omnislash_custom, BaseAbility)
function ability_juggernaut_omnislash_custom.prototype.OnSpellStart(self)
if not IsServer() then
return
end
local caster = self:GetCaster()
local target = self:GetCursorTarget()
if not target or not target:IsAlive() then
return
end
local duration = self:GetSpecialValueFor("duration")
caster:AddNewModifier(
caster,
self,
"modifier_juggernaut_omnislash_custom",
{
target = target:entindex(),
duration = duration
}
)
EmitSoundOn("Hero_Juggernaut.Omnislash", caster)
end
ability_juggernaut_omnislash_custom = __TS__Decorate(
ability_juggernaut_omnislash_custom,
ability_juggernaut_omnislash_custom,
{registerAbility(nil)},
{kind = "class", name = "ability_juggernaut_omnislash_custom"}
)
____exports.ability_juggernaut_omnislash_custom = ability_juggernaut_omnislash_custom
____exports.ability_juggernaut_miniomnislash_custom = __TS__Class()
local ability_juggernaut_miniomnislash_custom = ____exports.ability_juggernaut_miniomnislash_custom
ability_juggernaut_miniomnislash_custom.name = "ability_juggernaut_miniomnislash_custom"
ability_juggernaut_miniomnislash_custom.____file_path = "scripts/vscripts/abilities/heroes/juggernaut/ability_juggernaut_omnislash_custom.lua"
__TS__ClassExtends(ability_juggernaut_miniomnislash_custom, BaseAbility)
function ability_juggernaut_miniomnislash_custom.prototype.OnSpellStart(self)
if not IsServer() then
return
end
local caster = self:GetCaster()
local target = self:GetCursorTarget()
if not target or not target:IsAlive() then
return
end
local duration = self:GetSpecialValueFor("duration")
caster:AddNewModifier(
caster,
self,
"modifier_juggernaut_omnislash_custom",
{
target = target:entindex(),
duration = duration
}
)
EmitSoundOn("Hero_Juggernaut.Omnislash", caster)
end
ability_juggernaut_miniomnislash_custom = __TS__Decorate(
ability_juggernaut_miniomnislash_custom,
ability_juggernaut_miniomnislash_custom,
{registerAbility(nil)},
{kind = "class", name = "ability_juggernaut_miniomnislash_custom"}
)
____exports.ability_juggernaut_miniomnislash_custom = ability_juggernaut_miniomnislash_custom
____exports.modifier_juggernaut_omnislash_custom = __TS__Class()
local modifier_juggernaut_omnislash_custom = ____exports.modifier_juggernaut_omnislash_custom
modifier_juggernaut_omnislash_custom.name = "modifier_juggernaut_omnislash_custom"
modifier_juggernaut_omnislash_custom.____file_path = "scripts/vscripts/abilities/heroes/juggernaut/ability_juggernaut_omnislash_custom.lua"
__TS__ClassExtends(modifier_juggernaut_omnislash_custom, BaseModifier)
function modifier_juggernaut_omnislash_custom.prototype.____constructor(self, ...)
BaseModifier.prototype.____constructor(self, ...)
self.attackCount = 0
self.interval = 0
self.radius = 0
self.endInterval = 0.15
end
function modifier_juggernaut_omnislash_custom.prototype.IsHidden(self)
return false
end
function modifier_juggernaut_omnislash_custom.prototype.IsPurgable(self)
return false
end
function modifier_juggernaut_omnislash_custom.prototype.CheckState(self)
return {
[MODIFIER_STATE_NO_UNIT_COLLISION] = true,
[MODIFIER_STATE_INVULNERABLE] = true,
[MODIFIER_STATE_NO_HEALTH_BAR] = true,
[MODIFIER_STATE_DISARMED] = true,
[MODIFIER_STATE_ROOTED] = true,
[MODIFIER_STATE_SILENCED] = true
}
end
function modifier_juggernaut_omnislash_custom.prototype.DeclareFunctions(self)
return {MODIFIER_PROPERTY_IGNORE_CAST_ANGLE}
end
function modifier_juggernaut_omnislash_custom.prototype.GetModifierIgnoreCastAngle(self)
return 1
end
function modifier_juggernaut_omnislash_custom.prototype.OnCreated(self, params)
if not IsServer() then
return
end
local caster = self:GetParent()
local ability = self:GetAbility()
if not caster or not ability then
return
end
self.interval = 1 / self:GetCaster():GetAttacksPerSecond(false) / ability:GetSpecialValueFor("slash_interval_mult")
self.radius = ability:GetSpecialValueFor("bounce_radius")
if params.target ~= nil then
self.currentTarget = EntIndexToHScript(params.target)
end
caster:StartGesture(ACT_DOTA_OVERRIDE_ABILITY_4)
self:OnIntervalThink()
self:StartIntervalThink(self.interval)
end
function modifier_juggernaut_omnislash_custom.prototype.OnIntervalThink(self)
if not IsServer() then
return
end
self.attackCount = self.attackCount + 1
local caster = self:GetParent()
local ability = self:GetAbility()
if not caster or not caster:IsAlive() or not ability then
self:Destroy()
return
end
if self:GetRemainingTime() <= 0 then
self:Destroy()
return
end
local enemy = nil
local final = self.currentTarget == nil
if self.currentTarget and IsValidEntity(self.currentTarget) and self.currentTarget:IsAlive() and not self.currentTarget:IsOutOfGame() and (not self.currentTarget:IsInvisible() or caster:CanEntityBeSeenByMyTeam(self.currentTarget)) then
local distance = (self.currentTarget:GetAbsOrigin() - caster:GetAbsOrigin()):Length2D()
if distance <= self.radius or self.attackCount == 1 then
enemy = self.currentTarget
end
end
if not enemy then
local targets = FindUnitsInRadius(
caster:GetTeamNumber(),
caster:GetAbsOrigin(),
nil,
self.radius,
DOTA_UNIT_TARGET_TEAM_ENEMY,
bit.bor(DOTA_UNIT_TARGET_HERO, DOTA_UNIT_TARGET_BASIC),
bit.bor(
bit.bor(DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES, DOTA_UNIT_TARGET_FLAG_NO_INVIS),
DOTA_UNIT_TARGET_FLAG_INVULNERABLE
),
FIND_ANY_ORDER,
false
)
if targets and #targets > 0 then
enemy = targets[1]
end
end
if not enemy then
if final then
self:Destroy()
return
end
self.currentTarget = nil
self:StartIntervalThink(self.endInterval)
return
end
self.currentTarget = enemy
self:PlayEffect(enemy)
self:DealAttack(enemy)
if self:GetRemainingTime() > self.interval then
self:StartIntervalThink(self.interval)
end
end
function modifier_juggernaut_omnislash_custom.prototype.PlayEffect(self, enemy)
if not IsServer() then
return
end
local caster = self:GetParent()
caster:RemoveGesture(ACT_DOTA_OVERRIDE_ABILITY_4)
caster:StartGesture(ACT_DOTA_OVERRIDE_ABILITY_4)
local position1 = caster:GetAbsOrigin()
local turn = (enemy:GetAbsOrigin() - position1):Normalized()
turn.z = 0
local linePos = enemy:GetAbsOrigin() + turn * 90
local angle = -45 + 90 * RandomInt(0, 1)
local finalPos = rotatePositionYaw(
nil,
enemy:GetAbsOrigin(),
angle,
linePos
)
caster:SetAbsOrigin(finalPos)
local position2 = caster:GetAbsOrigin()
local direction = (enemy:GetAbsOrigin() - caster:GetAbsOrigin()):Normalized()
direction.z = 0
caster:SetForwardVector(direction)
caster:FaceTowards(enemy:GetAbsOrigin())
local trailParticle = ParticleManager:CreateParticle("particles/units/heroes/hero_juggernaut/juggernaut_omni_slash_trail.vpcf", PATTACH_ABSORIGIN, caster)
ParticleManager:SetParticleControl(trailParticle, 0, position1)
ParticleManager:SetParticleControl(trailParticle, 1, position2)
ParticleManager:ReleaseParticleIndex(trailParticle)
if self.attackCount == 1 then
local dashParticle = ParticleManager:CreateParticle("particles/units/heroes/hero_juggernaut/juggernaut_omni_dash.vpcf", PATTACH_CUSTOMORIGIN, caster)
local vDirection = (position2 - position1):Normalized()
ParticleManager:SetParticleControl(dashParticle, 0, position1)
ParticleManager:SetParticleControlForward(dashParticle, 0, vDirection * -1)
ParticleManager:SetParticleControlEnt(
dashParticle,
1,
enemy,
PATTACH_ABSORIGIN_FOLLOW,
"attach_hitloc",
enemy:GetAbsOrigin(),
true
)
ParticleManager:SetParticleControlEnt(
dashParticle,
2,
enemy,
PATTACH_ABSORIGIN_FOLLOW,
"attach_hitloc",
enemy:GetAbsOrigin(),
true
)
ParticleManager:ReleaseParticleIndex(dashParticle)
end
end
function modifier_juggernaut_omnislash_custom.prototype.DealAttack(self, target)
if not IsServer() then
return
end
local caster = self:GetParent()
local ability = self:GetAbility()
if not caster or not ability then
return
end
local attackModifier = caster:AddNewModifier(caster, ability, "modifier_juggernaut_omnislash_attack", {})
caster:PerformAttack(
target,
true,
true,
true,
false,
false,
false,
false
)
if attackModifier ~= nil then
attackModifier:Destroy()
end
local tgtParticle = ParticleManager:CreateParticle("particles/units/heroes/hero_juggernaut/juggernaut_omni_slash_tgt.vpcf", PATTACH_ABSORIGIN_FOLLOW, target)
ParticleManager:SetParticleControlEnt(
tgtParticle,
0,
target,
PATTACH_ABSORIGIN_FOLLOW,
"attach_hitloc",
target:GetAbsOrigin(),
true
)
ParticleManager:SetParticleControlEnt(
tgtParticle,
1,
target,
PATTACH_ABSORIGIN_FOLLOW,
"attach_hitloc",
target:GetAbsOrigin(),
true
)
ParticleManager:ReleaseParticleIndex(tgtParticle)
EmitSoundOn("Hero_Juggernaut.OmniSlash", target)
end
function modifier_juggernaut_omnislash_custom.prototype.OnDestroy(self)
if not IsServer() then
return
end
local caster = self:GetParent()
if caster and caster:IsAlive() then
caster:FadeGesture(ACT_DOTA_OVERRIDE_ABILITY_4)
caster:Stop()
end
EmitSoundOn("Hero_Juggernaut.Omnislash.End", caster)
end
function modifier_juggernaut_omnislash_custom.prototype.GetStatusEffectName(self)
return "particles/status_fx/status_effect_omnislash.vpcf"
end
function modifier_juggernaut_omnislash_custom.prototype.StatusEffectPriority(self)
return 10
end
modifier_juggernaut_omnislash_custom = __TS__Decorate(
modifier_juggernaut_omnislash_custom,
modifier_juggernaut_omnislash_custom,
{registerModifier(nil)},
{kind = "class", name = "modifier_juggernaut_omnislash_custom"}
)
____exports.modifier_juggernaut_omnislash_custom = modifier_juggernaut_omnislash_custom
____exports.modifier_juggernaut_omnislash_attack = __TS__Class()
local modifier_juggernaut_omnislash_attack = ____exports.modifier_juggernaut_omnislash_attack
modifier_juggernaut_omnislash_attack.name = "modifier_juggernaut_omnislash_attack"
modifier_juggernaut_omnislash_attack.____file_path = "scripts/vscripts/abilities/heroes/juggernaut/ability_juggernaut_omnislash_custom.lua"
__TS__ClassExtends(modifier_juggernaut_omnislash_attack, BaseModifier)
function modifier_juggernaut_omnislash_attack.prototype.____constructor(self, ...)
BaseModifier.prototype.____constructor(self, ...)
self.damagePercent = 0
end
function modifier_juggernaut_omnislash_attack.prototype.IsHidden(self)
return true
end
function modifier_juggernaut_omnislash_attack.prototype.OnCreated(self)
if not IsServer() then
return
end
local ability = self:GetAbility()
if not ability then
return
end
self.damagePercent = ability:GetSpecialValueFor("damage") - 100
end
function modifier_juggernaut_omnislash_attack.prototype.DeclareFunctions(self)
return {MODIFIER_PROPERTY_DAMAGEOUTGOING_PERCENTAGE}
end
function modifier_juggernaut_omnislash_attack.prototype.GetModifierDamageOutgoing_Percentage(self, event)
if event.inflictor then
return 0
end
return self.damagePercent
end
modifier_juggernaut_omnislash_attack = __TS__Decorate(
modifier_juggernaut_omnislash_attack,
modifier_juggernaut_omnislash_attack,
{registerModifier(nil)},
{kind = "class", name = "modifier_juggernaut_omnislash_attack"}
)
____exports.modifier_juggernaut_omnislash_attack = modifier_juggernaut_omnislash_attack
return ____exports