Print Page | Close Window

Npc Hp Bars Under Them

Printed From: Mirage Source
Category: Tutorials
Forum Name: Temporary Archive (Read Only)
Forum Discription: Temporary 3.0.3 archive tutorials, will be deleted when converted.
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=195
Printed Date: 20 December 2006 at 5:53pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Npc Hp Bars Under Them
Posted By: Sync
Subject: Npc Hp Bars Under Them
Date Posted: 11 February 2006 at 3:26pm
Difficulty: Medium 3/5

Originaly Posted By: GodSentDeath

Server Side

In modServerTCP, in Sub HandleData add the following anywhere:
' :::::::::::::::::::::::::::
    ' :: Npc hp request packet ::
    ' :::::::::::::::::::::::::::
    Dim Pack As String
    If LCase(Parse(0)) = "getnpchp" Then

    Pack = "npchp" & SEP_CHAR
        For i = 1 To MAX_MAP_NPCS
             n = MapNpc(GetPlayerMap(index), i).Num
             Pack = Pack & MapNpc(GetPlayerMap(index), i).HP & SEP_CHAR & GetNpcMaxHP(n) & SEP_CHAR
        Next i
    Pack = Pack & END_CHAR

        Call SendDataTo(index, Pack)
        Exit Sub
    End If


Now Client Side

In modClientTCP,in Sub HandleData add the following anywhere:
' :::::::::::::::::::
    ' :: 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


In modTypes find Type MapNpcRec under HP As Long add:
MaxHP As Long


Now in modGameLogic under:
' Blit out the npcs
For i = 1 To MAX_MAP_NPCS
Call BltNpc(i)
Next i

add:
' 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


Finally at the very bottom of modGameLogic add:
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


That should show the npcs there hp under them If you've got any problems please post.



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info