ID:151134
 
ok heres my code :

var/list/fighterLevels = list(100, 2000, 4000, 8000, 16000)

mob
var/list/expLevelList
var/exp
var/level
var/savefile="player.sav"

New()
..()
src.expLevelList = fighterLevels
usr << "You gained [++exp]!"

proc/AddExperience(myAmount)
exp += myAmount
if(expLevelList.len >= level+1)
if(exp>=fighterLevels[level+1])
src << "You are now level [++level]!"
max_life += 1
iq += 2

every hit a player gets exp...after his exp is 100 he should get +1 to his max_life...instead nothing happens...you exp can reach 20000 and you still won't have gained a level...please help
proc/AddExperience(myAmount)
exp += myAmount
if(expLevelList.len >= level+1)
if(exp>=fighterLevels[level+1])
src << "You are now level [++level]!"
max_life += 1
iq += 2

Try putting in some debugging statements to see where the problem lies. For example, you have a line where you compare exp to fighterLevels[level+1]. So put this just above it:

world << "exp [exp] points needed [fighterLevels[level+1]]" //dbg

(I always put //dbg after my debugging lines so it's easy to find them and get rid of them later.)

I just went through about an hour of putting debugging checkpoints all through a proc, testing, and repeating. Fortunately, you shouldn't need that many here!

<small>(It turned out I'd forgotten about the built-in "waitfor" behavior... when a flamethrower hit an acid-bleeding monster, the flame that caused the damage would suddenly freeze in place until the acid had eaten through the floor!)</small>
On 3/12/01 7:40 pm Darkness wrote:
ok heres my code :
var/list/fighterLevels = list(100, 2000, 4000, 8000, 16000)

mob
var/list/expLevelList
var/exp
var/level
var/savefile="player.sav"

New()
..()
src.expLevelList = fighterLevels

proc/AddExperience(myAmount)
exp += myAmount
if(expLevelList.len >= level+1)
if(exp >= expLevelList[level+1])
src << "You are now level [++level]!"
max_life += 1
iq += 2

every hit a player gets exp...after his exp is 100 he should get +1 to his max_life...instead nothing happens...you exp can reach 20000 and you still won't have gained a level...please help

Hmm, the only thing I could find wrong with it is that you're sending output to usr in New(), which is rather pointless.

This is what it should look like when you add experience:

usr.AddExperience(src.exp)

so if you had usr attacking M, it'd be

usr.AddExperience(M.exp)

and if you had M attacking src, it'd be

M.AddExperience(src.exp)

and so on.