[solved]basic leveling system help

D

Daripa

Guest
so I run this code and if my lvl increases my hp doesn't :/
can someone explain the logic behind this

///global
//lvl
global.lvl =1;
//player hitpoints
global.hp =100*global.lvl*1.25;
global.hpmax =100*global.lvl*1.25;

//EXP
global.ex =0;
global.exmax =100*global.lvl*1.25;

//player Damage
global.dmg = 50*global.lvl

// enemy.hitpoints
global.enemyhp = 1.25*global.lvl
 
D

Daripa

Guest
lol i found the problem.. everything was in a create event, i had to move global.lvl into a step event..
 
Last edited by a moderator:
D

Daripa

Guest
well that didnt work exactly now my hp scales with my lvl but it cnt decrease :/
 
A

arirish

Guest
It can't decrease because it's constantly being set to hpmax here:
Code:
global.hp =100*global.lvl*1.25;
You need to break your code up into what needs to be set at the start (Create event), what needs to be checked constantly (Step), and what needs to happen when you hit a level up (probably also Step, but with some additional checks)
 
D

Daripa

Guest
ill have to rethink this and incorporate a 2nd variable so i can run it in a step event :/
 
A

arirish

Guest
You can chuck all that back in the Create event, and then in the Step event put (I think...):
Code:
if global.ex=global.exmax
{
global.lvl++;
global.hp=global.hpmax;

global.exmax =100*global.lvl*1.25;
global.hpmax =100*global.lvl*1.25;
}
 
D

Daripa

Guest
You can chuck all that back in the Create event, and then in the Step event put (I think...):
Code:
if global.ex=global.exmax
{
global.lvl++;
global.hp=global.hpmax;

global.exmax =100*global.lvl*1.25;
global.hpmax =100*global.lvl*1.25;
}
thank you that worked :)
just had to add global.hpmax =100*global.lvl*1.25; before
global.hp=global.hpmax;
and global.ex=0
aswell as everything else to do with lvl
 
Last edited by a moderator:
Top