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 BaseItem = ____dota_ts_adapter.BaseItem local registerAbility = ____dota_ts_adapter.registerAbility --- Кофейные зёрна — восстанавливают ману и не занимают слоты бафф-еды ____exports.item_coffe_bean = __TS__Class() local item_coffe_bean = ____exports.item_coffe_bean item_coffe_bean.name = "item_coffe_bean" item_coffe_bean.____file_path = "scripts/vscripts/items/util_items/item_coffe_bean.lua" __TS__ClassExtends(item_coffe_bean, BaseItem) function item_coffe_bean.prototype.CastFilterResultTarget(self, target) if IsServer() then if not target:IsRealHero() 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_coffe_bean.prototype.GetCustomCastErrorTarget(self, target) if IsServer() then if not target:IsRealHero() then return "#dota_hud_error_cheese_bad_target" end if self:GetCurrentCharges() < self:GetInitialCharges() then return "#dota_hud_error_havent_charges" end end return "" end function item_coffe_bean.prototype.OnSpellStart(self) local target = self:GetCursorTarget() local item = self if not target then return end local maxMana = target:GetMaxMana() local manaPercentRestore = self:GetSpecialValueFor("mana_pct") local flatManaRestore = self:GetSpecialValueFor("mana") local manaAmount = maxMana * manaPercentRestore / 100 + flatManaRestore local currentMana = target:GetMana() local manaToGive = math.min(manaAmount, maxMana - currentMana) target:EmitSound("DOTA_Item.Cheese.Activate") if manaToGive > 0 then target:GiveMana(manaToGive) SendOverheadEventMessage( nil, OVERHEAD_ALERT_MANA_ADD, target, manaToGive, target:GetPlayerOwner() ) end if target:IsRealHero() then if item:GetCurrentCharges() <= item:GetInitialCharges() then UTIL_Remove(item) return end item:SetCurrentCharges(item:GetCurrentCharges() - item:GetInitialCharges()) end end item_coffe_bean = __TS__Decorate( item_coffe_bean, item_coffe_bean, {registerAbility(nil)}, {kind = "class", name = "item_coffe_bean"} ) ____exports.item_coffe_bean = item_coffe_bean return ____exports