experience system

GameBoy
this is what i tried....

define room <Arena>
east <fighters guild>
command </a monster> {
msg <you attacked |bmonster|xb with your bare hands for |b16|xb points of damage, killing it.>
conceal <monster>
inc <experience; 2001>
}

define object <monster>
end define

end define

define room <fighters guild>
west <Arena>
command </levelup> {
if ( %experience% >= 0 ) and ( %experience% < 800 ) then set <%level%; 1> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 800 ) and ( %experience% < 2000 ) then set <%level%; 2> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 2000 ) and ( %experience% < 4000 ) then set <%level%; 3> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 4000 ) and ( %experience% < 8000 ) then set <%level%; 4> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 8000 ) and ( %experience% < 15000 ) then set <%level%; 5> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 15000 ) and ( %experience% < 25000 ) then set <%level%; 6> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 25000 ) and ( %experience% < 40000 ) then set <%level%; 7> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 40000 ) and ( %experience% < 70000 ) then set <%level%; 8> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 70000 ) and ( %experience% < 120000 ) then set <%level%; 9> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 120000 ) and ( %experience% < 190000 ) then set <%level%; 10> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 190000 ) and ( %experience% < 300000 ) then set <%level%; 11> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 300000 ) and ( %experience% < 480000 ) then set <%level%; 12> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 480000 ) and ( %experience% < 750000 ) then set <%level%; 13> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 750000 ) and ( %experience% < 1100000 ) then set <%level%; 14> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 1100000 ) and ( %experience% < 1700000 ) then set <%level%; 15> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 1700000 ) and ( %experience% < 2600000 ) then set <%level%; 16> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 2600000 ) and ( %experience% < 3800000 ) then set <%level%; 17> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 3800000 ) and ( %experience% < 5600000 ) then set <%level%; 18> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 5600000 ) and ( %experience% < 8200000 ) then set <%level%; 19> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 8200000 ) and ( %experience% < 12000000 ) then set <%level%; 20> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 12000000 ) and ( %experience% < 17000000 ) then set <%level%; 21> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 17000000 ) and ( %experience% < 24000000 ) then set <%level%; 22> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 24000000 ) and ( %experience% < 35000000 ) then set <%level%; 23> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 35000000 ) and ( %experience% < 49000000 ) then set <%level%; 24> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 49000000 ) and ( %experience% < 68000000 ) then set <%level%; 25> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 68000000 ) and ( %experience% < 95000000 ) then set <%level%; 26> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 95000000 ) and ( %experience% < 130000000 ) then set <%level%; 27> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 130000000 ) and ( %experience% < 180000000 ) then set <%level%; 28> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 180000000 ) and ( %experience% < 250000000 ) then set <%level%; 29> else msg <|bYou do not have enough experience|xb>
if ( %experience% >= 250000000 ) then set <%level%; 30> else msg <|bYou do not have enough experience|xb>
msg <You have increased to |blevel %level%|xb.>
}
end define


this doesn't work lol. Is there an easier way to have a leveling system? thanks.

GameBoy
To help you out a bit....

I want an experience system. When you hit a monster, or complete a quest, i want you to be able to gain experience points. You can goto a training place after, and you can level up (i dont want people to level up automatically). so when you're in the training place, and you type '/levelup' the game should check how much experience you have. if you dont have enough experience for the next level, it should say "you do not have enough experience". if you have enough, i want you to increase a level up, and the %maxexp% variable change. in the status variable window it says..." Exp: 250 / 800 " for example. the 250 would be how much you have now, and the 800 would be how much you need for the next level.

When you die, i want you to lose experience points, but if you drop under that level of exp (say, you are level 2 and drop under 800 exp points), i dont want you to decrease in level.

Also, if that code posted before was to be activated in a training place, when under exp, it would set you back a level. i dont want it to do that. once you have gained a level, you can't go back.

paul_one
Try setting the numeric to 2001 instead of increasing it 2001 times.....

You might also want to change the leveling system to just up the level when it reaches a certain point instead of setting it to ranges...
IE: if level is 2 then set the upgrade range.... THEN upgrade.... Then reset the EXP or something (I would personally but it's up to your personal choice).

So:
set numeric <exp; %exp% + 1000>

Set an array of boundries for levels....
set numeric <levexp[1]; 1000> ' need 1000 to move from lev1 to lev2
set numeric <levexp[2]; 2500> ' need 2500 to go to lev 3...
set numeric <levexp[3]; 5500> ' etc...

Or you could go through with this loop thingy:
set numeric <levexp[99]; 0>

set numeric <lastlev; 250>
<loop; 1 to 99 step 1> ' sorry - I don't know the ASL for a loop or whatever...
set numeric <thislev; 2 * %lastlev%>
set numeric <thislev; %thislev% + 500>
set numeric <levexp[loop]; %thislev%>
set <lastlev; %thislev%>
<end loop>

NOTE: Since Alex uses a loop with no "Do events" the program freezes for thi loop time.... So if the user has a slow PC then it's gonna take ages ka-peesh! .... Maybe you could write a VB program to output all the level EXP thingy's for you so that the user doesn't hve to wait.... Or Alex could add "do events" in the loop sometime in the future...

Anyway, you've got the boundires set up, now it's time to level up...

if (%exp% >= %levexp[level]%) then set <level; %level% + 1> ' or inc <level>

Erm... That would increase the level..... Surely you'd check it after you got the EXP anyway to up the level after every battle..... BUT if you want a shop-like system (ie - you go to a certain place to up your level or whatever) then you just have him doing this several times - or search through the array until you find an appropriate level - again using a loop...

There ya go..... anything I forgot?

GameBoy
ok i'll try and work all that out lol. even though i've used the program for AGES, i still know jack all about the coding lol.

billchelonis
Here's one way to do it, and it doesn't decrease your level if you lost XP from death either. Loop through like so, but of course your Current_XP and Current_Level and Maximum_Levels variables will be different. I hardcoded them in this example on the first three lines. So you'd want to remove those lines and make these like global variables or something. :


define procedure <experience>
set numeric <Current_Level; 1>
set numeric <Maximum_Levels; 20>
set numeric <Current_XP; 12345>
set numeric <Next_Level; %Current_Level% + 1>
set numeric <XP_To_Next_Level; 0>
set numeric <Leveled_Up_This_Time; 0>
for <tempLevelPointer; 1; %Maximum_Levels%; 1> {
if ( %tempLevelPointer% = %Next_Level% ) then {
msg <...checking for level up condition.>
set numeric <bluetooth; %Next_Level% * 1000>
set numeric <greentooth; %bluetooth% / 2>
set numeric <XP_To_Next_Level; %bluetooth% + %greentooth%>
set numeric <XP_Difference; %XP_To_Next_Level% - %Current_XP%>
if ( %XP_Difference% <= 0 ) and ( %Current_Level% <> %Maximum_Levels% ) then {
msg <You can level up to |b%Next_Level%|xb!.... (run the level up procedure or prompt the player here for new spells, abilities, etc.)>
inc <Current_Level; 1>
inc <Next_Level; 1>
set numeric <Leveled_Up_This_Time; 1>
}
}
}
if ( %Leveled_Up_This_Time% = 1 ) then set string <myDisplayString; Sorry but you can't level up anymore right now.> else set string <myDisplayString; Sorry, you can't level up.>
if ( %Current_Level% <> %Maximum_Levels% ) then msg <#myDisplayString# You need %XP_Difference% more XP to make it to Level %Next_Level%>
if ( %Current_Level% = %Maximum_Levels% ) then msg <You are already at the highest level allowed in this game. You are level %Current_Level%.>
end define


Of courst this only accounts for 20 levels, and I'm not sure on the math formula, but you'll want some kind of math formula like this to make your job easier. i.e. "XP Per Level" = (level * 1000) + ((level * 1000) / 2)

Also, might want to keep an eye on how big those numbers are you're dealing with. I'd personally go with a smaller numbered XP system myself to allow for really high levels, and adjust the monster kill XP reward down a bit or level cap it so the lower level stuff doesn't give you an unfair XP gain in a system like this. Smaller numbers will work out better (IMO), and the reason why is you don't want huge numbers floating around in memory or bad things *might* happen (i.e. program crash).


Here is a full .ASL file for you. Just talk to the trainer and answer yes and he'll level you up.

' "test XP game"
' Created with QDK Pro 3.52

define game <test XP game>
asl-version <350>
gametype singleplayer
start <Training Room>
game author <myAuthorName>
game info <Created with QDK Pro 3.52>
startscript do <initialize>
end define

define synonyms
end define

define room <Training Room>
alias <Training Center>
prefix <the>
look <This is the training center.>

define object <Warrior Trainer>
alias <Trainer>
alt <warrior trainer; guild leader>
look <This is the warrior trainer.>
speak choose <trainer>
examine <The warrior trainer stands ready to help you train to the next level, if you're able. Just talk to him.>
prefix <a>
end define

end define

define procedure <experience>
set numeric <Next_Level; %Current_Level% + 1>
set numeric <XP_To_Next_Level; 0>
set numeric <Leveled_Up_This_Time; 0>
for <tempLevelPointer; 1; %Maximum_Levels%; 1> {
if ( %tempLevelPointer% = %Next_Level% ) then {
msg <...checking for level up condition.>
set numeric <bluetooth; %Next_Level% * 1000>
set numeric <greentooth; %bluetooth% / 2>
set numeric <XP_To_Next_Level; %bluetooth% + %greentooth%>
set numeric <XP_Difference; %XP_To_Next_Level% - %Current_XP%>
if ( %XP_Difference% <= 0 ) and ( %Current_Level% <> %Maximum_Levels% ) then {
msg <You can level up to |b%Next_Level%|xb!.... (run the level up procedure or prompt the player here for new spells, abilities, etc.)>
inc <Current_Level; 1>
inc <Next_Level; 1>
set numeric <Leveled_Up_This_Time; 1>
}
}
}
if ( %Leveled_Up_This_Time% = 1 ) then set string <myDisplayString; Sorry but you can't level up anymore right now.> else set string <myDisplayString; Sorry, you can't level up.>
if ( %Current_Level% <> %Maximum_Levels% ) then msg <#myDisplayString# You need %XP_Difference% more XP to make it to Level %Next_Level%>
if ( %Current_Level% = %Maximum_Levels% ) then msg <You are already at the highest level allowed in this game. You are level %Current_Level%.>
end define

define procedure <initialize>
set numeric <Current_XP; 12345>
set numeric <Current_Level; 1>
set numeric <Maximum_Levels; 20>

end define

define text <intro>

end define

define text <win>

end define

define text <lose>

end define

define selection <trainer>
info <"Up for some training today?" the trainer asks you.>
choice <Yes> do <experience>
choice <No> msg <The trainer says,"Okay, friend. Good luck and safe hunting!">
end define


The point where it says "run the level up procedure or prompt the player here for new spells, abilities, etc" .... this is where I would put the NPC prompt to ask if the player wants to purchase training to level up. If the player can not afford it or declines, then that's the end of the check and it stops right there. If the player accepts, the loop goes to the next level check automatically, etc.

Anonymous
Okay. Just realized I'm off by one level on that code. That's because level one starts at zero not at (1 * 1000) + ((1 * 1000)/2) or 1500. So technically when it says you made level 9 in that code you actually made level 8. So I have to go back and decrement it or something - or you could leave it as is and have a level zero being 0-1500 points. But you get the idea I guess.

billchelonis
Went back and edited/corrected the code. Needed to have the %Next_Level% thing in part of the check, not %Current_Level%. That's where the prob was.

Anonymous
With the method above what you're in effect doing is not worrying about how many XP points are between levels but at what threshold number you reach the next level up. See below:

level 2: 1500
level 3: 3000
level 4: 4500
level 5: 7500
level 6: 9000
level 7: 10500
level 8: 12000
level 9: 13500
level 10: 15000
level 11: 16500
...level 30: 45000
...level 60: 90000
...level 100: 150000

This means that to get level 9 you need a total of 13500 experience points in all, not 13500 points between level 8 and level 9, but 13500 since the very start of the game.

points total you need to next level = (level * 1000) + ((level * 1000) / 2)

With a system like this, you might set the monster experience reward in a math formula as well. So you can have a base monster XP reward and muliply it through a formula depending on how high of a level the player is VS. the monster's own level.

monster XP reward = monsterLevel * (base / PlayerLevel)

So a level 1 goblin with a base XP reward of 100 points to a level one player would be ..... 1 * (100 / 1) = 100 points to that player
...but that same monster to a level 60 player would be...
1 * (100 / 60) = 0.6 (not even one full XP point!)
So there's your level cap formula right there. If it's less than one XP point, don't reward the player for killing it. This is how I would make an XP system.

Now, on the other hand, a level 1 character fighting and somehow killing a level 10 monster that has a base XP reward of 500....
monsterLevel * (base / PlayerLevel)
10 * (500 / 1) = 5000 XP rewarded for the near impossible feat of a level one player killing a level ten monster!
That same monster killed by a character at the monster's own level (10) would grant the player the normal base reward of 500:
10 * (500 / 10) = 500 XP reward

So what this system would do is setup risk vs. reward so that players killing significantly higher level monsters would get that much bigger of a reward and thus level up faster.

paul_one
Anything from lev5 upward on that list is wrong....

You forgot to minus 1 on the level from that oint on.... But yes - I believe that is what my code does if you don't reset the EXP so.....

GameBoy
that's pretty neat. thanks for this :D

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums