mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-10-15 15:04:53 +02:00
Full Distribution
This commit is contained in:
99
data/lib/core/player.lua
Normal file
99
data/lib/core/player.lua
Normal file
@@ -0,0 +1,99 @@
|
||||
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: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.isNoVocation(self)
|
||||
return self:getVocation():getId() == 0
|
||||
end
|
||||
|
||||
function Player.isSorcerer(self)
|
||||
return self:getVocation():getId() == 1 or self:getVocation():getId() == 5
|
||||
end
|
||||
|
||||
function Player.isDruid(self)
|
||||
return self:getVocation():getId() == 2 or self:getVocation():getId() == 6
|
||||
end
|
||||
|
||||
function Player.isPaladin(self)
|
||||
return self:getVocation():getId() == 3 or self:getVocation():getId() == 7
|
||||
end
|
||||
|
||||
function Player.isKnight(self)
|
||||
return self:getVocation():getId() == 4 or self:getVocation():getId() == 8
|
||||
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
|
Reference in New Issue
Block a user