Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO] .ini-based Experience Table


balliztik1
 Share

Recommended Posts

The older versions of Eclipse had experience tables that were editable through a .ini file in the server. It's a fairly simple edit to recreate this.

**Please note: If you have access to the source code (which is pretty much assumed if you're here), and your experience table is based on a formula, it's much easier just to change the GetPlayerNextLevel function and MAX_LEVELS constant to suit your needs rather than having to implement a .ini system.**

_All edits are server-side._

The first thing that needs to be done is to get rid of the old experience system. It is very loosely integrated, so it's not too hard to do. Find and delete the following:

```
Function GetPlayerNextLevel(ByVal index As Long) As Long
    GetPlayerNextLevel = (GetPlayerLevel(index) + 1) * (GetPlayerStat(index, Stats.strength) + GetPlayerStat(index, Stats.endurance) + GetPlayerStat(index, Stats.intelligence) + GetPlayerStat(index, Stats.spirit) + GetPlayerPOINTS(index)) * 25
End Function
```
```
Public Const MAX_LEVELS As Byte = 100
```
Now, we just need to add in our new system. We'll need to set up two variables to do this. Add the following to the source (preferably in modGlobals if you value organization):

```
Public MAX_LEVELS As Byte
Public Experience() As Long
```
Now, a simple loading sub will set everything up. Add this, preferably in modDatabase:

```
Sub LoadExperience()
    Dim I As Byte

    If Not FileExist("data\Experience.ini") Then
        Call SetStatus("Generating experience table...")
        MaxLevel = 100
        Call PutVar(App.Path & "\data\Experience.ini", "Max", "MaxLevel", CStr(MaxLevel))

        ReDim Experience(1 To MaxLevel)
        For I = 1 To MaxLevel
            Experience(I) = I * 25
            Call PutVar(App.Path & "\data\Experience.ini", "Exp", CStr(I), CStr(Experience(I)))
        Next
    Else
        Call SetStatus("Loading experience...")
        MaxLevel = CByte(GetVar(App.Path & "\data\Experience.ini", "Max", "MaxLevel"))
        ReDim Experience(1 To MaxLevel)
        For I = 1 To MaxLevel
            Experience(I) = CLng(GetVar(App.Path & "\data\Experience.ini", "Exp", CStr(I)))
        Next
    End If
End Sub
```
Now, all that needs to be done is to make sure this is called. Find Sub LoadGameData and add this to it somewhere:

```
Call LoadExperience
```
As a last touch, just make sure to replace the old GetPlayerNextLevel (located in modPlayer) with this new one that reflects the proper values:

```
Function GetPlayerNextLevel(ByVal Index As Long) As Long
    If GetPlayerLevel(Index) = MAX_LEVELS Then
        GetPlayerNextLevel = 9999999
    Else
        GetPlayerNextLevel = Experience(GetPlayerLevel(Index) + 1)
    End If
End Function
```
To note, there's nothing in place yet to stop players from gaining experience once they've hit the level cap, so a slight change might be in order to the way SetPlayerExp works. Consider changing it to this:

```
Sub SetPlayerExp(ByVal Index As Long, ByVal EXP As Long)
    If GetPlayerLevel(Index) = MAX_LEVELS Then EXP = 0
    Player(Index).EXP = EXP
End Sub
```
Either do that, or restrict experience from accruing at the max level somehow. How you do it really doesn't matter, though.

That's that - a simple edit that allows a custom experience table. Just fire up the server and it will auto-create the .ini for you. All you need to do is alter it.
Link to comment
Share on other sites

  • 1 month later...
~~This is so useful. :) Thanks for this, it really makes it easier to change it, and you have less risk messing stuff up.

Edit:
I get the follow error while trying to compile.
I've double checked everything, but everything should be correct.

Image:

>! ![](http://img594.imageshack.us/img594/6488/maxlvlerror.png)

What to do?~~

Sloved.
Link to comment
Share on other sites

Oh yes, sorry about that. I either will make them smaller or put them in spoilers next time.

But thanks again, this fixed it. :)

Also, if I did use this "Dim MaxMap as long" and change a little few other things on the MaxMaps scripts (If I found it.) I could have more maps than 255, right? (Also for NPC, Shops, etc.)

And again, this is so far the best Eclipse MMORPG Maker I worked with. :)
I'm getting used to it quickly also.

Edit:

My level up system is borken. I keep remaining op lvl1 with 25exp.
Anyone else having this too?
I'm messing with it now, though no success yet.
Link to comment
Share on other sites

I found the error!!
Do NOT delete:
```
Public Const MAX_LEVELS As Byte = 100
```But rather change it to what you want your max level to be.
Now, search for

```
Public Const MAX_LEVELS As Byte = 100
```in the client, and change it to match what's in the server. Also, in the server, search and delete```
Public MAX_LEVELS As Byte
```
I tested it myself, now the EXP in the .ini loads, updates when you level, and leveling works.

Note: To change the max level, you'll have to change the```
Public Const MAX_LEVELS As Byte = 100
```in the client and server again. But hey, it works!

~Urame
Link to comment
Share on other sites

  • 1 month later...
@Sir:

> Many thanks to the OP, but also to Urame Hinote, without his fixes this wouldn't have worked properly.

No problem, but now I know how to send data from server to client, sooo…Here's a better fix which allows the .ini to work setting max level!
[http://www.touchofdeathforums.com/smf/index.php/topic,64180.0.html](http://www.touchofdeathforums.com/smf/index.php/topic,64180.0.html)

Hope that helps everyone =D
~Urame
Link to comment
Share on other sites

  • 2 weeks later...
> As a last touch, just make sure to replace the old GetPlayerNextLevel (located in modPlayer) with this new one that reflects the proper values:
>
> ```
> Function GetPlayerNextLevel(ByVal Index As Long) As Long
>     If GetPlayerLevel(Index) = MAX_LEVELS Then
>         GetPlayerNextLevel = 9999999
>     Else
>         GetPlayerNextLevel = Experience(GetPlayerLevel(Index) + 1)
>     End If
> End Function
> ```

I cannot find GetPlayerNextLevel as a function. Has this been updated in Origins? I have the latest version.

Here is what I find in "modplayer" on the "server" source when I search GetPlayerNextLevel:

```
    Do While GetPlayerExp(Index) >= GetPlayerNextLevel(Index)
        expRollover = GetPlayerExp(Index) - GetPlayerNextLevel(Index)
```
Link to comment
Share on other sites

@Robin:

> You accidentally the entire function. Well done.

Lmfao, I didn't know I already deleted it XD XD XD XD!!!!

EDIT EDIT:Nvm, I fixed it using google.. XD
ANDDD, I learned a new concept. :)

EDIT EDIT EDIT: I found a new bug, when your playing in game your experience starts out as 50 and it does not change. When you level up, your exp til next level is still 50…
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...