Skip to content

Commit

Permalink
Merge pull request #235 from actionquake/ghud/player-stat-bar
Browse files Browse the repository at this point in the history
GHUD - Add Player stats + Timer Bar
  • Loading branch information
darkshade9 authored Nov 8, 2024
2 parents 1cca1cc + a229048 commit 897d571
Show file tree
Hide file tree
Showing 11 changed files with 748 additions and 281 deletions.
6 changes: 4 additions & 2 deletions inc/shared/gameext.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ typedef struct {
game_import_ex_t
These pointer functions exist in the engine (server), and this enables importing them to be available for use by the gamelib
These pointer functions exist in the engine (server),
and this enables importing them to be available for use by the gamelib
server->gamedll
Expand All @@ -91,7 +92,8 @@ typedef struct {
game_export_ex_t
These pointer functions exist in the gamedll, and this enables importing them to be available for use by the engine (server)
These pointer functions exist in the gamedll,
and this enables importing them to be available for use by the engine (server)
gamedll->server
Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ game_deps = [zlib]
jpeg = dependency('libjpeg',
required: get_option('libjpeg'),
default_options: fallback_opt + [ 'jpeg-turbo=disabled', 'tests=disabled' ],
static: true
)

if jpeg.found()
Expand Down
3 changes: 3 additions & 0 deletions src/action/a_ctf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,9 @@ void CTFCapReward(edict_t * ent)

void CTFSetupStatusbar( void )
{
// Frags closer to the team scores
Q_strncatz(level.statusbar, "xr -76 yb -188 num 3 14 ", sizeof(level.statusbar));

Q_strncatz(level.statusbar,
// Red Team
"yb -164 " "if 24 " "xr -24 " "pic 24 " "endif " "xr -60 " "num 2 26 "
Expand Down
16 changes: 10 additions & 6 deletions src/action/g_combat.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,9 +865,11 @@ void T_Damage (edict_t * targ, edict_t * inflictor, edict_t * attacker, const ve
if (client && attacker->client)
{
if (!friendlyFire && !in_warmup) {
attacker->client->resp.damage_dealt += damage;
// Hit markers
attacker->client->damage_dealt += damage;
if (mod != MOD_TELEFRAG) {
attacker->client->resp.damage_dealt += damage;
// Hit markers
attacker->client->damage_dealt += damage;
}
if (mod > 0 && mod < MAX_GUNSTAT) {
attacker->client->resp.gunstats[mod].damage += damage;
}
Expand Down Expand Up @@ -930,9 +932,11 @@ void T_Damage (edict_t * targ, edict_t * inflictor, edict_t * attacker, const ve
if (attacker->client)
{
if (!friendlyFire && !in_warmup) {
attacker->client->resp.damage_dealt += damage;
// Hit markers
attacker->client->damage_dealt += damage;
if (mod != MOD_TELEFRAG) {
attacker->client->resp.damage_dealt += damage;
// Hit markers
attacker->client->damage_dealt += damage;
}
// All normal weapon damage
if (mod > 0 && mod < MAX_GUNSTAT) {
attacker->client->resp.gunstats[mod].damage += damage;
Expand Down
5 changes: 5 additions & 0 deletions src/action/g_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,11 @@ void Ghud_SetSize(edict_t *ent, int i, int x, int y)
engine_Ghud_SetSize(ent, i, x, y);
}

/* anchor is a float from 0 to 1, 0 being left/top, 1 being right/bottom
for example, 0.5, 0.5 is center
0, 0 is top left
1, 1 is bottom right
*/
void Ghud_SetAnchor(edict_t *ent, int i, float x, float y)
{
if (!engine_Ghud_SetAnchor)
Expand Down
10 changes: 10 additions & 0 deletions src/action/g_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -2955,6 +2955,16 @@ typedef enum {
h_team_l_num,
h_team_r,
h_team_r_num,
h_spectator_stats = 66, // display up to 5 stats at once
h_spectator_stats_bar = 74, // h_spectator_stats_bar text is 75
h_spectator_name_bar = 76, // h_spectator_name_bar text is 77
h_spectator_timer = 78,
h_spectator_timer_border,
h_spectator_time_tm,
h_spectator_time_mm,
h_spectator_time_ts,
h_spectator_time_ss,
h_spectator_time_sep, // Time seperator (:)
} huditem_t;

void HUD_SetType(edict_t *clent, int type);
Expand Down
11 changes: 9 additions & 2 deletions src/action/g_spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1710,8 +1710,15 @@ void G_SetupStatusbar( void )
{
Q_strncpyz(level.statusbar, STATBAR_COMMON, sizeof(level.statusbar));

if(!((noscore->value || hud_noscore->value) && teamplay->value)) // frags
Q_strncatz(level.statusbar, "xr -50 yt 2 num 3 14 ", sizeof(level.statusbar));
// if(!((noscore->value || hud_noscore->value) && teamplay->value) && !ctf->value) // frags
// Q_strncatz(level.statusbar, "xr -50 yt 2 num 3 14 ", sizeof(level.statusbar));

// Display frags in top-right corner if teamplay, but not in CTF (moved that to CTFSetupStatusbar())
if (!(noscore->value || hud_noscore->value) || !teamplay->value) {
if (!ctf->value) {
Q_strncatz(level.statusbar, "xr -50 yt 2 num 3 14 ", sizeof(level.statusbar));
}
}

if (ctf->value)
CTFSetupStatusbar();
Expand Down
4 changes: 4 additions & 0 deletions src/action/p_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -6275,6 +6275,10 @@ void ClientBeginServerFrame(edict_t * ent)
// then Action!
EspRespawnPlayer(ent);
}
#ifdef AQTION_EXTENSION
// Redraw GHUD
HUD_SetType(ent, 1);
#endif
}
else
{
Expand Down
Loading

0 comments on commit 897d571

Please sign in to comment.