Level Display
From VbGORE Visual Basic Online RPG Engine
For those who would like to display the level of all the players next to the user's name, here's what I did.
Client
1) In DataIDs.bas, find Public Type DataCode and add to it:
<vb>Server_UpdateLvl As Byte</vb>
2) Further down in the same module, find "InitDataCommands()", and find: "With DataCode". Add to that block of code:
<vb>.Server_UpdateLvl = 122 'Updates Lvl Displayed Overhead of Players</vb>
3) on frmMain find: "Private Sub GOREsock_OnDataArrival(inSox As Long, inData() As Byte)" and then locate inside it: "With DataCode". Add this:
<vb>Case .Server_UpdateLvl: Data_Server_UpdateLvl rBuf</vb>
4) In TCP.bas add this:
<vb>Sub Data_Server_UpdateLvl(ByRef rBuf As DataBuffer) '************************************************************ 'Update Lvl displayed next to PC name '<CharIndex(I)><Lvl(I)> '************************************************************ Dim CharIndex As Integer Dim Lvl As Integer
CharIndex = rBuf.Get_Integer
Lvl = rBuf.Get_Integer
'If the char doesn't exist, request to create it
If Not Engine_ValidChar(CharIndex) Then Exit Sub
' Add Lvl After Character's Name
CharList(CharIndex).DisplayName = CharList(CharIndex).Name & " (" & Lvl & ")"
End Sub </vb>
5) Go to the TileEngine module and find: "Public Type Char". In that block of code find: "Name As String". Below that, add:
<vb>DisplayName As String</vb>
6) In the same sub, go to "Engine_Char_Make". Find: "CharList(CharIndex).Name = Name". Below that add:
<vb> CharList(CharIndex).DisplayName = Name
If CharList(CharIndex).CharType = ClientCharType_PC Or CharList(CharIndex).CharType = ClientCharType_Grouped Then
CharList(CharIndex).NameOffset = (Engine_GetTextWidth(Font_Default, Name & " (##)")) * 0.5
Else
CharList(CharIndex).NameOffset = Engine_GetTextWidth(Font_Default, Name) * 0.5
End If
</vb>
7) Now locate the sub "Engine_Render_Char". Find the block of code that draws the name above the character. It should be preceeded by the comment: "'Draw name over head". Now, change all ".Name" to ".DisplayName"
Server
for the Server:
1) in "DataIDs.bas", find "Public Type DataCode" and add to it:
<vb>Server_UpdateLvl As Byte</vb>
2) Further down in the same module, find "InitDataCommands()", and find: "With DataCode". Add to that block of code:
<vb>.Server_UpdateLvl = 122 'Updates Lvl Displayed Overhead of Players </vb>
3) in Users.bas find the Sub User_MakeChar. Inside that, add this code at the end:
<vb>'Update User's Displayed Level to all on same map
User_UpdateLvl (UserIndex)</vb>
4)Then add that same code for the sub "User_RaiseExp"
5) Add this code to "Users.bas":
<vb>Public Sub User_UpdateLvl(ByVal UserIndex As Integer) '***************************************************************** 'Update Lvl displayed next to PC name 'Added by Adam Britt '*****************************************************************
Log "Call User_UpdateLvl(" & UserIndex & "," & UserList(UserIndex).Stats.BaseStat(SID.ELV) & ")", CodeTracker '//\\LOGLINE//\\
'Send the Lvl Update
ConBuf.PreAllocate 6
ConBuf.Put_Byte DataCode.Server_UpdateLvl
ConBuf.Put_Integer UserList(UserIndex).Char.CharIndex
ConBuf.Put_Integer UserList(UserIndex).Stats.BaseStat(SID.ELV)
'Data_Send ToMap, UserIndex, ConBuf.Get_Buffe
Data_Send ToMap, 0, ConBuf.Get_Buffer, UserList(UserIndex).Pos.Map
End Sub </vb>
That should be everything, your players now have their level next to their name.
Just a side note:
If you want to display the level of an NPC, just hard code it into their name (Unless you intend on NPCs training themselves... :P ) Also, the advantage to this is that you can avoid displaying the level to such NPCs as shop keepers, bankers, etc. who are non combatant. A good rule of thumb for deciding the NPC's level is (Def + MaxHit + Mag) / 5. Reasoning behind this is that the default XP system of VbGORE is to give you 5 skill points per level up. Enjoy!
This tutorial is made by: GoreMania