11-04-2009, 01:30 AM
[SERVERSIDE]
First we have to add a new packet
In mod Enumerations under
put
Now let us make the sub to send the packet
AT the bottom of modServerTcp put
Now lets send the packet. In the attacknpc sub, under
put
[CLIENTSIDE]
We have to add the new packet to the client too.
In mod Enumerations under
put
We have to add a value to MapNpcRec called MaxHp
Find
under
put
Now lets actually change the hp when we get the packet.
in modHandleData underput
now at the bottom of modHandleData put this sub
Now the last step, draw the hp bar. In sub BltNpc at the bottom put
First we have to add a new packet
In mod Enumerations under
Code:
SCastSpellCode:
SUpdateNpcHPNow let us make the sub to send the packet
AT the bottom of modServerTcp put
Code:
Public Sub SendNpcHp(ByVal Map As Long, ByVal Index As Byte)
'check if the npc is dead
If MapNpc(Map, Index).Vital(Vitals.HP) = 0 Then
Call SendDataToMap(Map, SUpdateNpcHP & SEP_CHAR & Index & SEP_CHAR & 0 & SEP_CHAR & 0 & END_CHAR)
Else
Call SendDataToMap(Map, SUpdateNpcHP & SEP_CHAR & Index & SEP_CHAR & MapNpc(Map, Index).Vital(Vitals.HP) & SEP_CHAR & Npc(MapNpc(Map, Index).Num).Stat(Stats.Strength) * Npc(MapNpc(Map, Index).Num).Stat(Stats.Defense) & END_CHAR)
End If
End SubNow lets send the packet. In the attacknpc sub, under
Code:
' Reduce durability of weapon
Call DamageEquipment(Attacker, Weapon)Code:
'Lets update the hp of the npc incase it got hurt
Call SendNpcHp(GetPlayerMap(Attacker), MapNpcNum)[CLIENTSIDE]
We have to add the new packet to the client too.
In mod Enumerations under
Code:
SCastSpellCode:
SUpdateNpcHPWe have to add a value to MapNpcRec called MaxHp
Find
Code:
Private Type MapNpcRecCode:
AttackTimer As LongCode:
MaxHp As LongNow lets actually change the hp when we get the packet.
in modHandleData under
Code:
HandleSpellCast ParseCode:
Case SUpdateNpcHP
HandleUpdateNpcHP Parsenow at the bottom of modHandleData put this sub
Code:
' ::::::::::::::::::::::::::
' :: Update Npc Hp packet ::
' ::::::::::::::::::::::::::
Private Sub HandleUpdateNpcHP(ByRef Parse() As String)
MapNpc(CByte(Parse(1))).Vital(Vitals.HP) = CLng(Parse(2))
End SubNow the last step, draw the hp bar. In sub BltNpc at the bottom put
Code:
If MapNpc(MapNpcNum).Vital(Vitals.HP) = 0 Then Exit Sub
Call DDS_BackBuffer.SetFillColor(RGB(255, 0, 0))
Call DDS_BackBuffer.DrawBox(X, Y + 32, X + 32, Y + 36)
Call DDS_BackBuffer.SetFillColor(RGB(0, 255, 0))
Call DDS_BackBuffer.DrawBox(X, Y + 32, X + ((MapNpc(MapNpcNum).Vital(Vitals.HP) / 100) / (MapNpc(MapNpcNum).MaxHp / 100) * 32), Y + 36)