Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rebirths (Level Reset)
#1
Author: Leighland
Difficulty: 2/5 (May require some modifications.)

"Note that you can modify the events that take place upon resetting the players level. Example: I chose to divide the players stats by 4, but you could also have them keep the stats they have. The only problem would be that die hard players might eventually "overflow" their stats, so don't forget to cap them."

:: SERVER SIDE ::
In modConstants, add:
Code:
Public Const MAX_LEVEL = (your max level here) 'Mine is 100
In modGamelogic, add these two subs:
Code:
Function GetPlayerRebirth(ByVal index As Long) As Long
    GetPlayerRebirth = Player(index).Char(Player(index).CharNum).Rebirth
End Function

Sub SetPlayerRebirth(ByVal index As Long, ByVal Rebirth As Long)
    Player(index).Char(Player(index).CharNum).Rebirth = Rebirth
End Sub
In the CheckPlayerLevelUp sub, find:
Code:
Call SetPlayerLevel(index, GetPlayerLevel(index) + 1)
Beneath it, add:
Code:
If GetPlayerLevel(index) > MAX_LEVEL Then
            Call SetPlayerPOINTS(index, 0)
            Call SetPlayerExp(index, 0)
            Call SetPlayerLevel(index, 1)
            Call SetPlayerStr(index, GetPlayerStr(index) / 4)
            Call SetPlayerDEF(index, GetPlayerDEF(index) / 4)
            Call SetPlayerMAGI(index, GetPlayerMAGI(index) / 4)
            Call SetPlayerSPEED(index, GetPlayerSPEED(index) / 4)
            Call SetPlayerRebirth(index, GetPlayerRebirth(index) + 1)
            Call GlobalMsg(GetPlayerName(index) & " has been reborn!", Brown)
            Call PlayerMsg(index, "You have been reborn!", BrightBlue)
            Call SendStats(index)
            Exit Sub
        End If
Now, there's where you choose what you want to do to the player after they are "reborn". I have a variable set up so that I can keep track of player's rebirths. The reason for this is after the player resets, because they start with so many points, I use the rebirth level to make the NPC's stronger. See my reply to this topic for details.

In modDatabase, in the SavePlayer sub, find:
Code:
Call PutVar(FileName, "CHAR" & i, "PK", STR(Player(index).Char(i).PK))
Beneath it, add:
Code:
Call PutVar(FileName, "CHAR" & i, "Rebirth", STR(Player(index).Char(i).Rebirth))

Then, In the same module, in the LoadPlayer sub, add:
Code:
Player(index).Char(i).Rebirth = Val(GetVar(FileName, "CHAR" & i, "Rebirth"))
Now, open modTypes, and in Type PlayerRec, add:
Code:
Rebirth As Long
NOTE: If you want, in the SendStats packet, you can add the rebirth level as well and display it on the user's stat menu.
Code:
Sub SendStats(ByVal index As Long)
Dim Packet As String
    
    Packet = "PLAYERSTATS" & SEP_CHAR & GetPlayerStr(index) & SEP_CHAR & GetPlayerDEF(index) & SEP_CHAR & GetPlayerSPEED(index) & SEP_CHAR & GetPlayerMAGI(index) & SEP_CHAR & GetPlayerLevel(index) & SEP_CHAR & GetPlayerPOINTS(index) & SEP_CHAR & GetPlayerExp(index) & SEP_CHAR & GetPlayerNextLevel(index) & SEP_CHAR & GetPlayerPK(index) & SEP_CHAR & GetPlayerGuild(index) & SEP_CHAR & GetPlayerGuildAccess(index) & SEP_CHAR & GetPlayerAccess(index) & SEP_CHAR & GetPlayerRebirth(index) & SEP_CHAR & END_CHAR
    Call SendDataTo(index, Packet)
End Sub
Your packet might have different things in it, but that's how mine is. I don't think I've changed it but just make sure that your only includes those stats above with the addition of the rebirth level, otherwise it might mess up your game.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)