19-02-2008, 06:44 PM
Well, I added another packet into the server. The packet is sent when a character is used and it works properly. The packet just sets the players CanUpdateDisplayPoisition value to whatever is in their file. It functions perfectly now!
OK, moving along (I'm not keen to stopping). I decided to add HP bars to NPCs, using GSD's tutorial. But, I don't understand parts of it. Let me show you...
I understand how the packet is sent from the server to the client. But, I want to confirm something when the client receives the packet.
Does n = n + 2 mean that the first MapNPC has the 1st and 2nd values in the packet (HP and Max HP) and that the second NPC has the 3rd and 4th and so on. Does it work because every two values are assiagned to different MapNPCs?
Next up is the calling of the function that blits the NPCs:
What does the GSD2 variable represent and why does it send data if it is less than the TickCount (still don't know what this is) + 500. Then, why does it increase to the tickcount? I think it has something to do with the amount of actions that can be carried out at once (i.e. the amount of time it takes for a player to wait before his current animation ends and he can start a new one).
Last off is with the drawing of the hp bars:
I don't understand any of this except that it involves DirectX. Could someone clarify what the x/y calculations do and how the BackBuffer draws things to the main surface?
Sorry if I my questions seem obvious, this is how I learn. Thanks for previous feedback and future feedback!
OK, moving along (I'm not keen to stopping). I decided to add HP bars to NPCs, using GSD's tutorial. But, I don't understand parts of it. Let me show you...
I understand how the packet is sent from the server to the client. But, I want to confirm something when the client receives the packet.
Code:
' :::::::::::::::::::
' :: Npc hp packet ::
' :::::::::::::::::::
If LCase(Parse(0)) = "npchp" Then
n = 1
For i = 1 To MAX_MAP_NPCS
MapNpc(i).HP = Val(Parse(n))
MapNpc(i).MaxHP = Val(Parse(n + 1))
n = n + 2
Next i
Exit Sub
End If
Does n = n + 2 mean that the first MapNPC has the 1st and 2nd values in the packet (HP and Max HP) and that the second NPC has the 3rd and 4th and so on. Does it work because every two values are assiagned to different MapNPCs?
Next up is the calling of the function that blits the NPCs:
Code:
' Blit out NPC hp bars
Dim GSD2 As Long
If GetTickCount > GSD2 + 500 Then
Call SendData("getnpchp" & SEP_CHAR & END_CHAR)
GSD2 = GetTickCount
End If
For i = 1 To MAX_MAP_NPCS
If MapNpc(i).Num > 0 Then
Call BltNpcBars(i)
End If
Next i
What does the GSD2 variable represent and why does it send data if it is less than the TickCount (still don't know what this is) + 500. Then, why does it increase to the tickcount? I think it has something to do with the amount of actions that can be carried out at once (i.e. the amount of time it takes for a player to wait before his current animation ends and he can start a new one).
Last off is with the drawing of the hp bars:
Code:
Sub BltNpcBars(ByVal Index As Long)
Dim x As Long, y As Long
x = MapNpc(Index).x * PIC_X + MapNpc(Index).XOffset
y = MapNpc(Index).y * PIC_Y + MapNpc(Index).YOffset - 4
If MapNpc(Index).HP = 0 Then Exit Sub
Call DD_BackBuffer.SetFillColor(RGB(255, 0, 0))
Call DD_BackBuffer.DrawBox(x, y + 32, x + 32, y + 36)
Call DD_BackBuffer.SetFillColor(RGB(0, 255, 0))
Call DD_BackBuffer.DrawBox(x, y + 32, x + ((MapNpc(Index).HP / 100) / (MapNpc(Index).MaxHP / 100) * 32), y + 36)
End Sub
I don't understand any of this except that it involves DirectX. Could someone clarify what the x/y calculations do and how the BackBuffer draws things to the main surface?
Sorry if I my questions seem obvious, this is how I learn. Thanks for previous feedback and future feedback!