initial commit
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
local ____lualib = require("lualib_bundle")
|
||||
local __TS__Class = ____lualib.__TS__Class
|
||||
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
||||
local ____exports = {}
|
||||
local ____dota_ts_adapter = require("lib.dota_ts_adapter")
|
||||
local BaseAbility = ____dota_ts_adapter.BaseAbility
|
||||
local ____hero_rage = require("abilities.system.hero_rage")
|
||||
local heroRageGetCurrent = ____hero_rage.heroRageGetCurrent
|
||||
--- Стоимость ярости: приоритет `rage_cost`, иначе берём обычный mana cost способности.
|
||||
function ____exports.getAbilityRageCost(self, ability)
|
||||
local customRageCost = math.max(
|
||||
0,
|
||||
math.floor(ability:GetSpecialValueFor("rage_cost"))
|
||||
)
|
||||
if customRageCost > 0 then
|
||||
return customRageCost
|
||||
end
|
||||
return math.max(
|
||||
0,
|
||||
math.floor(ability:GetManaCost(ability:GetLevel()))
|
||||
)
|
||||
end
|
||||
____exports.canCastRageNoTarget = function(____, ability)
|
||||
if not IsServer() then
|
||||
return UF_SUCCESS
|
||||
end
|
||||
local caster = ability:GetCaster()
|
||||
local cost = ____exports.getAbilityRageCost(nil, ability)
|
||||
if cost <= 0 then
|
||||
return UF_SUCCESS
|
||||
end
|
||||
if ability:IsChanneling() then
|
||||
return UF_SUCCESS
|
||||
end
|
||||
local ____temp_0
|
||||
if heroRageGetCurrent(nil, caster) < cost then
|
||||
____temp_0 = UF_FAIL_CUSTOM
|
||||
else
|
||||
____temp_0 = UF_SUCCESS
|
||||
end
|
||||
return ____temp_0
|
||||
end
|
||||
____exports.canCastRageErrorNoTarget = function(____, ability)
|
||||
if not IsServer() then
|
||||
return ""
|
||||
end
|
||||
local caster = ability:GetCaster()
|
||||
local cost = ____exports.getAbilityRageCost(nil, ability)
|
||||
if cost <= 0 then
|
||||
return ""
|
||||
end
|
||||
if ability:IsChanneling() then
|
||||
return ""
|
||||
end
|
||||
return heroRageGetCurrent(nil, caster) < cost and "#dota_hud_error_havent_charges" or ""
|
||||
end
|
||||
____exports.canCastRageTarget = function(____, ability, target)
|
||||
local rage = ____exports.canCastRageNoTarget(nil, ability)
|
||||
if rage ~= UF_SUCCESS then
|
||||
return rage
|
||||
end
|
||||
if not IsServer() then
|
||||
return UF_SUCCESS
|
||||
end
|
||||
local caster = ability:GetCaster()
|
||||
return UnitFilter(
|
||||
target,
|
||||
ability:GetAbilityTargetTeam(),
|
||||
ability:GetAbilityTargetType(),
|
||||
ability:GetAbilityTargetFlags(),
|
||||
caster:GetTeamNumber()
|
||||
)
|
||||
end
|
||||
--- Базовый класс для способностей с расходом ярости (проверка без таргета / точки). Не регистрируется как отдельная ability — только наследование.
|
||||
____exports.RageAbilityNoTarget = __TS__Class()
|
||||
local RageAbilityNoTarget = ____exports.RageAbilityNoTarget
|
||||
RageAbilityNoTarget.name = "RageAbilityNoTarget"
|
||||
RageAbilityNoTarget.____file_path = "scripts/vscripts/abilities/system/rage_ability.lua"
|
||||
__TS__ClassExtends(RageAbilityNoTarget, BaseAbility)
|
||||
function RageAbilityNoTarget.prototype.CastFilterResult(self)
|
||||
return ____exports.canCastRageNoTarget(nil, self)
|
||||
end
|
||||
function RageAbilityNoTarget.prototype.GetCustomCastError(self)
|
||||
return ____exports.canCastRageErrorNoTarget(nil, self)
|
||||
end
|
||||
--- Базовый класс для способностей с расходом ярости по юниту-цели.
|
||||
____exports.RageAbilityTarget = __TS__Class()
|
||||
local RageAbilityTarget = ____exports.RageAbilityTarget
|
||||
RageAbilityTarget.name = "RageAbilityTarget"
|
||||
RageAbilityTarget.____file_path = "scripts/vscripts/abilities/system/rage_ability.lua"
|
||||
__TS__ClassExtends(RageAbilityTarget, BaseAbility)
|
||||
function RageAbilityTarget.prototype.CastFilterResultTarget(self, target)
|
||||
return ____exports.canCastRageTarget(nil, self, target)
|
||||
end
|
||||
function RageAbilityTarget.prototype.GetCustomCastErrorTarget(self, _target)
|
||||
return ____exports.canCastRageErrorNoTarget(nil, self)
|
||||
end
|
||||
--- Базовый класс для способностей с расходом ярости по точке.
|
||||
____exports.RageAbilityPoint = __TS__Class()
|
||||
local RageAbilityPoint = ____exports.RageAbilityPoint
|
||||
RageAbilityPoint.name = "RageAbilityPoint"
|
||||
RageAbilityPoint.____file_path = "scripts/vscripts/abilities/system/rage_ability.lua"
|
||||
__TS__ClassExtends(RageAbilityPoint, BaseAbility)
|
||||
function RageAbilityPoint.prototype.CastFilterResultLocation(self)
|
||||
return ____exports.canCastRageNoTarget(nil, self)
|
||||
end
|
||||
function RageAbilityPoint.prototype.GetCustomCastErrorLocation(self)
|
||||
return ____exports.canCastRageErrorNoTarget(nil, self)
|
||||
end
|
||||
return ____exports
|
||||
Reference in New Issue
Block a user