182 lines
7.1 KiB
Lua
182 lines
7.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 BaseAbility = ____dota_ts_adapter.BaseAbility
|
|
local BaseModifier = ____dota_ts_adapter.BaseModifier
|
|
local registerAbility = ____dota_ts_adapter.registerAbility
|
|
local registerModifier = ____dota_ts_adapter.registerModifier
|
|
--- Значения Warpath от уровня героя (не от уровня способности).
|
|
local function getWarpathLevel(self, hero)
|
|
return math.max(
|
|
1,
|
|
hero:GetLevel()
|
|
)
|
|
end
|
|
local function getWarpathDamagePerStack(self, ability, hero)
|
|
local level = getWarpathLevel(nil, hero)
|
|
return ability:GetSpecialValueFor("damage_per_stack_base") + level * ability:GetSpecialValueFor("damage_per_stack_per_hero_level") + ability:GetSpecialValueFor("damage_per_stack")
|
|
end
|
|
local function getWarpathMoveSpeedPerStack(self, ability, hero)
|
|
local level = getWarpathLevel(nil, hero)
|
|
return ability:GetSpecialValueFor("move_speed_per_stack_base") + level * ability:GetSpecialValueFor("move_speed_per_stack_per_hero_level")
|
|
end
|
|
local function getWarpathMaxStacks(self, ability, hero)
|
|
local level = getWarpathLevel(nil, hero)
|
|
return math.floor(ability:GetSpecialValueFor("max_stacks_base") + level * ability:GetSpecialValueFor("max_stacks_per_hero_level"))
|
|
end
|
|
local function getWarpathStackDuration(self, ability, hero)
|
|
local level = getWarpathLevel(nil, hero)
|
|
return ability:GetSpecialValueFor("stack_duration_base") + level * ability:GetSpecialValueFor("stack_duration_per_hero_level")
|
|
end
|
|
____exports.bristleback_warpath = __TS__Class()
|
|
local bristleback_warpath = ____exports.bristleback_warpath
|
|
bristleback_warpath.name = "bristleback_warpath"
|
|
bristleback_warpath.____file_path = "scripts/vscripts/abilities/heroes/bristleback/bristleback_warpath_custom.lua"
|
|
__TS__ClassExtends(bristleback_warpath, BaseAbility)
|
|
function bristleback_warpath.prototype.GetIntrinsicModifierName(self)
|
|
return ____exports.modifier_bristleback_warpath_custom.name
|
|
end
|
|
bristleback_warpath = __TS__Decorate(
|
|
bristleback_warpath,
|
|
bristleback_warpath,
|
|
{registerAbility(nil)},
|
|
{kind = "class", name = "bristleback_warpath"}
|
|
)
|
|
____exports.bristleback_warpath = bristleback_warpath
|
|
____exports.modifier_bristleback_warpath_custom = __TS__Class()
|
|
local modifier_bristleback_warpath_custom = ____exports.modifier_bristleback_warpath_custom
|
|
modifier_bristleback_warpath_custom.name = "modifier_bristleback_warpath_custom"
|
|
modifier_bristleback_warpath_custom.____file_path = "scripts/vscripts/abilities/heroes/bristleback/bristleback_warpath_custom.lua"
|
|
__TS__ClassExtends(modifier_bristleback_warpath_custom, BaseModifier)
|
|
function modifier_bristleback_warpath_custom.prototype.IsHidden(self)
|
|
return true
|
|
end
|
|
function modifier_bristleback_warpath_custom.prototype.IsPurgable(self)
|
|
return false
|
|
end
|
|
function modifier_bristleback_warpath_custom.prototype.RemoveOnDeath(self)
|
|
return false
|
|
end
|
|
function modifier_bristleback_warpath_custom.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_EVENT_ON_TAKEDAMAGE}
|
|
end
|
|
function modifier_bristleback_warpath_custom.prototype.OnCreated(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
self.parentHero = self:GetParent()
|
|
end
|
|
function modifier_bristleback_warpath_custom.prototype.OnTakeDamage(self, event)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
if event.unit ~= self.parentHero then
|
|
return
|
|
end
|
|
if event.damage <= 0 then
|
|
return
|
|
end
|
|
if self.parentHero:PassivesDisabled() then
|
|
return
|
|
end
|
|
local ability = self:GetAbility()
|
|
if not ability or ability:IsNull() then
|
|
return
|
|
end
|
|
local stacksMod = self.parentHero:FindModifierByName(____exports.modifier_bristleback_warpath_stacks.name)
|
|
local maxStacks = getWarpathMaxStacks(nil, ability, self.parentHero)
|
|
local duration = getWarpathStackDuration(nil, ability, self.parentHero)
|
|
if not stacksMod then
|
|
self.parentHero:AddNewModifier(self.parentHero, ability, ____exports.modifier_bristleback_warpath_stacks.name, {duration = duration})
|
|
return
|
|
end
|
|
local nextStacks = math.min(
|
|
maxStacks,
|
|
stacksMod:GetStackCount() + 1
|
|
)
|
|
stacksMod:SetStackCount(nextStacks)
|
|
stacksMod:SetDuration(duration, true)
|
|
stacksMod:ForceRefresh()
|
|
end
|
|
modifier_bristleback_warpath_custom = __TS__Decorate(
|
|
modifier_bristleback_warpath_custom,
|
|
modifier_bristleback_warpath_custom,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_bristleback_warpath_custom"}
|
|
)
|
|
____exports.modifier_bristleback_warpath_custom = modifier_bristleback_warpath_custom
|
|
____exports.modifier_bristleback_warpath_stacks = __TS__Class()
|
|
local modifier_bristleback_warpath_stacks = ____exports.modifier_bristleback_warpath_stacks
|
|
modifier_bristleback_warpath_stacks.name = "modifier_bristleback_warpath_stacks"
|
|
modifier_bristleback_warpath_stacks.____file_path = "scripts/vscripts/abilities/heroes/bristleback/bristleback_warpath_custom.lua"
|
|
__TS__ClassExtends(modifier_bristleback_warpath_stacks, BaseModifier)
|
|
function modifier_bristleback_warpath_stacks.prototype.IsHidden(self)
|
|
return false
|
|
end
|
|
function modifier_bristleback_warpath_stacks.prototype.IsPurgable(self)
|
|
return false
|
|
end
|
|
function modifier_bristleback_warpath_stacks.prototype.IsDebuff(self)
|
|
return false
|
|
end
|
|
function modifier_bristleback_warpath_stacks.prototype.GetTexture(self)
|
|
return "bristleback_warpath"
|
|
end
|
|
function modifier_bristleback_warpath_stacks.prototype.OnCreated(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
self:SetStackCount(1)
|
|
end
|
|
function modifier_bristleback_warpath_stacks.prototype.OnRefresh(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
self:SetStackCount(math.max(
|
|
1,
|
|
self:GetStackCount()
|
|
))
|
|
end
|
|
function modifier_bristleback_warpath_stacks.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_PREATTACK_BONUS_DAMAGE, MODIFIER_PROPERTY_MOVESPEED_BONUS_CONSTANT}
|
|
end
|
|
function modifier_bristleback_warpath_stacks.prototype.GetModifierPreAttack_BonusDamage(self)
|
|
if self:GetParent():PassivesDisabled() then
|
|
return 0
|
|
end
|
|
local ability = self:GetAbility()
|
|
if not ability then
|
|
return 0
|
|
end
|
|
return self:GetStackCount() * getWarpathDamagePerStack(
|
|
nil,
|
|
ability,
|
|
self:GetParent()
|
|
)
|
|
end
|
|
function modifier_bristleback_warpath_stacks.prototype.GetModifierMoveSpeedBonus_Constant(self)
|
|
if self:GetParent():PassivesDisabled() then
|
|
return 0
|
|
end
|
|
local ability = self:GetAbility()
|
|
if not ability then
|
|
return 0
|
|
end
|
|
return self:GetStackCount() * getWarpathMoveSpeedPerStack(
|
|
nil,
|
|
ability,
|
|
self:GetParent()
|
|
)
|
|
end
|
|
modifier_bristleback_warpath_stacks = __TS__Decorate(
|
|
modifier_bristleback_warpath_stacks,
|
|
modifier_bristleback_warpath_stacks,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_bristleback_warpath_stacks"}
|
|
)
|
|
____exports.modifier_bristleback_warpath_stacks = modifier_bristleback_warpath_stacks
|
|
return ____exports
|