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

[EO].ini-Based Experience Bug-Fix


DarkSpine
 Share

Recommended Posts

All credits go to Ballie for the original code.
TESTING STATUS: **Tested! Works!**

>! @Ballie:
>! > 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.

Now comes my additional code, this will make the max level part possible:
**SERVER SIDE**
In **modEnumerations**
Search for:
```
STradeStatus
```And under it, add:
```
SMaxLevel
```
Now, go to **modDatabase** and replace:
```
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
```With:
```
' .ini-Based EXP System
Sub LoadExperience(Optional Index As Long, Optional Skip As Long)
Dim MaxLevel As Long
    Dim I As Byte

    If Skip <> 1 Then
    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
        MAX_LEVELS = CByte(MaxLevel)
    End If
    ElseIf Skip = 1 Then
        Call SendMaxLevel(Index, MaxLevel)
    End If
End Sub
```
At the bottom of **modServerTCP** add:
```
Sub SendMaxLevel(ByVal Index As Long, ByVal MaxLevel As Long)
    Dim Buffer As clsBuffer

    Set Buffer = New clsBuffer
    Buffer.WriteLong SMaxLevel
    Buffer.WriteLong MaxLevel
    SendDataTo Index, Buffer.ToArray()

    Set Buffer = Nothing
End Sub

```
Now, in **modHandleData** Search for:
```
Call TextAdd(GetPlayerLogin(Index) & " has logged in from " & GetPlayerIP(Index) & ".")
```and under it, add:
```
Call LoadExperience(Index, 1)
```
**FOLLOWING EDITS ARE CLIENT-SIDE!!!**

In **modEnumerations** Search for:
```
STradeStatus
```and under it, add:
```
SMaxLevel
```
Search and delete in **modConstants**:
```
Public Const MAX_LEVELS As Byte = 100
```
Now, in **modGlobals** add:
```
Public MAX_LEVELS As Byte
```
Go to **modHandleData** and under:
```
HandleDataSub(STradeStatus) = GetAddress(AddressOf HandleTradeStatus)
```Add:```
HandleDataSub(SMaxLevel) = GetAddress(AddressOf HandleMaxLevel)
```
At the bottom of **modHandleData** add:
```
Private Sub HandleMaxLevel(ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
    Dim Buffer As clsBuffer
    Dim MaxLevel As Long

    Set Buffer = New clsBuffer
    Buffer.WriteBytes Data()

    MaxLevel = Buffer.ReadLong
    MAX_LEVELS = CByte(MaxLevel)

    Set Buffer = Nothing
End Sub
```

That should do it, I'll be testing now, so wait until I've finished testing to add in =P

~Urame
Link to comment
Share on other sites

  • 3 weeks later...
@smokeythebear:

> > That should do it, I'll be testing now, so wait until I've finished testing to add in =P
> >
> > ~Urame
>
> Ok… So have you tested it yetÉ

Said so at the top of the post, this all works.

@314piwm:

> @Urame:
>
> > Search and delete in **modConstants**:
> > ```
> > Public Const MAX_LEVELS As Byte = 100
> > ```
> > Now, in **modGlobals** add:
> >
> > > Public MAX_LEVELS As **Byte**
>
> Byte, not bye  ;)

Thanks for pointing that out, fixed, I prolly never would've noticed xD (I believe I wrote a lot of the code here, and then inserted it in VB6, so it was a simple quick-typing error)

~Urame
Link to comment
Share on other sites

  • 1 month later...
@Robin:

> Dude, the fucking fix is in the post above you.

Robin, damn it, don't you think I tried that.
It says "Compile error:
Ambiguous name detected: MAX_LEVELS"

EDIT: I got it to compile, but when I run the server everything is ok, but when I try to login, the server gets runtime error 9, after the client says "Loading Game Data…".
Link to comment
Share on other sites

@Robin:

> Does it look like I care what you've tried? You're obviously blind.
>
> > **Search and delete in modConstants:**
> > ```
> > Public Const MAX_LEVELS As Byte = 100
> > ```

I don't care, that you don't care I have tried, I was just stating that I have tried the method above my post.

Solved.
Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...
I have EO Xmas Edition and I've installed this tut,  the server runs without problems but when I run the client, and I try to register a new account, I get the runtime error 91: "Object Variable or With Block variable not set"… how to fix it?
Link to comment
Share on other sites

  • 1 year later...

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...