Mirage Source
[Feature] HP/MP/SP bars (for players) - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Source Code Development (https://mirage-engine.uk/forums/forumdisplay.php?fid=51)
+----- Forum: Mirage Source 4 (Visual Basic 6) (https://mirage-engine.uk/forums/forumdisplay.php?fid=44)
+------ Forum: Tutorials (https://mirage-engine.uk/forums/forumdisplay.php?fid=13)
+------ Thread: [Feature] HP/MP/SP bars (for players) (/showthread.php?tid=2727)



[Feature] HP/MP/SP bars (for players) - Labmonkey - 10-04-2009

[SERVERSIDE]
change the SendVital sub to this

Code:
Public Sub SendVital(ByVal Index As Long, ByVal Vital As Vitals)
Dim Packet As String
    
    Select Case Vital
        Case HP
            Packet = SPlayerHp & SEP_CHAR & Index & SEP_CHAR & GetPlayerMaxVital(Index, Vitals.HP) & SEP_CHAR & GetPlayerVital(Index, Vitals.HP) & END_CHAR
        Case MP
            Packet = SPlayerMp & SEP_CHAR & Index & SEP_CHAR & GetPlayerMaxVital(Index, Vitals.MP) & SEP_CHAR & GetPlayerVital(Index, Vitals.MP) & END_CHAR
        Case SP
            Packet = SPlayerSp & SEP_CHAR & Index & SEP_CHAR & GetPlayerMaxVital(Index, Vitals.SP) & SEP_CHAR & GetPlayerVital(Index, Vitals.SP) & END_CHAR
    End Select
    
    Call SendDataToMap(GetPlayerMap(Index), Index, Packet)
End Sub
This sends the vitals to everyone, and also says who they are for.

[CLIENTSIDE]
change sub HandlePlayerHp to
Code:
Private Sub HandlePlayerHp(ByRef Parse() As String)
     Dim Index As Long
     Index = CLng(Parse(1))
     Player(Index).MaxHP = CLng(Parse(2))
     Call SetPlayerVital(Index, Vitals.HP, CLng(Parse(3)))
     If Index = MyIndex Then
        If GetPlayerMaxVital(Index, Vitals.HP) > 0 Then
            frmMirage.lblHP.Caption = Int(GetPlayerVital(Index, Vitals.HP) / GetPlayerMaxVital(Index, Vitals.HP) * 100) & "%"
        End If
     End If
End Sub

change sub HandlePlayerMp to
Code:
Private Sub HandlePlayerMp(ByRef Parse() As String)
     Dim Index As Long
     Index = CLng(Parse(1))
     Player(Index).MaxMP = CLng(Parse(2))
     Call SetPlayerVital(Index, Vitals.MP, CLng(Parse(3)))
     If Index = MyIndex Then
        If GetPlayerMaxVital(Index, Vitals.MP) > 0 Then
            frmMirage.lblMP.Caption = Int(GetPlayerVital(Index, Vitals.MP) / GetPlayerMaxVital(Index, Vitals.MP) * 100) & "%"
        End If
     End If
End Sub

change sub HandlePlayerSp to
Code:
Private Sub HandlePlayerSp(ByRef Parse() As String)
     Dim Index As Long
     Index = CLng(Parse(1))
     Player(Index).MaxSP = CLng(Parse(2))
     Call SetPlayerVital(Index, Vitals.SP, CLng(Parse(3)))
     If Index = MyIndex Then
        If GetPlayerMaxVital(Index, Vitals.SP) > 0 Then
            frmMirage.lblSP.Caption = Int(GetPlayerVital(Index, Vitals.SP) / GetPlayerMaxVital(Index, Vitals.SP) * 100) & "%"
        End If
     End If
End Sub


Now to actually draw out the bars for everyone Big Grin.

in sub BltPlayer, right before end sub put
Code:
If Player(Index).Vital(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 + ((Player(Index).Vital(HP) / 100) / (Player(Index).MaxHP / 100) * 32), Y + 36)
        
        Call DDS_BackBuffer.SetFillColor(RGB(255, 0, 0))
        Call DDS_BackBuffer.DrawBox(X, Y + 35, X + 32, Y + 39)
        
        Call DDS_BackBuffer.SetFillColor(RGB(0, 0, 255))
        Call DDS_BackBuffer.DrawBox(X, Y + 35, X + ((Player(MyIndex).Vital(MP) / 100) / (Player(MyIndex).MaxMP / 100) * 32), Y + 39)

If you happen to also be using sp, you could put this.
Code:
Call DDS_BackBuffer.SetFillColor(RGB(255, 0, 0))
        Call DDS_BackBuffer.DrawBox(X, Y + 38, X + 32, Y +42)

        Call DDS_BackBuffer.SetFillColor(RGB(255, 255, 0))
        Call DDS_BackBuffer.DrawBox(X, Y + 38, X + ((Player(MyIndex).Vital(MP) / 100) / (Player(MyIndex).MaxMP / 100) * 32), Y + 42)

And you are done Big Grin.


Re: [Feature] HP/MP/SP bars (for players) - Tdiddy - 12-04-2009

is this the HP MP SP bars for below/above the player or...... off to the side were the the current hp #%'s are


Re: [Feature] HP/MP/SP bars (for players) - Doomy - 12-04-2009

if im right its above


Re: [Feature] HP/MP/SP bars (for players) - Labmonkey - 12-04-2009

No its below.


Re: [Feature] HP/MP/SP bars (for players) - Clu - 28-06-2009

If you want a player HP/MP bar just for your own player, you can solely put this in, inside your bltplayer sub

Code:
If Player(Index).Vital(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 + ((Player(Index).Vital(HP) / 100) / (Player(Index).MaxHP / 100) * 32), Y + 36)
      
        Call DDS_BackBuffer.SetFillColor(RGB(255, 0, 0))
        Call DDS_BackBuffer.DrawBox(X, Y + 35, X + 32, Y + 39)
      
        Call DDS_BackBuffer.SetFillColor(RGB(0, 0, 255))
        Call DDS_BackBuffer.DrawBox(X, Y + 35, X + ((Player(MyIndex).Vital(MP) / 100) / (Player(MyIndex).MaxMP / 100) * 32), Y + 39)

It still works perfectly fine in MS4 the latest version I as just using it.


Re: [Feature] HP/MP/SP bars (for players) - Ciao - 11-08-2009

I tried to do this, it seems to work for a few people but I am new and I did everything correctly and I got a shit load of errors that I tried to fix myself but all I got was more errors, I get Compile Error ' Variable Not Defined' and I don't know what to do because there's only one Sub SendVital and usually Variable Not defined errors mean I am putting the code in the wrong section.


Re: [Feature] HP/MP/SP bars (for players) - Matt - 11-08-2009

Ciao Wrote:I tried to do this, it seems to work for a few people but I am new and I did everything correctly and I got a shit load of errors that I tried to fix myself but all I got was more errors, I get Compile Error ' Variable Not Defined' and I don't know what to do because there's only one Sub SendVital and usually Variable Not defined errors mean I am putting the code in the wrong section.

All these tutorials need to be converted to work with the byte array packets system. You might wanna learn the difference between the two systems. These tutorials use string packets, but the source has byte array packets now.


Re: [Feature] HP/MP/SP bars (for players) - Ciao - 12-08-2009

Thank you for letting me know, is there going to be a whole fix by the way ?


Re: [Feature] HP/MP/SP bars (for players) - Matt - 12-08-2009

Ciao Wrote:Thank you for letting me know, is there going to be a whole fix by the way ?

No, but sooner or later, prolly this weekend, I will post a few examples of how to convert the packets and what not.


Re: [Feature] HP/MP/SP bars (for players) - Ellesar - 13-08-2009

I'll be waiiting 4 it, i 've seen many tutorials and things that i wnna to Add but never colud do it because allways give error in SEP_CHAR and END_CHAR.(Supose that they are Strings packets rigth?)


Re: [Feature] HP/MP/SP bars (for players) - Labmonkey - 13-08-2009

The newest version of mirage uses byte packets, this uses string packets.


Re: [Feature] HP/MP/SP bars (for players) - Ellesar - 13-08-2009

I Thougt so, so Why they changed? are better byte than String Packets?
Cold anyone tell me the diference?

Well anyways i think i will find out later how to make the bars ^^ i hve other problems first ^^...


Re: [Feature] HP/MP/SP bars (for players) - Labmonkey - 14-08-2009

Byte array packets are much smaller.


Re: [Feature] HP/MP/SP bars (for players) - 4ngel - 14-08-2009

Labmonkey Wrote:Byte array packets are much smaller.
What? I fail to understand why a byte array would help make the packets smaller. The byte array is equatable to a string if the array contents correspond to a character set like ASCII.