Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local foodCondition = Condition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
- function Player.feed(self, food)
- local condition = self:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
- if condition then
- condition:setTicks(condition:getTicks() + (food * 1000))
- else
- local vocation = self:getVocation()
- if not vocation then
- return nil
- end
- foodCondition:setTicks(food * 1000)
- foodCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, vocation:getHealthGainAmount())
- foodCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, vocation:getHealthGainTicks() * 1000)
- foodCondition:setParameter(CONDITION_PARAM_MANAGAIN, vocation:getManaGainAmount())
- foodCondition:setParameter(CONDITION_PARAM_MANATICKS, vocation:getManaGainTicks() * 1000)
- self:addCondition(foodCondition)
- end
- return true
- end
- function Player.getClosestFreePosition(self, position, extended)
- if self:getGroup():getAccess() and self:getAccountType() >= ACCOUNT_TYPE_GOD then
- return position
- end
- return Creature.getClosestFreePosition(self, position, extended)
- end
- function Player.getDepotItems(self, depotId)
- return self:getDepotChest(depotId, true):getItemHoldingCount()
- end
- function Player.hasFlag(self, flag)
- return self:getGroup():hasFlag(flag)
- end
- local lossPercent = {
- [0] = 100,
- [1] = 70,
- [2] = 45,
- [3] = 25,
- [4] = 10,
- [5] = 0
- }
- function Player.getLossPercent(self)
- local blessings = 0
- for i = 1, 5 do
- if self:hasBlessing(i) then
- blessings = blessings + 1
- end
- end
- return lossPercent[blessings]
- end
- function Player.isPremium(self)
- return self:getPremiumDays() > 0 or configManager.getBoolean(configKeys.FREE_PREMIUM)
- end
- function Player.sendCancelMessage(self, message)
- if type(message) == "number" then
- message = Game.getReturnMessage(message)
- end
- return self:sendTextMessage(MESSAGE_STATUS_SMALL, message)
- end
- function Player.isUsingOtClient(self)
- return self:getClient().os >= CLIENTOS_OTCLIENT_LINUX
- end
- function Player.sendExtendedOpcode(self, opcode, buffer)
- if not self:isUsingOtClient() then
- return false
- end
- local networkMessage = NetworkMessage()
- networkMessage:addByte(0x32)
- networkMessage:addByte(opcode)
- networkMessage:addString(buffer)
- networkMessage:sendToPlayer(self)
- networkMessage:delete()
- return true
- end
- APPLY_SKILL_MULTIPLIER = true
- local addSkillTriesFunc = Player.addSkillTries
- function Player.addSkillTries(...)
- APPLY_SKILL_MULTIPLIER = false
- local ret = addSkillTriesFunc(...)
- APPLY_SKILL_MULTIPLIER = true
- return ret
- end
- local addManaSpentFunc = Player.addManaSpent
- function Player.addManaSpent(...)
- APPLY_SKILL_MULTIPLIER = false
- local ret = addManaSpentFunc(...)
- APPLY_SKILL_MULTIPLIER = true
- return ret
- end
- function Player.getExhaustion(self, value)
- local storage = self:getStorageValue(value)
- if storage <= 0 then
- return 0
- end
- return storage - os.time()
- end
- function Player.depositMoney(self, amount)
- if not self:removeMoney(amount) then
- return false
- end
- self:setBankBalance(self:getBankBalance() + amount)
- return true
- end
- function Player.setExhaustion(self, value, time)
- return self:setStorageValue(value, time + os.time())
- end
- function Player.withdrawMoney(self, amount)
- local balance = self:getBankBalance()
- if amount > balance or not self:addMoney(amount) then
- return false
- end
- self:setBankBalance(balance - amount)
- return true
- end
- function Player.isDruid(self)
- return isInArray({2, 6}, self:getVocation():getId())
- end
- function Player.isKnight(self)
- return isInArray({4, 8}, self:getVocation():getId())
- end
- function Player.isPaladin(self)
- return isInArray({3, 7}, self:getVocation():getId())
- end
- function Player.isMage(self)
- return isInArray({1, 2, 5, 6}, self:getVocation():getId())
- end
- function Player.isSorcerer(self)
- return isInArray({1, 5}, self:getVocation():getId())
- end
- function Player.getCookiesDelivered(self)
- local storage, amount = {
- Storage.WhatAFoolishQuest.CookieDelivery.SimonTheBeggar,
- Storage.WhatAFoolishQuest.CookieDelivery.Markwin,
- Storage.WhatAFoolishQuest.CookieDelivery.Ariella,
- Storage.WhatAFoolishQuest.CookieDelivery.Hairycles,
- Storage.WhatAFoolishQuest.CookieDelivery.Djinn,
- Storage.WhatAFoolishQuest.CookieDelivery.AvarTar,
- Storage.WhatAFoolishQuest.CookieDelivery.OrcKing,
- Storage.WhatAFoolishQuest.CookieDelivery.Lorbas,
- Storage.WhatAFoolishQuest.CookieDelivery.Wyda,
- Storage.WhatAFoolishQuest.CookieDelivery.Hjaern
- }, 0
- for i = 1, #storage do
- if self:getStorageValue(storage[i]) == 1 then
- amount = amount + 1
- end
- end
- return amount
- end
Add Comment
Please, Sign In to add comment