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

want level up to give percentage of max mana/hp instead of full [TFS 1.3 8.6 downgrade by nekiro]

Silba

is stephany, the josh wife
Joined
Aug 22, 2013
Messages
458
Solutions
9
Reaction score
386
Hello, if im correct i can comment out 2 lines in the source in player.cpp

Code:
health = healthMax;
mana = manaMax;

then use an lua script to deal with adding % of max hp/mana on level up?

I want to fine tune this so having to compile every time i make a change is not acceptable.

Could someone help me with a script to add this? I've seen various scripts around the forum but didn't find any to do % health or that listed 1.x compatibility.

Thanks :)
 
C++:
health = healthMax * 0.5;
mana = manaMax * 0.5;

*0.5 = 50%
can put any value u want

Ah, ok so this would work the same in lua right? much like a spell formula?

Thanks a bunch, guess i can start working on the lua implementation now
 
Ah, ok so this would work the same in lua right? much like a spell formula?

Thanks a bunch, guess i can start working on the lua implementation now
if u want to make this formula by lua, in your source code use it
C++:
health = 0;
mana = 0;
and make a script by lua, "onAdvance"
Lua:
function onAdvance(player, skill, oldlevel, newlevel)
    if skill == SKILL_LEVEL then
        player:addHealth(player:getMaxHealth() * 0.5)
        player:addMana(player:getMaxMana() * 0.5)
    end
    return true
end
 
if u want to make this formula by lua, in your source code use it
C++:
health = 0;
mana = 0;
and make a script by lua, "onAdvance"
Lua:
function onAdvance(player, skill, oldlevel, newlevel)
    if skill == SKILL_LEVEL then
        player:addHealth(player:getMaxHealth() * 0.5)
        player:addMana(player:getMaxMana() * 0.5)
    end
    return true
end

Oh right, thank you so much for the script, can't wait to try it
 
if u want to make this formula by lua, in your source code use it
C++:
health = 0;
mana = 0;
and make a script by lua, "onAdvance"
Lua:
function onAdvance(player, skill, oldlevel, newlevel)
    if skill == SKILL_LEVEL then
        player:addHealth(player:getMaxHealth() * 0.5)
        player:addMana(player:getMaxMana() * 0.5)
    end
    return true
end

Had to comment out the code in player.cpp, setting it to 0 kills the character :D

C++:
//health = maxHealth;
//mana = maxMana;

With it commented out and before i add your lua code i now get 20 mana per level up (not checked hp) and im not sure why... added your lua code to global.lua and as far as i can tell it does nothing and there's no errors. :( I still only get this unexplained 20 mana per level up.

I also tried putting the code in creaturescripts but itgave an error saying "onAdvance" is not valid.
 
its from vocations.xml
Code:
    <vocation id="0" clientid="0" name="None" description="none" gaincap="10" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="1" gainmanaticks="6" gainmanaamount="1" manamultiplier="4.0" attackspeed="500" basespeed="200" soulmax="100" gainsoulticks="120" fromvoc="0">
change gainhp and gainmana to 0 and do it from creaturescripts with lua for %
 
its from vocations.xml
Code:
    <vocation id="0" clientid="0" name="None" description="none" gaincap="10" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="1" gainmanaticks="6" gainmanaamount="1" manamultiplier="4.0" attackspeed="500" basespeed="200" soulmax="100" gainsoulticks="120" fromvoc="0">
change gainhp and gainmana to 0 and do it from creaturescripts with lua for %

oh yeah that makes sense thank you, i didn't know it added to current mana on level up.

i did already try creaturescripts but since you said that's where to put it now i tried again and realised my mistake, i put event type as "onadvance" but it should be "advance".

Script seems to be working fine now, thank you so much mate.
 
oh yeah that makes sense thank you, i didn't know it added to current mana on level up.

i did already try creaturescripts but since you said that's where to put it now i tried again and realised my mistake, i put event type as "onadvance" but it should be "advance".

Script seems to be working fine now, thank you so much mate.
Don't do that, your character will not gain increased health/mana from leveling (talking about the stat itself, not healing).
 
Back
Top