Dynamic level system

From VbGORE Visual Basic Online RPG Engine

Contents

Dinamic Level System

Do you want in every level of the people get get more experience? With this tutorial you can do several Experience between levels.

Dificulty

The dificulty its easy, everyone can do this.


The Code

Go to users.bas in the gameserver.vbp and find: Public Sub User_RaiseExp(ByVal UserIndex As Integer, ByVal lngEXP As Long)

And later, remplaze all the code for this one:

   Public Sub User_RaiseExp(ByVal UserIndex As Integer, ByVal lngEXP As Long)
   '*****************************************************************
   'Raise the user's experience - this should be the only way exp is raised!
   'More info: http://www.vbgore.com/GameServer.Users.User_RaiseExp
   '*****************************************************************
   Dim Levels As Integer
   Log "Call User_RaiseExp(" & UserIndex & "," & lngEXP & ")", CodeTracker '//\\LOGLINE//\\
   'Update the user's experience
   UserList(UserIndex).Stats.BaseStat(SID.EXP) = UserList(UserIndex).Stats.BaseStat(SID.EXP) + lngEXP
   'Loop as many times as needed to get every level gained in
   Do While UserList(UserIndex).Stats.BaseStat(SID.EXP) >= UserList(UserIndex).Stats.BaseStat(SID.ELU)
       Log "User_RaiseExp: User by index " & UserIndex & " (" & UserList(UserIndex).Name & ") leveled up", CodeTracker '//\\LOGLINE//\\
       
                       
           'Set the number of levels gained
           'Levels = Levels + 1
       
           'Raise stats / level requirements
           With UserList(UserIndex).Stats
               If .BaseStat(SID.ELV) <= 90 Then
                   .BaseStat(SID.MinHIT) = .BaseStat(SID.MinHIT) + 1
                   .BaseStat(SID.MaxHIT) = .BaseStat(SID.MaxHIT) + 1
                   .BaseStat(SID.MaxHP) = .BaseStat(SID.MaxHP) + 25
                   .BaseStat(SID.MaxMAN) = .BaseStat(SID.MaxMAN) + 10
                   .BaseStat(SID.MaxSTA) = .BaseStat(SID.MaxSTA) + 10
                   .BaseStat(SID.Points) = .BaseStat(SID.Points) + 1
                   
                   .BaseStat(SID.ELV) = .BaseStat(SID.ELV) + 1
                   .BaseStat(SID.EXP) = .BaseStat(SID.EXP) - .BaseStat(SID.ELU)
                   If .BaseStat(SID.ELU) >= 5 Then
                       .BaseStat(SID.ELU) = .BaseStat(SID.ELV) * 80
                   ElseIf .BaseStat(SID.ELU) >= 10 Then
                       .BaseStat(SID.ELU) = .BaseStat(SID.ELV) * 105
                   ElseIf .BaseStat(SID.ELU) >= 15 Then
                       .BaseStat(SID.ELU) = .BaseStat(SID.ELV) * 190
                   ElseIf .BaseStat(SID.ELU) >= 20 Then
                       .BaseStat(SID.ELU) = .BaseStat(SID.ELV) * 290
                   ElseIf .BaseStat(SID.ELU) >= 25 Then
                       .BaseStat(SID.ELU) = .BaseStat(SID.ELV) * 400
                   ElseIf .BaseStat(SID.ELU) >= 30 Then
                       .BaseStat(SID.ELU) = .BaseStat(SID.ELV) * 640
                   ElseIf .BaseStat(SID.ELU) >= 40 Then
                       .BaseStat(SID.ELU) = .BaseStat(SID.ELV) * 940
                   ElseIf .BaseStat(SID.ELU) >= 50 Then
                       .BaseStat(SID.ELU) = .BaseStat(SID.ELV) * 1043
                   ElseIf .BaseStat(SID.ELU) >= 60 Then
                       .BaseStat(SID.ELU) = .BaseStat(SID.ELV) * 1250
                   ElseIf .BaseStat(SID.ELU) >= 70 Then
                       .BaseStat(SID.ELU) = .BaseStat(SID.ELV) * 1900
                   ElseIf .BaseStat(SID.ELU) >= 80 Then
                       .BaseStat(SID.ELU) = .BaseStat(SID.ELV) * 2400
                   End If
               End If
           End With
           Levels = Levels + 1
   Loop
   'Check if needing to update from leveling
   If Levels = 1 Then
       Log "User_RaiseExp: User gained a level", CodeTracker '//\\LOGLINE//\\
       'Say the user's level raised
       Data_Send ToIndex, UserIndex, cMessage(34).Data
   ElseIf Levels > 1 Then
       Log "User_RaiseExp: User gained multiple levels (" & Levels & ")", CodeTracker '//\\LOGLINE//\\
       'Say the user's level raised
       ConBuf.PreAllocate 3
       ConBuf.Put_Byte DataCode.Server_Message
       ConBuf.Put_Byte 35
       ConBuf.Put_Byte Levels
       Data_Send ToIndex, UserIndex, ConBuf.Get_Buffer
   End If
   End Sub

In Base Stats Elu, you can see if every level of the person has got, if this reach that hes ELU its more up.


Credits

By sergio_team

Personal tools