127 lines
4.9 KiB
Lua
127 lines
4.9 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 BaseModifier = ____dota_ts_adapter.BaseModifier
|
|
local registerModifier = ____dota_ts_adapter.registerModifier
|
|
____exports.modifier_general_fired = __TS__Class()
|
|
local modifier_general_fired = ____exports.modifier_general_fired
|
|
modifier_general_fired.name = "modifier_general_fired"
|
|
modifier_general_fired.____file_path = "scripts/vscripts/abilities/modifiers/modifier_general_fired.lua"
|
|
__TS__ClassExtends(modifier_general_fired, BaseModifier)
|
|
function modifier_general_fired.prototype.____constructor(self, ...)
|
|
BaseModifier.prototype.____constructor(self, ...)
|
|
self.isBurned = false
|
|
self.STACKS_TO_BURN = 0
|
|
self.STACKS_TO_ARMOR_REDUCE = 70
|
|
end
|
|
function modifier_general_fired.prototype.IsDebuff(self)
|
|
return true
|
|
end
|
|
function modifier_general_fired.prototype.IsPurgable(self)
|
|
return true
|
|
end
|
|
function modifier_general_fired.prototype.OnCreated(self)
|
|
if IsServer() then
|
|
self:CheckBurnedState()
|
|
self:StartIntervalThink(1)
|
|
end
|
|
end
|
|
function modifier_general_fired.prototype.OnRefresh(self)
|
|
if IsServer() then
|
|
self:CheckBurnedState()
|
|
end
|
|
end
|
|
function modifier_general_fired.prototype.OnDestroy(self)
|
|
if IsClient() then
|
|
return
|
|
end
|
|
if self.particleId then
|
|
ParticleManager:DestroyParticle(self.particleId, false)
|
|
ParticleManager:ReleaseParticleIndex(self.particleId)
|
|
end
|
|
if self.burnedParticleId then
|
|
ParticleManager:DestroyParticle(self.burnedParticleId, false)
|
|
ParticleManager:ReleaseParticleIndex(self.burnedParticleId)
|
|
end
|
|
self.burnedParticleId = nil
|
|
end
|
|
function modifier_general_fired.prototype.OnIntervalThink(self)
|
|
local frozeModifier = self:GetParent():FindModifierByName("modifier_general_froze")
|
|
local frozeStacks = frozeModifier and frozeModifier:GetStackCount() or 0
|
|
if self:GetStackCount() > 0 then
|
|
local decreaseAmount = math.max(
|
|
1,
|
|
math.ceil(self:GetStackCount() * 0.1)
|
|
)
|
|
self:SetStackCount(self:GetStackCount() - decreaseAmount)
|
|
self:SetDuration(1.01, true)
|
|
else
|
|
self:GetParent():RemoveModifierByName("modifier_general_fired")
|
|
end
|
|
if frozeStacks > 0 then
|
|
local decreaseAmount = math.min(
|
|
self:GetStackCount(),
|
|
frozeStacks
|
|
)
|
|
self:SetStackCount(self:GetStackCount() - decreaseAmount)
|
|
if frozeModifier then
|
|
frozeModifier:SetStackCount(frozeStacks - decreaseAmount)
|
|
end
|
|
end
|
|
if self:GetStackCount() > 0 then
|
|
ApplyDamage({
|
|
victim = self:GetParent(),
|
|
attacker = self:GetCaster() or self:GetParent(),
|
|
damage = self:GetStackCount() * 3,
|
|
damage_type = DAMAGE_TYPE_MAGICAL,
|
|
ability = self:GetAbility()
|
|
})
|
|
end
|
|
end
|
|
function modifier_general_fired.prototype.CheckState(self)
|
|
if self.isBurned and self:GetStackCount() >= self.STACKS_TO_ARMOR_REDUCE then
|
|
return {[MODIFIER_STATE_PASSIVES_DISABLED] = true}
|
|
end
|
|
return {}
|
|
end
|
|
function modifier_general_fired.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_PHYSICAL_ARMOR_BONUS, MODIFIER_PROPERTY_MAGICAL_RESISTANCE_BONUS, MODIFIER_PROPERTY_PHYSICAL_ARMOR_BONUS}
|
|
end
|
|
function modifier_general_fired.prototype.GetModifierPhysicalArmorBonus(self)
|
|
return self:GetStackCount() >= self.STACKS_TO_ARMOR_REDUCE and -self:GetStackCount() * 0.25 or 0
|
|
end
|
|
function modifier_general_fired.prototype.GetModifierMagicalResistanceBonus(self)
|
|
return self:GetStackCount() >= self.STACKS_TO_ARMOR_REDUCE and -self:GetStackCount() * 0.25 or 0
|
|
end
|
|
function modifier_general_fired.prototype.GetEffectName(self)
|
|
return "particles/units/heroes/hero_huskar/huskar_burning_spear_debuff.vpcf"
|
|
end
|
|
function modifier_general_fired.prototype.GetEffectAttachType(self)
|
|
return PATTACH_ABSORIGIN_FOLLOW
|
|
end
|
|
function modifier_general_fired.prototype.CheckBurnedState(self)
|
|
local parent = self:GetParent()
|
|
if self:GetStackCount() >= self.STACKS_TO_BURN and not self.isBurned then
|
|
self.isBurned = true
|
|
EmitSoundOn("Hero_Huskar.BurningSpear.Target", parent)
|
|
elseif self:GetStackCount() < self.STACKS_TO_BURN and self.isBurned then
|
|
self.isBurned = false
|
|
if self.burnedParticleId then
|
|
ParticleManager:DestroyParticle(self.burnedParticleId, false)
|
|
ParticleManager:ReleaseParticleIndex(self.burnedParticleId)
|
|
self.burnedParticleId = nil
|
|
end
|
|
end
|
|
end
|
|
modifier_general_fired = __TS__Decorate(
|
|
modifier_general_fired,
|
|
modifier_general_fired,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_general_fired"}
|
|
)
|
|
____exports.modifier_general_fired = modifier_general_fired
|
|
return ____exports
|