Hello all, I was justy wondering on how I would go about making a level system in an action/rpg game. I have some code for it now, but I am not sure on how to actually level the character when I get the gven amount of experience and to reset the exp needed to 0.
I used Zilal's tutorial, so I have whatever she had on it.
How I thought I would go about leveling is like, when I would get the exp needed to level iot would call a proc, like Level() then it would add the stats, and reset how much exp I have for the next level and add the next amount.
So like....
//for a warrior class or something.
Level()
Str += rand(4,8)
Int += rand(1,2)
And stuff like that. Well, that part is just the level proc for the warrior, I would need to know how to call it. So like I would make an exp variable, and somehow make it where when I get the needed amount of exp it calls the proc then i get the stats and stuff.
Well sorry for the noobish request there :p Thanks for the help in advance :D
ID:163124
Oct 8 2007, 6:57 am
|
|
A typical way to handle leveling up is to put everything, even the exp check, in the same proc. That isn't strictly necessary but it doesn't hurt. Then you can call this any time experience changes.
mob/proc/Levelup() Lummox JR |
In response to KirbyAllStar
|
|
Okay, so how would I go about making the person require more exp for each level? Like if I had him need 100 to transgress to level 2 and then like 120 to 3 then what would I code in for that?
So for the levelcheck thing I would code it similar to DeathCheck() kk, thanks KirbyAllStar :D |
ill help!
mob i hope that helps, plus the exp-=max_exp helps if you want people to get multiple levels if they have enough exp. |
In response to VolksBlade
|
|
I think I got this now, so would I make a maxxp var as well? and have the exp added go into that var?
Oh, and thanks sooo much guys :) This project I am on now is like my mnake or break for my drive to want to code games :p and so far it is going really well. You will probably see me more frequently in the next few days with newbie coding questions again XD |
In response to VolksBlade
|
|
VolksBlade wrote:
if(src.class=="Warrior") That's horribly wrong. Never ever have a proc call itself unless 1) you use spawn() or 2) recursion is actually intentional (i.e., to break a problem like sorting into smaller problems). In this case a while() loop instead of an if() statement at the beginning is the correct choice. Lummox JR |
In response to Lummox JR
|
|
So then I could use Volk's Code but put a while() in front of the class name?
~Well, my lunch just ended, gotta go to class. Again, Thank you guys SOO much for the help :) I will be back around 4. Expect to see me more XD |
In response to Blanke
|
|
Blanke wrote:
So then I could use Volk's Code but put a while() in front of the class name? Not quite. You want while() in place of the first if(), not the others. If you take out his repeat calls to Levelup() and the return after each one, and then change the first if() to a while(), you should be all set. Lummox JR |
In response to Lummox JR
|
|
mob Like so? |
In response to VolksBlade
|
|
You're still returning out of each if() for no reason, which defeats the purpose of the while() loop.
Lummox JR |
In response to Lummox JR
|
|
So then use his code but take the returns out and keep the while there and the ifs?
|
In response to Blanke
|
|
Well, I know I need to make a class variable, then I need to assign the classes to that variable. so like would I make the variable called class then make the stuff within the var the classes?
Like var Class Warrior Str = 2 etc etc Or some other way? Cuz tonight I want to add the classes and their stats in with the stat panel showing the stats. (I can look on Xerse's code for that, I don't know how efficient his code is, I heard it was pretty crappy bnut I guess thats what I have to work with :p |
In response to Blanke
|
|
id do this
var class other vars you need here then id do this at login mob Login() src.class=input("Which class would you like to be","Class") in list("class1","class2","class3") and so on then if(src.class=="class1") class stats here that might be a crappy way of doing it and Lummox may have a better way but thats pretty much how i start off before i get too involved into the save/load/delete system |
In response to Blanke
|
|
Blanke wrote:
Okay, so how would I go about making the person require more exp for each level? Like if I had him need 100 to transgress to level 2 and then like 120 to 3 then what would I code in for that? expmax = expmax * 1.5 |
In response to Fusioneko
|
|
Okay thanks for all of the help guys :) After I tackle the classes tonight and get the displays going and stuff I will probably work on making the monsters move and attack back. Which I also made a thread about but no one posted in it :p :(
|
In response to Blanke
|
|
Hey, I got it where you can choose the class in the beginning =D I am working on getting the stats straightened out right now. ~Update~ I have it now where I have the icons for the class!! I guess when I was editing code I deleted the
mob icon = "(icons file name) part. So then I put players.dmi there. then I put the class stuff. if(src.Class=="Caller") HP = 30 MP = 10 Str = 1 Int = 1 Agi = 1 (the stats are 1 for End = 1 (because they dont do Luk = 1 (anything yet :p) Exp = 0 Exp_Needed = 100 icon_state = "Mage2" |
Or you could put it all in Level() but that might be sloppy depending on how you do it.