For long time i was looking the way to show the health and armour (in my client) above the playermodels (like in warsow) and, thx to your client i can do it. Thx guys for help me (indirectly). all credit is for you guys.
you can see here:
and here the code (file src/fpsgame/render.cpp):
void rendergame(bool mainpass)
{
if(mainpass) ai::render();
if(intermission)
{
bestteams.shrink(0);
bestplayers.shrink(0);
if(m_teammode) getbestteams(bestteams);
else getbestplayers(bestplayers);
}
startmodelbatches();
fpsent *exclude = isthirdperson() ? NULL : followingplayer();
loopv(players)
{
fpsent *d = players[i];
if(d == player1 || d->state==CS_SPECTATOR || d->state==CS_SPAWNING || d->lifesequence < 0 || d == exclude || (d->state==CS_DEAD && hidedead)) continue;
int team = 0;
if(teamskins || m_teammode) team = isteam(player1->team, d->team) ? 1 : 2;
renderplayer(d, getplayermodelinfo(d), team, 1, mainpass);
copystring(d->info, colorname(d));
if(d->maxhealth>100) { defformatstring(sn)(" +%d", d->maxhealth-100); concatstring(d->info, sn); }
bool specorsameteam = (player1->state==CS_SPECTATOR) ? true : isteam(player1->team, d->team);
if(m_teammode && !m_insta && specorsameteam && d->state!=CS_DEAD) {
// -------------- here is the code ----------------------
particle_meter(d->abovehead(), d->armour/100.0f, PART_METER, 1, 0xFF4500, 0, 1.0f);
particle_meter(d->abovehead().add(vec(0, 0, 1)), d->health/100.0f , PART_METER, 1, 0x00FF00, 0, 1.0f);
particle_text(d->abovehead().add(vec(0, 0, 3)), d->info, PART_TEXT, 1, 0x6496FF, 2.0f);
}
else if(d->state!=CS_DEAD) particle_text(d->abovehead(), d->info, PART_TEXT, 1, team ? (team==1 ? 0x6496FF : 0xFF4B19) : 0x1EC850, 2.0f);
}
loopv(ragdolls)
{
fpsent *d = ragdolls[i];
int team = 0;
if(teamskins || m_teammode) team = isteam(player1->team, d->team) ? 1 : 2;
float fade = 1.0f;
if(ragdollmillis && ragdollfade)
fade -= clamp(float(lastmillis - (d->lastupdate + max(ragdollmillis - ragdollfade, 0)))/min(ragdollmillis, ragdollfade), 0.0f, 1.0f);
renderplayer(d, getplayermodelinfo(d), team, fade, mainpass);
}
if(isthirdperson() && !followingplayer() && (player1->state!=CS_DEAD || !hidedead)) renderplayer(player1, getplayermodelinfo(player1), teamskins || m_teammode ? 1 : 0, 1, mainpass);
rendermonsters();
rendermovables();
entities::renderentities();
renderbouncers();
renderprojectiles();
if(cmode) cmode->rendergame();
endmodelbatches();
}
Of course needed some adjust, for example in
ctf mode we can get more than 100 (of shield) wiht yellow armour and we can get more than 100 (health) wiht the healt bonus.
I prefer this way to show the health and armour than only show some text, if you wanna added to your client will be great.