-
Mar 7th, 2015, 04:43 AM
#1
Thread Starter
Member
[.Net 2010]Rpg Game Help - Leveling
Hello! I'm new to the forum so if I posted this incorrectly, I apologize beforehand. I am building an RPG game in Visual Basic .Net 2010, and everything is going great so far! No errors or mishaps, but what I've come to ask about is when I go to level my player up, I want to use the best method possible. I don't know any common algorithms used for such purposes and I would apreciate some input! Please and thank you!
P.S: I'm currently using this - my.settings.expMax = playerExperience.maximum + (my.settings.expMax • my.settings.playerLevel) / 2
It works, but eventually the exp is really really high. Starts at 100 and lvl 3 is 1350
-
Mar 7th, 2015, 09:22 AM
#2
Re: [.Net 2010]Rpg Game Help - Leveling
Why not use a simple scheme like 100 for level 1 200 for level 2 and so on ?
-
Mar 7th, 2015, 11:58 AM
#3
Thread Starter
Member
Re: [.Net 2010]Rpg Game Help - Leveling
Because its too generic. I want something a little more complex. Plus, there are modifiers for EXP, so when the player reaches a certain level in Intelligence, The modifier will change to make it easier to level up.
This is the actual code for Changing the MaxEXP on Leveling Up:
My.Settings.MaxEXP = My.Settings.MaxEXP * (My.Settings.expMultiplier * My.Settings.playerLevel) / 2
The multiplier is now 3
-
Mar 7th, 2015, 06:05 PM
#4
Thread Starter
Member
Re: [.Net 2010]Rpg Game Help - Leveling
Originally Posted by Odin the Wise
Because its too generic. I want something a little more complex. Plus, there are modifiers for EXP, so when the player reaches a certain level in Intelligence, The modifier will change to make it easier to level up.
This is the actual code for Changing the MaxEXP on Leveling Up:
My.Settings.MaxEXP = My.Settings.MaxEXP * (My.Settings.expMultiplier * My.Settings.playerLevel) / 2
The multiplier is now 3
So Basically at Level 1 you have 100 EXP, Then 300, then 1350, and Level 5 has 6870
Thats extremely exponential. I would like Level 1 to be 100 and level 100(Cap) to be 1,000,000 with an exponential growth rate, not linear. So level 50 would have to be less than 500,000, say like 300,000 or so.
What would be the Math for this?
EDIT
====
Not TOO exponential, as you can see, or I wouldn't be posting here :3
Last edited by Odin the Wise; Mar 7th, 2015 at 06:08 PM.
-
Mar 7th, 2015, 07:27 PM
#5
Re: [.Net 2010]Rpg Game Help - Leveling
I guess something close to what you want would be
EXP = 100 * (level ^ 2)
That gives you 100 at level 1, 1000000 at level 100, and 250000 at level 50.
-
Mar 7th, 2015, 07:39 PM
#6
Thread Starter
Member
Re: [.Net 2010]Rpg Game Help - Leveling
Originally Posted by passel
I guess something close to what you want would be
EXP = 100 * (level ^ 2)
That gives you 100 at level 1, 1000000 at level 100, and 250000 at level 50.
That sounds like a good one, I'll check it out in a minute.
Another issue is EXP overflow. If I kill an enemy for 50exp but I only need 25exp, how would I get it to add the remaining 25exp to the next level?
And when it comes to the EXP modifier, I'll just use it with enemyExp to change how much EXP is given based on player Intelligence :3
Edit:
Works great, thanks! 1M may seem a little high tho. Idk. I'll leave it for now... Thanks a lot man! Now I just need to fix EXP OverFlow
Last edited by Odin the Wise; Mar 7th, 2015 at 07:47 PM.
-
Mar 7th, 2015, 08:02 PM
#7
Re: [.Net 2010]Rpg Game Help - Leveling
Well, if you would rather go 100 to 100000, then you can change the exponent to 1.5, but you will get level values that have many digits after the decimal point quite often. You probably want to round up to next even 100, so could do this.
Code:
Dim LevelMax as Double
LevelMax = Int(100 * (level ^ 1.5)) + 99 'add 99 to force a roundup to 100, when truncating in the next line
LevelMax = d - d Mod 100 'round down to the previous 100
I'm not sure what the issue is with EXP OverFlow.
If the EXP would exceed LevelMax, then set some variable to the overflow amount and add it to the EXP when you reach the next level.
Last edited by passel; Mar 7th, 2015 at 08:06 PM.
-
Mar 7th, 2015, 08:24 PM
#8
Thread Starter
Member
Re: [.Net 2010]Rpg Game Help - Leveling
Thanks alot, I'll keep that in mind. I came up with a simple OverFlow Function that catches when settings.currentExp is Greaterthan maxExp, and it works, except when it doesnt set the current exp to 0 then add the overflow, it just changes the max Exp, keeps the current exp the same, and adds the over flow, Like so:
Intitial: Exp = 0; Max Exp = 100
+101 Exp
^LEVEL UP^
Post-Level: Exp = 101 Max Exp = 400
heres the Leveling.vb Code:
Code:
Public Class Leveling
Inherits frmMain
Public Sub expOverFlow()
Dim overflow = My.Settings.expOverFlow
overflow = 0
If My.Settings.currentEXP >= My.Settings.MaxEXP Then
overflow = My.Settings.currentEXP - My.Settings.MaxEXP
My.Settings.currentEXP = 0
My.Settings.Save()
My.Settings.Reload()
My.Settings.currentEXP = My.Settings.currentEXP + overflow
My.Settings.Save()
My.Settings.Reload()
LevelUp()
Else
LevelUp()
End If
End Sub
Public Sub LevelUp()
My.Settings.playerLevel = My.Settings.playerLevel + 1
My.Settings.MaxEXP = 100 * (My.Settings.playerLevel ^ 2)
'My.Settings.expIncrement = My.Settings.expIncrement * 2
My.Settings.Save()
My.Settings.Reload()
End Sub
End Class
-
Mar 7th, 2015, 10:51 PM
#9
Thread Starter
Member
Re: [.Net 2010]Rpg Game Help - Leveling
Ok, so I'm sure what I did, but I made it worse D:
I have button, and a NumbericUpDown
The button just adds the NumericUpDown's value to currentExp.
But when I go to test it. Anything over 1 Exp crashes the game, and tells me "-98 is not a valid Value for ProgressBar" (Paraphrased)
So I add 1 Exp, works fine, add 1 more for a whopping total of 2 Exp and it crashes with said error.
I deleted all the functions that call for LevelUp() and just made it with the button.
Also merged expOverFlow and LevelUp, like so:
Code:
Public Class Leveling
Inherits frmMain
Public Sub LevelUp()
Dim overflow = My.Settings.expOverFlow
Dim exp = My.Settings.currentEXP
Try
If My.Settings.currentEXP >= My.Settings.MaxEXP Then
overflow = exp - My.Settings.MaxEXP
My.Settings.currentEXP = 0
'My.Settings.Save()
'My.Settings.Reload()
My.Settings.playerLevel = My.Settings.playerLevel + 1
My.Settings.MaxEXP = 100 * (My.Settings.playerLevel ^ 2)
'If Experienced earned during LevelUp overflows, Handle it
My.Settings.currentEXP = My.Settings.currentEXP + overflow
'Save any changes made
My.Settings.Save()
My.Settings.Reload()
End If
Catch ex As Exception
End Try
End Sub
End Class
This is very frustrating
-
Mar 7th, 2015, 11:17 PM
#10
Thread Starter
Member
Re: [.Net 2010]Rpg Game Help - Leveling
BOOM BABY! Fixed that bullcrap! Thanks for your help. Is it OK if I leave this thread open incase I run into another problem(as long as it deals with Leveling as the thread name implies?)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|