164 lines
6.3 KiB
Lua
164 lines
6.3 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 ____modifier_general_hunger = require("abilities.modifiers.modifier_general_hunger")
|
|
local modifier_buff_food_slot = ____modifier_general_hunger.modifier_buff_food_slot
|
|
local modifier_general_hunger = ____modifier_general_hunger.modifier_general_hunger
|
|
local BUFF_FOOD_MAX_SLOTS = ____modifier_general_hunger.BUFF_FOOD_MAX_SLOTS
|
|
local getBuffFoodSlotCount = ____modifier_general_hunger.getBuffFoodSlotCount
|
|
local ____dota_ts_adapter = require("lib.dota_ts_adapter")
|
|
local BaseItem = ____dota_ts_adapter.BaseItem
|
|
local BaseModifier = ____dota_ts_adapter.BaseModifier
|
|
local registerAbility = ____dota_ts_adapter.registerAbility
|
|
local registerModifier = ____dota_ts_adapter.registerModifier
|
|
--- Кофе — бафф-еда: уменьшает кд способностей и ускоряет скорость каста
|
|
____exports.item_coffee = __TS__Class()
|
|
local item_coffee = ____exports.item_coffee
|
|
item_coffee.name = "item_coffee"
|
|
item_coffee.____file_path = "scripts/vscripts/items/util_items/item_coffee.lua"
|
|
__TS__ClassExtends(item_coffee, BaseItem)
|
|
function item_coffee.prototype.CastFilterResultTarget(self, target)
|
|
if IsServer() then
|
|
if not target:IsRealHero() then
|
|
return UF_FAIL_CUSTOM
|
|
end
|
|
if getBuffFoodSlotCount(nil, target) >= BUFF_FOOD_MAX_SLOTS then
|
|
return UF_FAIL_CUSTOM
|
|
end
|
|
if self:GetCurrentCharges() < self:GetInitialCharges() then
|
|
return UF_FAIL_CUSTOM
|
|
end
|
|
return UF_SUCCESS
|
|
end
|
|
return UF_SUCCESS
|
|
end
|
|
function item_coffee.prototype.GetCustomCastErrorTarget(self, target)
|
|
if IsServer() then
|
|
if not target:IsRealHero() then
|
|
return "#dota_hud_error_cheese_bad_target"
|
|
end
|
|
if getBuffFoodSlotCount(nil, target) >= BUFF_FOOD_MAX_SLOTS then
|
|
return "#dota_hud_error_ability_not_ready"
|
|
end
|
|
if self:GetCurrentCharges() < self:GetInitialCharges() then
|
|
return "#dota_hud_error_havent_charges"
|
|
end
|
|
end
|
|
return ""
|
|
end
|
|
function item_coffee.prototype.OnSpellStart(self)
|
|
local target = self:GetCursorTarget()
|
|
local item = self
|
|
if not target then
|
|
return
|
|
end
|
|
target:EmitSound("DOTA_Item.Cheese.Activate")
|
|
if target:IsRealHero() then
|
|
local buffDuration = self:GetSpecialValueFor("buff_duration")
|
|
local cooldownReduction = self:GetSpecialValueFor("cooldown_reduction")
|
|
local casttimeReduction = self:GetSpecialValueFor("casttime_reduction")
|
|
local hungerModifier = target:AddNewModifier(
|
|
self:GetCaster(),
|
|
self,
|
|
modifier_general_hunger.name,
|
|
{}
|
|
)
|
|
target:AddNewModifier(
|
|
self:GetCaster(),
|
|
self,
|
|
modifier_buff_food_slot.name,
|
|
{duration = buffDuration}
|
|
)
|
|
target:AddNewModifier(
|
|
self:GetCaster(),
|
|
self,
|
|
____exports.modifier_item_coffee_buff.name,
|
|
{duration = buffDuration, cooldown_reduction = cooldownReduction, casttime_reduction = casttimeReduction}
|
|
)
|
|
if hungerModifier then
|
|
local hunger_bonus = self:GetSpecialValueFor("hunger_bonus")
|
|
do
|
|
local i = 0
|
|
while i < hunger_bonus do
|
|
hungerModifier:IncrementStackCount()
|
|
i = i + 1
|
|
end
|
|
end
|
|
end
|
|
if item:GetCurrentCharges() <= item:GetInitialCharges() then
|
|
UTIL_Remove(item)
|
|
return
|
|
end
|
|
item:SetCurrentCharges(item:GetCurrentCharges() - item:GetInitialCharges())
|
|
end
|
|
end
|
|
item_coffee = __TS__Decorate(
|
|
item_coffee,
|
|
item_coffee,
|
|
{registerAbility(nil)},
|
|
{kind = "class", name = "item_coffee"}
|
|
)
|
|
____exports.item_coffee = item_coffee
|
|
--- Бафф от кофе: снижение кд и ускорение каста
|
|
____exports.modifier_item_coffee_buff = __TS__Class()
|
|
local modifier_item_coffee_buff = ____exports.modifier_item_coffee_buff
|
|
modifier_item_coffee_buff.name = "modifier_item_coffee_buff"
|
|
modifier_item_coffee_buff.____file_path = "scripts/vscripts/items/util_items/item_coffee.lua"
|
|
__TS__ClassExtends(modifier_item_coffee_buff, BaseModifier)
|
|
function modifier_item_coffee_buff.prototype.____constructor(self, ...)
|
|
BaseModifier.prototype.____constructor(self, ...)
|
|
self.cooldownReduction = 0
|
|
self.casttimeReduction = 0
|
|
end
|
|
function modifier_item_coffee_buff.prototype.IsHidden(self)
|
|
return false
|
|
end
|
|
function modifier_item_coffee_buff.prototype.IsPurgable(self)
|
|
return true
|
|
end
|
|
function modifier_item_coffee_buff.prototype.IsDebuff(self)
|
|
return false
|
|
end
|
|
function modifier_item_coffee_buff.prototype.GetAttributes(self)
|
|
return MODIFIER_ATTRIBUTE_MULTIPLE
|
|
end
|
|
function modifier_item_coffee_buff.prototype.GetTexture(self)
|
|
return "utils/coffee"
|
|
end
|
|
function modifier_item_coffee_buff.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_COOLDOWN_PERCENTAGE, MODIFIER_PROPERTY_CASTTIME_PERCENTAGE}
|
|
end
|
|
function modifier_item_coffee_buff.prototype.OnCreated(self, params)
|
|
if (params and params.cooldown_reduction) ~= nil then
|
|
self.cooldownReduction = params.cooldown_reduction
|
|
end
|
|
if (params and params.casttime_reduction) ~= nil then
|
|
self.casttimeReduction = params.casttime_reduction
|
|
end
|
|
local ability = self:GetAbility()
|
|
if ability then
|
|
if self.cooldownReduction == 0 then
|
|
self.cooldownReduction = ability:GetSpecialValueFor("cooldown_reduction")
|
|
end
|
|
if self.casttimeReduction == 0 then
|
|
self.casttimeReduction = ability:GetSpecialValueFor("casttime_reduction")
|
|
end
|
|
end
|
|
end
|
|
function modifier_item_coffee_buff.prototype.GetModifierPercentageCooldown(self)
|
|
return self.cooldownReduction
|
|
end
|
|
function modifier_item_coffee_buff.prototype.GetModifierPercentageCasttime(self)
|
|
return self.casttimeReduction
|
|
end
|
|
modifier_item_coffee_buff = __TS__Decorate(
|
|
modifier_item_coffee_buff,
|
|
modifier_item_coffee_buff,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_item_coffee_buff"}
|
|
)
|
|
____exports.modifier_item_coffee_buff = modifier_item_coffee_buff
|
|
return ____exports
|