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_general_hunger = __TS__Class() local modifier_general_hunger = ____exports.modifier_general_hunger modifier_general_hunger.name = "modifier_general_hunger" modifier_general_hunger.____file_path = "scripts/vscripts/abilities/modifiers/modifier_general_hunger.lua" __TS__ClassExtends(modifier_general_hunger, BaseModifier) function modifier_general_hunger.prototype.____constructor(self, ...) BaseModifier.prototype.____constructor(self, ...) self.maxstack = 100 end function modifier_general_hunger.prototype.IsHidden(self) return false end function modifier_general_hunger.prototype.IsDebuff(self) return false end function modifier_general_hunger.prototype.IsPurgable(self) return false end function modifier_general_hunger.prototype.OnCreated(self, params) if IsServer() then self:SetDuration(3.01, true) self:StartIntervalThink(3) end end function modifier_general_hunger.prototype.OnRefresh(self, params) if IsServer() then self:SetDuration(3.01, true) self:StartIntervalThink(3) end end function modifier_general_hunger.prototype.OnIntervalThink(self) if IsServer() then self:SetStackCount(self:GetStackCount() - 1) self:SetDuration(3.01, true) if self:GetStackCount() < 1 then self:Destroy() end end end function modifier_general_hunger.prototype.DeclareFunctions(self) return {MODIFIER_PROPERTY_STATS_AGILITY_BONUS, MODIFIER_PROPERTY_STATS_INTELLECT_BONUS, MODIFIER_PROPERTY_STATS_STRENGTH_BONUS} end function modifier_general_hunger.prototype.GetModifierBonusStats_Strength(self) if not IsServer() then return 0 end local parent = self:GetParent() if not parent then return 0 end if not parent:IsRealHero() then return 0 end do local function ____catch(e) return true, 0 end local ____try, ____hasReturned, ____returnValue = pcall(function() local hero = parent local baseStr = hero:GetBaseStrength() or 0 return true, math.ceil(baseStr * (self:GetStackCount() * 0.01)) end) if not ____try then ____hasReturned, ____returnValue = ____catch(____hasReturned) end if ____hasReturned then return ____returnValue end end end function modifier_general_hunger.prototype.GetModifierBonusStats_Agility(self) if not IsServer() then return 0 end local parent = self:GetParent() if not parent then return 0 end if not parent:IsRealHero() then return 0 end local hero = parent local baseAgi = hero:GetBaseAgility() return math.ceil(baseAgi * (self:GetStackCount() * 0.01)) end function modifier_general_hunger.prototype.GetModifierBonusStats_Intellect(self) if not IsServer() then return 0 end local parent = self:GetParent() if not parent then return 0 end if not parent:IsRealHero() then return 0 end do local function ____catch(e) return true, 0 end local ____try, ____hasReturned, ____returnValue = pcall(function() local hero = parent local baseInt = hero:GetBaseIntellect() or 0 return true, math.ceil(baseInt * (self:GetStackCount() * 0.01)) end) if not ____try then ____hasReturned, ____returnValue = ____catch(____hasReturned) end if ____hasReturned then return ____returnValue end end end function modifier_general_hunger.prototype.IncrementStackCount(self) if self:GetStackCount() >= self.maxstack then self:SetStackCount(self.maxstack) else BaseModifier.prototype.SetStackCount( self, self:GetStackCount() + 1 ) end end function modifier_general_hunger.prototype.GetTexture(self) return "life_stealer_rage" end modifier_general_hunger = __TS__Decorate( modifier_general_hunger, modifier_general_hunger, {registerModifier(nil)}, {kind = "class", name = "modifier_general_hunger"} ) ____exports.modifier_general_hunger = modifier_general_hunger --- Несколько экземпляров на юните — у каждого свой таймер (каждый приём пищи живёт 60 сек). ____exports.modifier_general_hunger_fulled = __TS__Class() local modifier_general_hunger_fulled = ____exports.modifier_general_hunger_fulled modifier_general_hunger_fulled.name = "modifier_general_hunger_fulled" modifier_general_hunger_fulled.____file_path = "scripts/vscripts/abilities/modifiers/modifier_general_hunger.lua" __TS__ClassExtends(modifier_general_hunger_fulled, BaseModifier) function modifier_general_hunger_fulled.prototype.IsHidden(self) return false end function modifier_general_hunger_fulled.prototype.IsDebuff(self) return false end function modifier_general_hunger_fulled.prototype.IsPurgable(self) return false end function modifier_general_hunger_fulled.prototype.GetAttributes(self) return MODIFIER_ATTRIBUTE_MULTIPLE end function modifier_general_hunger_fulled.prototype.OnCreated(self, params) if IsServer() then local duration = params.duration or 60 self:SetDuration(duration, true) end end modifier_general_hunger_fulled = __TS__Decorate( modifier_general_hunger_fulled, modifier_general_hunger_fulled, {registerModifier(nil)}, {kind = "class", name = "modifier_general_hunger_fulled"} ) ____exports.modifier_general_hunger_fulled = modifier_general_hunger_fulled --- Максимум «слотов» сытости для еды с баффами (энерго-напиток и т.п.). Каждый слот = один приём, свой таймер 60 сек. ____exports.BUFF_FOOD_MAX_SLOTS = 3 --- Слот сытости от еды с баффами. Вешается только такими предметами (energy_drink и т.д.). Лимит BUFF_FOOD_MAX_SLOTS штук. ____exports.modifier_buff_food_slot = __TS__Class() local modifier_buff_food_slot = ____exports.modifier_buff_food_slot modifier_buff_food_slot.name = "modifier_buff_food_slot" modifier_buff_food_slot.____file_path = "scripts/vscripts/abilities/modifiers/modifier_general_hunger.lua" __TS__ClassExtends(modifier_buff_food_slot, BaseModifier) function modifier_buff_food_slot.prototype.IsHidden(self) return true end function modifier_buff_food_slot.prototype.IsDebuff(self) return false end function modifier_buff_food_slot.prototype.IsPurgable(self) return false end function modifier_buff_food_slot.prototype.GetAttributes(self) return MODIFIER_ATTRIBUTE_MULTIPLE end function modifier_buff_food_slot.prototype.OnCreated(self, params) if IsServer() then local duration = params.duration or 60 self:SetDuration(duration, true) end end function modifier_buff_food_slot.prototype.GetTexture(self) return "life_stealer_rage" end modifier_buff_food_slot = __TS__Decorate( modifier_buff_food_slot, modifier_buff_food_slot, {registerModifier(nil)}, {kind = "class", name = "modifier_buff_food_slot"} ) ____exports.modifier_buff_food_slot = modifier_buff_food_slot --- Считает, сколько слотов бафф-еды сейчас на юните (для проверки лимита). function ____exports.getBuffFoodSlotCount(self, unit) local count = 0 do local i = 0 while i < unit:GetModifierCount() do if unit:GetModifierNameByIndex(i) == ____exports.modifier_buff_food_slot.name then count = count + 1 end i = i + 1 end end return count end return ____exports