ID:166104
 
When my exp reaches 100 i just keep gaining it instead of it resetting. Anyone know why? It is also properly indented in the compiler it came out wrong when i pasted

 mob
proc
Levelup()
if(src.exp>=src.maxexp)//If your exp var equals, or passes your maxexp var
src.level++//Add to your level
src.exp=0//resets your exp to 0
src.maxexp*=2//makes your maxexp double
src.maxhealth*=1.2
src.Ninjutsu*=1.2
src.Genjutsu*=1.2
src.Chakra*=1.1
src.Taijutsu*=1.1
src<<"You gained a level!"
src.Statup()
else
..()//defaults if the if() doesn't return it's arguments

mob
proc
Statup()
src.maxhealth+=20//adds to your health
src.health=src.maxhealth
src<<"Your stats increase!"//Outputs a message telling you that you gained stats
//Call both of these procs in your attack process here's an example


mob
Stat()//Calls the stat proc.
..()
statpanel("Stats")//Makes a new statpanel called "Stats"
stat("Health","[health]/[maxhealth]")
stat("Experience","[exp]/[maxexp]")//Creates a new stat called "Experience" and gives it the value of "exp/maxexp"
stat("Level",level)
stat("Chakra",Chakra)
stat("Ninjutsu",Ninjutsu)
stat("Genjutsu",Genjutsu)
stat("Taijutsu",Taijutsu)

mob
var/list/moves
...
New()
..()
moves=list()
var/list/level_learned_moves=list(
"Kawarimi no jutsu"=5,//Kawarimi at Lvl 5
"Bunshin no jutsu"=10,//Ditto
"Henge no jutsu"=10)//Ditto

mob
var
health = 100//Makes a var called health and gives it the value 100
maxhealth = 100
exp = 0
maxexp = 100
level = 1
Ninjutsu = 20
Taijutsu = 20
Genjutsu = 20
Chakra = 1000



obj/Log
icon='tree log.dmi'
density=1
verb/Hit()
set src in view(1)
usr<<"You are aware of a crack in the log.."
usr.exp+=5
<dm>
Please put your codes in <dm> tags so it's readable, and do not put your text all in <b> tags.

The reasion your levelup isn't working is that you never call the proc.

You also don't need the Statup() proc. That should just be stuck in with Levelup().

Lummox JR
In response to Lummox JR (#1)
Thank you. And i had it in the tags because i thought those fixed indentation errors. Thanks for correcting me.
To call the proc would i just add Levelup() beneath the obj/log coding?
You need to make it run LevelUp() everytime you make it add EXP. You could make a GiveEXP() proc to do it.
EX:
proc/GiveEXP(n as num)
exp += n
LevelUp()


Then, instead of giving exp, you can do usr.GiveEXP(5) or something.
In response to Nejichidori (#2)
Nejichidori wrote:
Thank you. And i had it in the tags because i thought those fixed indentation errors.

Nope, those just put the text in bold.

To call the proc would i just add Levelup() beneath the obj/log coding?

No, you need to call it after you increase experience following practice/battle.

Lummox JR
In response to Lummox JR (#4)
You said i needed to call the proc after every hit of the log. (to check whether they have passed the req for the next level but how do i call the proc? If i were to use an if then statement i'd get a duplicate statement error.)
In response to Nejichidori (#5)
Nejichidori wrote:
You said i needed to call the proc after every hit of the log. (to check whether they have passed the req for the next level but how do i call the proc? If i were to use an if then statement i'd get a duplicate statement error.)

Um, no, you won't get such an error if you do it right. If what you're doing is causing a problem, post it so we can set you right.

Lummox JR
In response to Lummox JR (#6)
Well this is gonna get ugly.. Please don't laugh at meh n00bish mistakes lol. I just started seriuosly coding about 2 weeks ago.

<dm>
mob
var
health = 100//Makes a var called health and gives it the value 100
maxhealth = 100
exp = 0
maxexp = 100
level = 1
Ninjutsu = 20
Taijutsu = 20
Genjutsu = 20
Chakra = 1000






obj/Log
icon='tree log.dmi'
density=1
proc/Levelup()
verb/Hit()
set src in view(1)
usr<<"You are aware of a crack in the log.."
usr.exp+=5



mob
proc
Levelup()
if(src.exp>=src.maxexp)//If your exp var equals, or passes your maxexp var
src.level++//Add to your level
src.exp=0//resets your exp to 0
src.maxexp*=2//makes your maxexp double
src.maxhealth*=1.2
src.Ninjutsu*=1.2
src.Genjutsu*=1.2
src.Chakra*=1.1
src.Taijutsu*=1.1
src<<"You gained a level!"
src.Statup()
else
..()//defaults if the if()
<dm>

I get no errors but i still don't level up. I also have cut out some unessential stuff on this post saying that i haven't defined my vars is incorrect cause in the full coding i have.
In response to Nejichidori (#7)
You still haven't called the LevelUp Proc. You just created a proc that a Log has.

This should fix it:

obj/Log
icon='tree log.dmi'
density=1
verb/Hit()
set src in view(1)
usr<<"You are aware of a crack in the log.."
usr.exp+=5
usr.Levelup()
In response to Kalajin (#8)
Thank you very much. I just needed to know how to call the proc.