Files
Dota-Zombie-Invasion/scripts/vscripts/arsenal/items/battle_level.lua
T
2026-05-29 15:11:31 +07:00

63 lines
2.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 ____dota_ts_adapter = require("lib.dota_ts_adapter")
local BaseModifier = ____dota_ts_adapter.BaseModifier
local registerModifier = ____dota_ts_adapter.registerModifier
____exports.modifier_arsenal_battle_level = __TS__Class()
local modifier_arsenal_battle_level = ____exports.modifier_arsenal_battle_level
modifier_arsenal_battle_level.name = "modifier_arsenal_battle_level"
modifier_arsenal_battle_level.____file_path = "scripts/vscripts/arsenal/items/battle_level.lua"
__TS__ClassExtends(modifier_arsenal_battle_level, BaseModifier)
function modifier_arsenal_battle_level.prototype.IsHidden(self)
return true
end
function modifier_arsenal_battle_level.prototype.RemoveOnDeath(self)
return false
end
function modifier_arsenal_battle_level.prototype.OnCreated(self)
if not IsServer() then
return
end
self:applyBattleLevel()
end
function modifier_arsenal_battle_level.prototype.OnRefresh(self)
if not IsServer() then
return
end
self:applyBattleLevel()
end
function modifier_arsenal_battle_level.prototype.applyBattleLevel(self)
local hero = self:GetParent()
if not hero or not IsValidEntity(hero) or not hero:IsRealHero() then
return
end
local bonus = math.max(
0,
math.floor(self:GetStackCount() or 0)
)
if bonus <= 0 then
return
end
local targetLevel = 1 + bonus
local cur = hero:GetLevel()
if cur >= targetLevel then
return
end
local prevAbilityPoints = hero:GetAbilityPoints()
while hero:GetLevel() < targetLevel do
hero:HeroLevelUp(false)
hero:SetAbilityPoints(prevAbilityPoints)
end
end
modifier_arsenal_battle_level = __TS__Decorate(
modifier_arsenal_battle_level,
modifier_arsenal_battle_level,
{registerModifier(nil)},
{kind = "class", name = "modifier_arsenal_battle_level"}
)
____exports.modifier_arsenal_battle_level = modifier_arsenal_battle_level
return ____exports