Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Other Player HP/MP Bar


Kirby4tw
 Share

Recommended Posts

Ok. THis the Code of the NPC-Bars:

```
Sub BltNpcBars(ByVal Index As Long)
    Dim X As Long, Y As Long

    On Error GoTo BltNpcBars_Error

    If MapNpc(Index).HP = 0 Then
        Exit Sub
    End If
    If MapNpc(Index).Num < 1 Then
        Exit Sub
    End If

    If Npc(MapNpc(Index).Num).Big = 1 Then
        X = (MapNpc(Index).X * PIC_X + sx - 9 + MapNpc(Index).xOffset) - (NewPlayerX * PIC_X) - NewXOffset
        Y = (MapNpc(Index).Y * PIC_Y + sx + MapNpc(Index).yOffset) - (NewPlayerY * PIC_Y) - NewYOffset

        Call DD_BackBuffer.SetFillColor(RGB(255, 0, 0))
        Call DD_BackBuffer.DrawBox(X, Y + 32, X + 50, Y + 36)
        Call DD_BackBuffer.SetFillColor(RGB(0, 255, 0))
        If MapNpc(Index).MaxHp < 1 Then
            Call DD_BackBuffer.DrawBox(X, Y + 32, X + ((MapNpc(Index).HP / 100) / ((MapNpc(Index).MaxHp + 1) / 100) * 50), Y + 36)
        Else
            Call DD_BackBuffer.DrawBox(X, Y + 32, X + ((MapNpc(Index).HP / 100) / (MapNpc(Index).MaxHp / 100) * 50), Y + 36)
        End If
    Else
        X = (MapNpc(Index).X * PIC_X + sx + MapNpc(Index).xOffset) - (NewPlayerX * PIC_X) - NewXOffset
        Y = (MapNpc(Index).Y * PIC_Y + sx + MapNpc(Index).yOffset) - (NewPlayerY * PIC_Y) - NewYOffset

        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))

        If MapNpc(Index).MaxHp < 1 Then
            Call DD_BackBuffer.DrawBox(X, Y + 32, X + ((MapNpc(Index).HP / 100) / ((MapNpc(Index).MaxHp + 1) / 100) * 32), Y + 36)
        Else
            Call DD_BackBuffer.DrawBox(X, Y + 32, X + ((MapNpc(Index).HP / 100) / (MapNpc(Index).MaxHp / 100) * 32), Y + 36)
        End If

    End If

    On Error GoTo 0
    Exit Sub

BltNpcBars_Error:

    If Err.Number = DDERR_CANTCREATEDC Then

    End If

End Sub

```

And this is the Players part:
```
Sub BltPlayerBars(ByVal Index As Long)
    Dim X As Long, Y As Long

    X = (GetPlayerX(Index) * PIC_X + sx + Player(Index).xOffset) - (NewPlayerX * PIC_X) - NewXOffset
    Y = (GetPlayerY(Index) * PIC_Y + sx + Player(Index).yOffset) - (NewPlayerY * PIC_Y) - NewYOffset

    If Player(Index).HP = 0 Then
        Exit Sub
    End If
    If SpriteSize = 1 Then
        ' draws the back bars
        Call DD_BackBuffer.SetFillColor(RGB(255, 0, 0))
        Call DD_BackBuffer.DrawBox(X, Y - 30, X + 32, Y - 34)

        ' draws HP
        Call DD_BackBuffer.SetFillColor(RGB(0, 255, 0))
        Call DD_BackBuffer.DrawBox(X, Y - 30, X + ((Player(Index).HP / 100) / (Player(Index).MaxHp / 100) * 32), Y - 34)
    Else
        If SpriteSize = 2 Then
            ' draws the back bars
            Call DD_BackBuffer.SetFillColor(RGB(255, 0, 0))
            Call DD_BackBuffer.DrawBox(X, Y - 30 - PIC_Y, X + 32, Y - 34 - PIC_Y)

            ' draws HP
            Call DD_BackBuffer.SetFillColor(RGB(0, 255, 0))
            Call DD_BackBuffer.DrawBox(X, Y - 30 - PIC_Y, X + ((Player(Index).HP / 100) / (Player(Index).MaxHp / 100) * 32), Y - 34 - PIC_Y)
        Else
            ' draws the back bars
            Call DD_BackBuffer.SetFillColor(RGB(255, 0, 0))
            Call DD_BackBuffer.DrawBox(X, Y + 2, X + 32, Y - 2)

            ' draws HP
            Call DD_BackBuffer.SetFillColor(RGB(0, 255, 0))
            Call DD_BackBuffer.DrawBox(X, Y + 2, X + ((Player(Index).HP / 100) / (Player(Index).MaxHp / 100) * 32), Y - 2)
        End If
    End If
End Sub
```

–---------------------------------------------

Im attempted deserve ways to get a hpbar for other players, but it backfired...
So... i think for an ScriptingPro... its a easy think.

help <3
Link to comment
Share on other sites

Try messing around with the Indexes. For example, try this:

```
' draws HP
        Call DD_BackBuffer.SetFillColor(RGB(0, 255, 0))
        Call DD_BackBuffer.DrawBox(X, y + 35, X + ((Player(Index).HP / 100) / (Player(MyIndex).MaxHp / 100) * 32), y + 31)
```
You can also try this:

```
' draws HP
        Call DD_BackBuffer.SetFillColor(RGB(0, 255, 0))
        Call DD_BackBuffer.DrawBox(X, y + 35, X + ((Player(MyIndex).HP / 100) / (Player(Index).MaxHp / 100) * 32), y + 31)
```
Link to comment
Share on other sites

AUGH. DOES ANYONE KNOW WHAT AN INDEX IS!

```
' draws HP
        Call DD_BackBuffer.SetFillColor(RGB(0, 255, 0))
        Call DD_BackBuffer.DrawBox(X, y + 35, X + ((Player(Index).HP / 100) / (Player(Index).MaxHp / 100) * 32), y + 31)

```MyIndex on the client is the index of the player running the client, "index" is a parameter passed to the function that gives the index of the player's hp bar to draw.

Why would you compare every players hp with your own, everyone doesn't have your max you know? …

*bashes head againsed wall*
Link to comment
Share on other sites

I just told him to try out some things, since I don't see why the tutorial wasn't working for him.

@[THE-KRIS:

> link=topic=50165.msg533082#msg533082 date=1251406054]
> people know what they are but most newbies to eclipse just C&P gawd we've all done it :P

I don't know if you're directing this to me, but anyway, I'm fully capable of editing the server and client source. I've reformed some of the features that Eclipse comes with, such as the personal messaging system and the trading system. Incase you haven't noticed, I've also fixed up The Oracle's friends list. It now works great.
Link to comment
Share on other sites

I'm pretty sure this is just a matter of a couple lines tops. All you'd have to do is make sure all players' health is blitted instead of just your own. I'll look into it.

What version of Eclipse are you using? I'm looking at Eclipse Stable, and it looks like this is already coded in.
Link to comment
Share on other sites

```
                    ' Blit players bar
                    If frmMirage.chkPlayerBar.Value = Checked Then
                        For I = 1 To MAX_PLAYERS
                            If IsPlaying(I) Then
                                If GetPlayerMap(I) = GetPlayerMap(MyIndex) Then
                                    Call BltPlayerBars(I)
                                End If
                            End If
                        Next I
                    End If
```
```
Sub BltPlayerBars(ByVal Index As Long)
    Dim x As Long, y As Long

    x = (GetPlayerX(Index) * PIC_X + sx + Player(Index).xOffset) - (NewPlayerX * PIC_X) - NewXOffset
    y = (GetPlayerY(Index) * PIC_Y + sx + Player(Index).yOffset) - (NewPlayerY * PIC_Y) - NewYOffset

    If Player(Index).HP = 0 Then
        Exit Sub
    End If
    If SpriteSize = 1 Then
        ' draws the back bars
        Call DD_BackBuffer.SetFillColor(RGB(255, 0, 0))
        Call DD_BackBuffer.DrawBox(x, y - 30, x + 32, y - 34)

        ' draws HP
        Call DD_BackBuffer.SetFillColor(RGB(0, 255, 0))
        Call DD_BackBuffer.DrawBox(x, y - 30, x + ((Player(Index).HP / 100) / (Player(Index).MaxHp / 100) * 32), y - 34)
    Else
        If SpriteSize = 2 Then
            ' draws the back bars
            Call DD_BackBuffer.SetFillColor(RGB(255, 0, 0))
            Call DD_BackBuffer.DrawBox(x, y - 30 - PIC_Y, x + 32, y - 34 - PIC_Y)

            ' draws HP
            Call DD_BackBuffer.SetFillColor(RGB(0, 255, 0))
            Call DD_BackBuffer.DrawBox(x, y - 30 - PIC_Y, x + ((Player(Index).HP / 100) / (Player(Index).MaxHp / 100) * 32), y - 34 - PIC_Y)
        Else
            ' draws the back bars
            Call DD_BackBuffer.SetFillColor(RGB(255, 0, 0))
            Call DD_BackBuffer.DrawBox(x, y + 2, x + 32, y - 2)

            ' draws HP
            Call DD_BackBuffer.SetFillColor(RGB(0, 255, 0))
            Call DD_BackBuffer.DrawBox(x, y + 2, x + ((Player(Index).HP / 100) / (Player(Index).MaxHp / 100) * 32), y - 2)
        End If
    End If
End Sub
```

There's no code in there restricting it to only one player's bar. If they are on the same map and health bars are enabled, you should be seeing their bars. It's set to loop for all indices.

I just multilogged, and there's no health bar over other characters…hmm...this is odd. I'll probe a bit deeper into this.

Whoa...found the error. Apparently, Eclipse doesn't send HP info from other players. I took out the line about "If Player(index).HP = 0" and it works, except it reads all others' health as 0\. I'll see about making the server send that info to all clients on the same map.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...