ID:150024
Jan 2 2002, 7:41 pm
|
|
I can't figure out how to create a level up code that does exactly what I want it to do. Every time when the designated exp is reached it keeps adding, adding,a nd adding, and adding the stats that i want it to. i just want it to make the stats go up once not fifty million times. is there a solution?
|
In response to Nadrew
|
|
that's not exactly what I mean. what i think is wrong is that I have a proc that is called whenever my exp reaches a certain amount... well here I'll jsut put the code here and would somebody tell me what is wrong. i think it just keeps calling the levelup proc over and over cuz i dont know how to tell it to stop.
i tried it both of these ways and i think they are exactly the same just a different format... if(exp == 500) src.str+=20 and if(exp == 500) levelup() proc/levelup() src.str+=20 |
In response to Canar
|
|
Canar wrote:
that's not exactly what I mean. what i think is wrong is that I have a proc that is called whenever my exp reaches a certain amount... well here I'll jsut put the code here and would somebody tell me what is wrong. i think it just keeps calling the levelup proc over and over cuz i dont know how to tell it to stop.... if(exp == 500) Two minor problems here: First, you should use >=500, not ==500, because if exp skips past 500 then you'll forever be stuck on the same level. Second, when you level up you need some way to reset either exp or the amount needed to move to the next level; otherwise, exp>=500 will remain true and levelup() will continue to be called. if(exp >= exp_needed) I should explain some of the code I used in there. The do-while loop is so that if you happen to have gained so much exp that it's enough to skip two levels, it will. The max(exp_needed+1,formula) in there is so you don't go into an infinite loop if exp_needed*1.5 rounds to the same number every time (like if exp_needed==0); it's always going to increase by at least 1. There are other ways to handle leveling systems, but I think this should be a good place to get started. Hope this helps you. Lummox JR |
In response to Lummox JR
|
|
thanks! I finally got my strength to increase by twenty not twenty million.
|
== //exactly a number
<= //the exact number, and less
< //less than