228 lines
8.1 KiB
Lua
228 lines
8.1 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 ____difficulty_manager = require("difficulty_manager")
|
|
local Difficulty = ____difficulty_manager.Difficulty
|
|
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 ZOMBIE_VIRUS_DEBUFF_NAME = "modifier_zombie_virus_debuff"
|
|
local ZOMBIE_VIRUS_MAX_INSTANCES = 9
|
|
local function countZombieVirusDebuffInstances(self, unit)
|
|
local n = 0
|
|
do
|
|
local i = 0
|
|
while i < unit:GetModifierCount() do
|
|
if unit:GetModifierNameByIndex(i) == ZOMBIE_VIRUS_DEBUFF_NAME then
|
|
n = n + 1
|
|
end
|
|
i = i + 1
|
|
end
|
|
end
|
|
return n
|
|
end
|
|
____exports.zombie_virus = __TS__Class()
|
|
local zombie_virus = ____exports.zombie_virus
|
|
zombie_virus.name = "zombie_virus"
|
|
zombie_virus.____file_path = "scripts/vscripts/abilities/creep/zombie_virus.lua"
|
|
__TS__ClassExtends(zombie_virus, BaseAbility)
|
|
function zombie_virus.prototype.GetIntrinsicModifierName(self)
|
|
return "modifier_zombie_virus_intrinsic"
|
|
end
|
|
zombie_virus = __TS__Decorate(
|
|
zombie_virus,
|
|
zombie_virus,
|
|
{registerAbility(nil)},
|
|
{kind = "class", name = "zombie_virus"}
|
|
)
|
|
____exports.zombie_virus = zombie_virus
|
|
____exports.modifier_zombie_virus_intrinsic = __TS__Class()
|
|
local modifier_zombie_virus_intrinsic = ____exports.modifier_zombie_virus_intrinsic
|
|
modifier_zombie_virus_intrinsic.name = "modifier_zombie_virus_intrinsic"
|
|
modifier_zombie_virus_intrinsic.____file_path = "scripts/vscripts/abilities/creep/zombie_virus.lua"
|
|
__TS__ClassExtends(modifier_zombie_virus_intrinsic, BaseModifier)
|
|
function modifier_zombie_virus_intrinsic.prototype.IsHidden(self)
|
|
return true
|
|
end
|
|
function modifier_zombie_virus_intrinsic.prototype.IsDebuff(self)
|
|
return false
|
|
end
|
|
function modifier_zombie_virus_intrinsic.prototype.IsPurgable(self)
|
|
return false
|
|
end
|
|
function modifier_zombie_virus_intrinsic.prototype.OnCreated(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
end
|
|
function modifier_zombie_virus_intrinsic.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_EVENT_ON_ATTACK_LANDED}
|
|
end
|
|
function modifier_zombie_virus_intrinsic.prototype.OnAttackLanded(self, event)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
if event.attacker ~= self:GetParent() then
|
|
return
|
|
end
|
|
local ability = self:GetAbility()
|
|
if not ability then
|
|
return
|
|
end
|
|
local primaryZombieVirus = event.attacker:FindAbilityByName("zombie_virus")
|
|
if not primaryZombieVirus or ability ~= primaryZombieVirus then
|
|
return
|
|
end
|
|
local target = event.target
|
|
if not target or target:GetUnitName() == "npc_homer" then
|
|
return
|
|
end
|
|
local duration = ability:GetSpecialValueFor("duration")
|
|
if RandomInt(1, 100) > ability:GetSpecialValueFor("chance") then
|
|
return
|
|
end
|
|
if countZombieVirusDebuffInstances(nil, target) >= ZOMBIE_VIRUS_MAX_INSTANCES then
|
|
return
|
|
end
|
|
target:AddNewModifier(
|
|
self:GetParent(),
|
|
ability,
|
|
ZOMBIE_VIRUS_DEBUFF_NAME,
|
|
{duration = duration}
|
|
)
|
|
end
|
|
modifier_zombie_virus_intrinsic = __TS__Decorate(
|
|
modifier_zombie_virus_intrinsic,
|
|
modifier_zombie_virus_intrinsic,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_zombie_virus_intrinsic"}
|
|
)
|
|
____exports.modifier_zombie_virus_intrinsic = modifier_zombie_virus_intrinsic
|
|
____exports.modifier_zombie_virus_debuff = __TS__Class()
|
|
local modifier_zombie_virus_debuff = ____exports.modifier_zombie_virus_debuff
|
|
modifier_zombie_virus_debuff.name = "modifier_zombie_virus_debuff"
|
|
modifier_zombie_virus_debuff.____file_path = "scripts/vscripts/abilities/creep/zombie_virus.lua"
|
|
__TS__ClassExtends(modifier_zombie_virus_debuff, BaseModifier)
|
|
function modifier_zombie_virus_debuff.prototype.IsHidden(self)
|
|
return true
|
|
end
|
|
function modifier_zombie_virus_debuff.prototype.IsDebuff(self)
|
|
return true
|
|
end
|
|
function modifier_zombie_virus_debuff.prototype.IsPurgable(self)
|
|
return true
|
|
end
|
|
function modifier_zombie_virus_debuff.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_MOVESPEED_BONUS_PERCENTAGE, MODIFIER_PROPERTY_PHYSICAL_ARMOR_BONUS}
|
|
end
|
|
function modifier_zombie_virus_debuff.prototype.GetModifierMoveSpeedBonus_Percentage(self)
|
|
local ability = self:GetAbility()
|
|
if not ability then
|
|
return 0
|
|
end
|
|
return -ability:GetSpecialValueFor("slow_movespeed") * Difficulty:getNpcStatScale()
|
|
end
|
|
function modifier_zombie_virus_debuff.prototype.GetModifierPhysicalArmorBonus(self)
|
|
local ability = self:GetAbility()
|
|
if not ability then
|
|
return 0
|
|
end
|
|
return -ability:GetSpecialValueFor("armor") * Difficulty:getNpcStatScale()
|
|
end
|
|
function modifier_zombie_virus_debuff.prototype.OnCreated(self)
|
|
local ability = self:GetAbility()
|
|
if not ability then
|
|
return
|
|
end
|
|
self.damage = ability:GetSpecialValueFor("damage")
|
|
self.tickInterval = ability:GetSpecialValueFor("tick_interval")
|
|
if IsServer() then
|
|
local caster = self:GetCaster()
|
|
if not caster or caster:IsNull() or not IsValidEntity(caster) or not caster:IsAlive() then
|
|
self:Destroy()
|
|
return
|
|
end
|
|
self:StartIntervalThink(self.tickInterval)
|
|
self.particleId = ParticleManager:CreateParticle(
|
|
"particles/econ/items/viper/viper_ti7_immortal/viper_poison_debuff_ti7.vpcf",
|
|
PATTACH_ABSORIGIN_FOLLOW,
|
|
self:GetParent()
|
|
)
|
|
ParticleManager:SetParticleControl(
|
|
self.particleId,
|
|
0,
|
|
self:GetParent():GetAbsOrigin()
|
|
)
|
|
ParticleManager:SetParticleControl(
|
|
self.particleId,
|
|
1,
|
|
self:GetParent():GetAbsOrigin()
|
|
)
|
|
end
|
|
end
|
|
function modifier_zombie_virus_debuff.prototype.OnRefresh(self, params)
|
|
if self.particleId then
|
|
ParticleManager:DestroyParticle(self.particleId, false)
|
|
ParticleManager:ReleaseParticleIndex(self.particleId)
|
|
end
|
|
end
|
|
function modifier_zombie_virus_debuff.prototype.OnIntervalThink(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local ability = self:GetAbility()
|
|
local caster = self:GetCaster()
|
|
local target = self:GetParent()
|
|
if not ability or ability:IsNull() or not caster or caster:IsNull() or not IsValidEntity(caster) or not caster:IsAlive() then
|
|
self:Destroy()
|
|
return
|
|
end
|
|
local tickDamage = self.damage * self.tickInterval * Difficulty:getNpcStatScale()
|
|
if target and target:IsAlive() then
|
|
ApplyDamage({
|
|
victim = target,
|
|
attacker = caster,
|
|
damage = tickDamage,
|
|
damage_type = DAMAGE_TYPE_PHYSICAL,
|
|
ability = ability
|
|
})
|
|
SendOverheadEventMessage(
|
|
nil,
|
|
OVERHEAD_ALERT_DAMAGE,
|
|
target,
|
|
tickDamage,
|
|
nil
|
|
)
|
|
end
|
|
end
|
|
function modifier_zombie_virus_debuff.prototype.OnDestroy(self)
|
|
if IsClient() then
|
|
return
|
|
end
|
|
if self.particleId then
|
|
ParticleManager:DestroyParticle(self.particleId, false)
|
|
ParticleManager:ReleaseParticleIndex(self.particleId)
|
|
end
|
|
end
|
|
function modifier_zombie_virus_debuff.prototype.GetEffectName(self)
|
|
return "particles/econ/items/void_spirit/void_spirit_immortal_2021/void_spirit_immortal_2021_astral_step_debuff.vpcf"
|
|
end
|
|
function modifier_zombie_virus_debuff.prototype.GetTexture(self)
|
|
return "life_stealer_open_wounds"
|
|
end
|
|
function modifier_zombie_virus_debuff.prototype.GetEffectAttachType(self)
|
|
return PATTACH_ABSORIGIN_FOLLOW
|
|
end
|
|
modifier_zombie_virus_debuff = __TS__Decorate(
|
|
modifier_zombie_virus_debuff,
|
|
modifier_zombie_virus_debuff,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_zombie_virus_debuff"}
|
|
)
|
|
____exports.modifier_zombie_virus_debuff = modifier_zombie_virus_debuff
|
|
return ____exports
|