• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

HP/Mana regeneration by level %

bergamoth

Member
Joined
Jul 26, 2021
Messages
24
Solutions
2
Reaction score
14
Hey guys, super noob here.

Is it possible to set hp/mana regen as a % of player level?

Thx in advance <3
 
Solution
WOOT!!! Found a way!! It works!

It's the formula of FOOD inside data/core/lib/player.lua

This simple solution sets the mana regen to be MAX MANA divided by 20, you can also set by Player Level, skill, ML or whatever you wish.

Lua:
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...
So, i'm trying to change the values here, am i in the correct place?

in condition.cpp

{
if (updateCondition(addCondition)) {
setTicks(addCondition->getTicks());

const ConditionRegeneration& conditionRegen = static_cast<const ConditionRegeneration&>(*addCondition);

healthTicks = conditionRegen.healthTicks;
manaTicks = conditionRegen.manaTicks;

healthGain = conditionRegen.healthGain+((Player::level) / 100);
manaGain = conditionRegen.manaGain;
}

if (Player* player = creature->getPlayer()) {
player->sendStats();

I'm sure the formula i'm trying for level is wrong tho.
 
Well, i decided to tacle it from a different direction.. by doing it thru LUA..

Managed to find where the food regen is done, i'm guessing i can do it here, but i'm f***ng something up still!

Here's what i got, 0 errors in console but mana won't regen ingame (testing first with mana).



Lua:
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_MANATICKS, vocation:getManaGainTicks() * 1000)
        
function Player.feed(creature, var, self, food)
    local player = creature:getPlayer()
    if player then
        local min = (player:getMaxMana() * 0.01)
        local max = (player:getMaxMana() * 0.02)
        foodCondition:setParameter(CONDITION_PARAM_MANAGAIN, math.random(min, max))
    end
    return true
  end       

        self:addCondition(foodCondition)
    end
    return true
end
 
WOOT!!! Found a way!! It works!

It's the formula of FOOD inside data/core/lib/player.lua

This simple solution sets the mana regen to be MAX MANA divided by 20, you can also set by Player Level, skill, ML or whatever you wish.

Lua:
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, math.min(self:getMaxHealth() / 20))
        foodCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, vocation:getHealthGainTicks() * 1000)
        foodCondition:setParameter(CONDITION_PARAM_MANAGAIN, math.min(self:getMaxMana() / 20))
        foodCondition:setParameter(CONDITION_PARAM_MANATICKS, vocation:getManaGainTicks() * 1000)

        self:addCondition(foodCondition)
    end
    return true
end
 
Solution
Back
Top