

void DrawPVEBracketBox ( LPDIRECT3DDEVICE9 pDevice, CPlayer* pPlayer, D3DCOLOR Color )
{
// Cabeça do boneco;
D3DXVECTOR3 pHead = GetBonePosition ( pPlayer->Object, M_BONE_HEAD );
// Pé do boneco;
D3DXVECTOR3 pLFoot = GetBonePosition ( pPlayer->Object, M_BONE_L_FOOT );
D3DXVECTOR3 pRFoot = GetBonePosition ( pPlayer->Object, M_BONE_R_FOOT );
if ( WorldToScreens ( pDevice, &pHead ) && WorldToScreens ( pDevice, &pLFoot ) && WorldToScreens ( pDevice, &pRFoot ) )
{
// Calcular tamanho;
D3DXVECTOR3 pBox = pHead - pRFoot;
if ( pBox.y < 0 )
pBox.y *= -1;
int pBoxHidg = ( int ) pBox.y / 2;
int pDrawX = ( int ) pHead.x - ( pBoxHidg / 2 );
int pDrawX2 = ( int ) pHead.x + ( pBoxHidg / 2 );
FillRGB ( pDrawX, pHead.y - 0, 10, 1, Color, pDevice );
FillRGB ( pDrawX, pHead.y - 0, 1, 10, Color, pDevice );
FillRGB ( pDrawX, pLFoot.y - 10, 1, 10, Color, pDevice );
FillRGB ( pDrawX, pLFoot.y - 0, 10, 1, Color, pDevice );
FillRGB ( pDrawX2, pHead.y - 0, 10, 1, Color, pDevice );
FillRGB ( pDrawX2 + 10, pHead.y - 0, 1, 10, Color, pDevice );
FillRGB ( pDrawX2 + 10, pLFoot.y - 10, 1, 10, Color, pDevice );
FillRGB ( pDrawX2 - 0, pLFoot.y - 0, 10, 1, Color, pDevice );
}
}
void DrawHealthBar(LPDIRECT3DDEVICE9 pDevice, CPlayer* Player)
{
D3DXVECTOR3 MidPosition, pLeftTop, pLeftBottom, pRightBottom, pRightTop;
// Validate player
if (!IsValidClient(Player)) return;
// Get player structures positions
MidPosition = GetMidPoint(GetBonePosition(Player->Object, 6), GetBonePosition(Player->Object, 3));
pRightBottom = MidPosition + D3DXVECTOR3(50, -160, 0); // <- Right Bottom
pRightTop = MidPosition + D3DXVECTOR3(50, 160, 0); // <- Right Top
if (WorldToScreen(pDevice, &pRightBottom) && WorldToScreen(pDevice, &pRightTop))
{
// Player Box
D3DXVECTOR3 hBox = pRightBottom - pRightTop; // Foot - Head
// Health
DWORD healthColor = 0xFF00FF00;
int health = (Player->Health > 0) ? Player->Health : 100;
// Get Health color
if (health > 80)
healthColor = 0xFF00FF00;
else if (health > 60)
healthColor = 0xFFFFFF00;
else if (health > 40)
healthColor = 0xFFFF4500;
else
healthColor = 0xFFFF0000;
if (hBox.y < 0) hBox.y *= -1;
// Box Width/position
int BoxWidth = (int)hBox.y;
int BarX = (int)pRightTop.x;
int BarY = (int)pRightTop.y;
// Bar width / position fix
int BarWidth = (int)((health * BoxWidth) / 100);
int barDiff = (BoxWidth - BarWidth);
// Draw health background
FillRGB(BarX + 5, BarY - 2, 5, BoxWidth + 1, 0xFF000000, pDevice);
// Draw health fill
FillRGB(BarX + 6, BarY + barDiff - 1, 3, BarWidth, healthColor, pDevice);
}
}

