18-09-2006, 01:58 AM
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:In modGamelogic, add these two subs:In the CheckPlayerLevelUp sub, find:Beneath it, add: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:Beneath it, add:
Then, In the same module, in the LoadPlayer sub, add:Now, open modTypes, and in Type PlayerRec, add: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.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.
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
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
Code:
Call SetPlayerLevel(index, GetPlayerLevel(index) + 1)
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
In modDatabase, in the SavePlayer sub, find:
Code:
Call PutVar(FileName, "CHAR" & i, "PK", STR(Player(index).Char(i).PK))
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"))
Code:
Rebirth As Long
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