• 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!

Increase maximum health per storage

felipemko

New Member
Joined
Mar 2, 2010
Messages
173
Reaction score
3
Hi everyone,
Can you guys help me?

I need something like a player gain % of maximum health per value of storage.

Example:
Each value of storage add 5% of maximum health

So a player with value 7 of storage gain 35% more health

Player normal health: 100
Player with 7 of storage: 135 (100+35% above maximum health)

@heba can you help me with this too?
 
Solution
I sent for you in private
in player.cpp add this
Lua:
int32_t Player::gethealthbouns() const
{
int32_t healthbouns = 0;
std::string value;
getStorage("218984", value);
if (value != "-1")
{
healthbouns = atoi(value.c_str());
}

    return healthbouns*5;
}
after getArmor()

and in function addExperience change this
Code:
healthMax += vocation->getGain(GAIN_HEALTH);
        health += vocation->getGain(GAIN_HEALTH);
        manaMax += vocation->getGain(GAIN_MANA);
        mana += vocation->getGain(GAIN_MANA);
to
Code:
uint32_t bouns = healthMax*gethealthbouns()/100;       
 healthMax += vocation->getGain(GAIN_HEALTH)+bouns ;
        health += vocation->getGain(GAIN_HEALTH)+bouns ;
        manaMax +=...
in login.lua use this
Lua:
    local storagebouns = getCreatureStorage(cid, 359453) -- you can change for ur storage here
    local bounshealth = getCreatureMaxHealth(cid) *(storagebouns*5)/100 
   local bounsmana = getCreatureMaxMana(cid) *(storagebouns*5)/100 
local power = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(power, CONDITION_PARAM_TICKS, -1)
setConditionParam(power, CONDITION_PARAM_STAT_MAXHEALTH, bounshealth ) -- Health
setConditionParam(power, CONDITION_PARAM_STAT_MAXMANA, bounsmana ) --- Mana

if getCreatureStorage(cid, 359453) >= 1 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You got "..bounshealth.." Health and "..bounsmana .." Mana.")
        doAddCondition(cid,power)
    end
 
Last edited:
in login.lua use this
Lua:
    local storagebouns = getCreatureStorage(cid, 359453) -- you can change for ur storage here
    local bounshealth = getCreatureMaxHealth(cid) *(storagebouns*5)/100
   local bounsmana = getCreatureMaxMana(cid) *(storagebouns*5)/100
local power = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(power, CONDITION_PARAM_TICKS, -1)
setConditionParam(power, CONDITION_PARAM_STAT_MAXHEALTH, bounshealth ) -- Health
setConditionParam(power, CONDITION_PARAM_STAT_MAXMANA, bounsmana ) --- Mana

if getCreatureStorage(cid, 359453) >= 1 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You got "..bounshealth.." Health and "..bounsmana .." Mana.")
        doAddCondition(cid,power)
    end

The problem is player must re-log each time up level to update the bonus.
 
Exactly... The idea is every time player advance level the maximum health update with bonus
@heba @Acubens
Lua:
local function Back(cid)
    if(isPlayer(cid)) then
local storagebouns = getCreatureStorage(cid, 359453) -- you can change for ur storage here
local bounshealth = getCreatureMaxHealth(cid) *(storagebouns*5)/100
local bounsmana = getCreatureMaxMana(cid) *(storagebouns*5)/100

local power = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(power, CONDITION_PARAM_TICKS, -1)
setConditionParam(power, CONDITION_PARAM_STAT_MAXHEALTH, bounshealth ) -- Health
setConditionParam(power, CONDITION_PARAM_STAT_MAXMANA, bounsmana ) --- Mana

doAddCondition(cid,power)
    end
    return true
end

function onAdvance(cid, skill, oldlevel, newlevel)
local statvalue = 1
local statkey = 359453
local getstat = getCreatureStorage(cid, statkey)
if skill == SKILL__LEVEL then
doCreatureSetStorage(cid, statkey,math.max(0,getstat+statvalue))
addEvent(Back,1000,cid)   
    end
return true
end

but u must use login script too because if player logout will lose his bouns
edit
best way is login because
if player logout will lose bouns and when login again will get bouns
when advanced level will get bouns (his maxhealth+ bouns he got when login) you understand me ??
i know my english not good but i try to expalin for you how this system work
 
Last edited:
Lua:
local function Back(cid)
    if(isPlayer(cid)) then
local storagebouns = getCreatureStorage(cid, 359453) -- you can change for ur storage here
local bounshealth = getCreatureMaxHealth(cid) *(storagebouns*5)/100
local bounsmana = getCreatureMaxMana(cid) *(storagebouns*5)/100

local power = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(power, CONDITION_PARAM_TICKS, -1)
setConditionParam(power, CONDITION_PARAM_STAT_MAXHEALTH, bounshealth ) -- Health
setConditionParam(power, CONDITION_PARAM_STAT_MAXMANA, bounsmana ) --- Mana

doAddCondition(cid,power)
    end
    return true
end

function onAdvance(cid, skill, oldlevel, newlevel)
local statvalue = 1
local statkey = 359453
local getstat = getCreatureStorage(cid, statkey)
if skill == SKILL__LEVEL then
doCreatureSetStorage(cid, statkey,math.max(0,getstat+statvalue))
addEvent(Back,1000,cid)   
    end
return true
end

but u must use login script too because if player logout will lose his bouns

Idk why but i'm losing life like a curse and didnt add the bonus
 
because ur storage is too high
look to my last reply i edit it

My storage is 378378 is a problem?

I understand but when login didnt got bonus, I tested without storage and with 1 storage and the health is the same

And where are u from? Maybe be the same my english isnt good too

To message appears:
12:32 You got 1371.65 Health and 420.1 Mana.

But i'm with the same health without storage
 
My storage is 378378 is a problem?

I understand but when login didnt got bonus, I tested without storage and with 1 storage and the health is the same

And where are u from? Maybe be the same my english isnt good too

To message appears:
12:32 You got 1371.65 Health and 420.1 Mana.

But i'm with the same health without storage
try to change ur storage to 10-20 this system work with me
and im from egypt
 
i don't see anything bad in script check how u setup the scripts again

I added in login.lua:

Lua:
local storagebouns = getCreatureStorage(cid, 20) -- you can change for ur storage here
    local bounshealth = getCreatureMaxHealth(cid) *(storagebouns*5)/100
    local bounsmana = getCreatureMaxMana(cid) *(storagebouns*5)/100
    local power = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(power, CONDITION_PARAM_TICKS, -1)
    setConditionParam(power, CONDITION_PARAM_STAT_MAXHEALTH, bounshealth ) -- Health
    setConditionParam(power, CONDITION_PARAM_STAT_MAXMANA, bounsmana ) --- Mana

    if getCreatureStorage(cid, 20) >= 1 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You got "..bounshealth.." Health and "..bounsmana .." Mana.")
        doAddCondition(cid,power)
    end

In a new creaturescript and add in creaturescripts.xml with advance
<event type="advance" name="bonus" event="script" value="bonus.lua"/>:

Code:
local function Back(cid)
    if(isPlayer(cid)) then
local storagebouns = getCreatureStorage(cid, 20) -- you can change for ur storage here
local bounshealth = getCreatureMaxHealth(cid) *(storagebouns*5)/100
local bounsmana = getCreatureMaxMana(cid) *(storagebouns*5)/100

local power = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(power, CONDITION_PARAM_TICKS, -1)
setConditionParam(power, CONDITION_PARAM_STAT_MAXHEALTH, bounshealth ) -- Health
setConditionParam(power, CONDITION_PARAM_STAT_MAXMANA, bounsmana ) --- Mana

doAddCondition(cid,power)
    end
    return true
end

function onAdvance(cid, skill, oldlevel, newlevel)
local statvalue = 1
local statkey = 20
local getstat = getCreatureStorage(cid, statkey)
if skill == SKILL__LEVEL then
doCreatureSetStorage(cid, statkey,math.max(0,getstat+statvalue))
addEvent(Back,1000,cid)   
    end
return true
end
 
Back
Top