Ok, just spent all afternoon working on a better way of this so here it is:
static ConVar hud_offsetX( "hud_offsetX", "6", FCVAR_ARCHIVE );
static ConVar hud_offsetY( "hud_offsetY", "-5", FCVAR_ARCHIVE );
static ConVar hud_offsetZ( "hud_offsetZ", "74", FCVAR_ARCHIVE );
static ConVar hud_sizeY( "hud_sizeY", "48", FCVAR_ARCHIVE );
static ConVar hud_sizeX( "hud_sizeX", "15", FCVAR_ARCHIVE );
static ConVar hud_sizeDis( "hud_sizeDis", "15", FCVAR_ARCHIVE );
void CHud_PlayerIcon::Paint( void )
{
IGameResources *G_PR = GameResources();
C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
if ( !pLocalPlayer )
return;
Vector origin;
int x, y, length, wide, tall, offsetZ, alpha;
int x1, y1, x2, y2, x3, y3, x4, y4;
float xoff, yoff, zoff;
for ( int i = 0; i < MAX_PLAYERS; i++ )
{
C_BasePlayer *pPlayer = UTIL_PlayerByIndex( i );
if( pPlayer && !pPlayer->IsLocalPlayer() )
{
if (InView(pLocalPlayer, pPlayer))
{
ArmorPer = ((float)G_PR->GetArmor( i ))
/100.0;
healthPer = (100.0-(float)G_PR->GetHealth( i
)) /100.0;
ArmorColor.SetColor(0, 255*ArmorPer, 255,
255);
healthColor.SetColor(255, 255*healthPer, 0,
255);
QAngle look = pPlayer->GetAbsAngles();
xoff = hud_offsetX.GetFloat();
yoff = hud_offsetY.GetFloat();
zoff = hud_offsetZ.GetFloat();
float ang = (look.y * PI) / 180;
Vector offset = Vector(
xoff*cos(ang)-yoff*sin(ang), xoff*sin(ang)+yoff*cos(ang), zoff );
GetVectorInScreenSpace(pPlayer->GetAbsOrigin(), x, y, &offset);
ang = ((180+pLocalPlayer->GetAbsAngles().y)
* PI) / 180;
xoff = hud_offsetX.GetFloat();
yoff = hud_offsetY.GetFloat() -
hud_sizeY.GetFloat() - hud_sizeDis.GetFloat();
zoff = hud_offsetZ.GetFloat() +
hud_sizeX.GetFloat()/2.0f;
Vector h_topc = Vector(
xoff*cos(ang)-yoff*sin(ang), xoff*sin(ang)+yoff*cos(ang), zoff);
xoff = hud_offsetX.GetFloat();
yoff = hud_offsetY.GetFloat() -
hud_sizeDis.GetFloat();
zoff = hud_offsetZ.GetFloat() -
hud_sizeX.GetFloat()/2.0f;
Vector h_botc = Vector(
xoff*cos(ang)-yoff*sin(ang), xoff*sin(ang)+yoff*cos(ang), zoff);
xoff = hud_offsetX.GetFloat();
yoff = hud_offsetY.GetFloat() +
hud_sizeDis.GetFloat();
zoff = hud_offsetZ.GetFloat() +
hud_sizeX.GetFloat()/2.0f;
Vector a_topc = Vector(
xoff*cos(ang)-yoff*sin(ang), xoff*sin(ang)+yoff*cos(ang), zoff);
xoff = hud_offsetX.GetFloat();
yoff = hud_offsetY.GetFloat() +
hud_sizeY.GetFloat() + hud_sizeDis.GetFloat();
zoff = hud_offsetZ.GetFloat() -
hud_sizeX.GetFloat()/2.0f;
Vector a_botc = Vector(
xoff*cos(ang)-yoff*sin(ang), xoff*sin(ang)+yoff*cos(ang), zoff);
GetVectorInScreenSpace(pPlayer->GetAbsOrigin(), x1, y1, &h_topc);
GetVectorInScreenSpace(pPlayer->GetAbsOrigin(), x2, y2, &h_botc);
GetVectorInScreenSpace(pPlayer->GetAbsOrigin(), x3, y3, &a_topc);
GetVectorInScreenSpace(pPlayer->GetAbsOrigin(), x4, y4, &a_botc);
gHUD.DrawIconPB_Size( x3, y3, x4-x3, y4-y3,
m_icon_rb, m_icon_rbe, ArmorPer, ArmorColor, CHud::HUDPB_VERTICAL );
gHUD.DrawIconPB_Size( x1, y1, x2-x1, y2-y1,
m_icon_lb, m_icon_lbe, healthPer, healthColor, CHud::HUDPB_VERTICAL );
}
}
}
}
Basicly its used to draw health and armor (like on the crosshair except
above the player)
This code is not finished and not optimized (still working on that) but it
works and scales the image automaticly.
Parts might need to be changed to suit your mod.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dest Romano
Sent: Wednesday, April 18, 2007 7:38 AM
To: [email protected]
Subject: Re: [hlcoders] Client Side Text
The client text is now working perfectly with Oliver's reminder of putting
the class in hudlayout.res
Thanks Oliver, you will receive full acknowledgment for your contribution in
my mod. And I checked out your modification, High Five, looks really neat.
And for your mod, you could try assigning players randomly generated colors
for the client text just for fun. Thanks!
_________________________________________________________________
Exercise your brain! Try Flexicon.
http://games.msn.com/en/flexicon/default.htm?icid=flexicon_hmemailtaglineapr
il07
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders