From: z411 Date: Sat, 7 Nov 2020 18:44:49 +0000 (-0300) Subject: Spectator HUD: Added weapon display X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4eb0d308cd0e2769110ff2dcad5087de031bb1fd;p=xonotic%2Fxonotic-data.pk3dir.git Spectator HUD: Added weapon display --- diff --git a/qcsrc/client/hud/panel/spect.qc b/qcsrc/client/hud/panel/spect.qc index 92eff46db..fc8fd89aa 100644 --- a/qcsrc/client/hud/panel/spect.qc +++ b/qcsrc/client/hud/panel/spect.qc @@ -27,8 +27,8 @@ void HUD_SpectHUD_drawTeamPlayers(vector pos, entity tm, vector rgb, bool invert vector tmp_over; vector line_sz = vec2((vid_conwidth - 1) / 7, hud_fontsize.y * 1.5); vector line_sz_sub = vec2((vid_conwidth - 1) / 7, hud_fontsize.y); - vector total_sz = vec2(line_sz.x, line_sz.y + line_sz_sub.y); - string tmp_str; + + string playername; float a = panel_fg_alpha * 0.8; entity pl; @@ -44,33 +44,73 @@ void HUD_SpectHUD_drawTeamPlayers(vector pos, entity tm, vector rgb, bool invert float health = 0; float armor = 0; + string icon = ""; + vector icon_size = '0 0 0'; + vector icon_rgb = '1 1 1'; + // Position and size calculation vectors tmp_over = pos; - tmp_str = textShortenToWidth(entcs_GetName(pl.sv_entnum), line_sz.x * 0.8, hud_fontsize, stringwidth_colors); + vector total_sz = vec2(line_sz.x, line_sz.y + line_sz_sub.y); + + if(pl.eliminated) { + // z411 TODO : Unhardcode luma + icon = "gfx/hud/luma/notify_death.tga"; + icon_rgb = rgb; + } else { + entity entcs = entcs_receiver(pl.sv_entnum); + if(entcs.m_entcs_private) { + health = (entcs.healthvalue / autocvar_hud_panel_healtharmor_maxhealth) * line_sz.x; + armor = (GetResource(entcs, RES_ARMOR) / autocvar_hud_panel_healtharmor_maxarmor) * line_sz_sub.x; + + Weapon wep = REGISTRY_GET(Weapons, entcs.activewepid); + icon = strcat("gfx/hud/luma/", wep.model2); + } else { + if(tm.team == NUM_TEAM_1) + icon = "gfx/hud/luma/player_red"; + else if(tm.team == NUM_TEAM_2) + icon = "gfx/hud/luma/player_blue"; + else + icon = "gfx/hud/luma/player_neutral"; + } + } - entity entcs = entcs_receiver(pl.sv_entnum); - if(entcs.m_entcs_private) { - health = (entcs.healthvalue / autocvar_hud_panel_healtharmor_maxhealth) * line_sz.x; - armor = (GetResource(entcs, RES_ARMOR) / autocvar_hud_panel_healtharmor_maxarmor) * line_sz_sub.x; + // Draw weapon + if(icon != "") { + vector tmp_sz = draw_getimagesize(icon); + icon_size = vec2(total_sz.y*(tmp_sz.x/tmp_sz.y), total_sz.y); + total_sz.x += icon_size.x; + + if(invert) { + pos.x -= icon_size.x; + tmp_over.x -= icon_size.x; + } + drawpic(pos, icon, icon_size, icon_rgb, panel_fg_alpha, DRAWFLAG_NORMAL); + pos.x += icon_size.x; } + // Get player's name + playername = textShortenToWidth(entcs_GetName(pl.sv_entnum), line_sz.x * 0.8, hud_fontsize, stringwidth_colors); + // Draw health and name drawfill(pos, line_sz, rgb * 0.7, a * 0.3, DRAWFLAG_NORMAL); if(health) drawfill(pos, vec2(health, line_sz.y), rgb * 0.7, a, DRAWFLAG_NORMAL); - drawcolorcodedstring(pos + eY * ((line_sz.y - hud_fontsize.y) / 2) + eX * (hud_fontsize.x * 0.5), tmp_str, hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); + drawcolorcodedstring(pos + eY * ((line_sz.y - hud_fontsize.y) / 2) + eX * (hud_fontsize.x * 0.5), playername, hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); pos.y += line_sz.y; // Draw armor if(armor) drawfill(pos, vec2(armor, line_sz_sub.y), rgb, a, DRAWFLAG_NORMAL); - pos.y += line_sz_sub.y * 2; // Highlight current player if(pl.sv_entnum == current_player) drawfill(tmp_over, total_sz, '1 1 1', 0.3, DRAWFLAG_NORMAL); if(pl.eliminated) - drawfill(tmp_over, total_sz, '0 0 0', 0.3, DRAWFLAG_NORMAL); + drawfill(tmp_over, total_sz, '0 0 0', 0.4, DRAWFLAG_NORMAL); + + if(!invert) + pos.x -= icon_size.x; + pos.y += line_sz_sub.y * 2; } } diff --git a/qcsrc/common/ent_cs.qc b/qcsrc/common/ent_cs.qc index e785aea53..7a06825ba 100644 --- a/qcsrc/common/ent_cs.qc +++ b/qcsrc/common/ent_cs.qc @@ -161,6 +161,11 @@ ENTCS_PROP(SOLID, true, sv_solid, solid, ENTCS_SET_NORMAL, { WriteByte(chan, ent.sv_solid); }, { ent.sv_solid = ReadByte(); }) +// z411 weapon +ENTCS_PROP(ACTIVEWEPID, false, activewepid, activewepid, ENTCS_SET_NORMAL, + { WriteByte(chan, ent.activewepid); }, + { ent.activewepid = ReadByte(); }) + #ifdef SVQC int ENTCS_PUBLICMASK = 0; diff --git a/qcsrc/common/ent_cs.qh b/qcsrc/common/ent_cs.qh index 30ee83bbc..3faef872f 100644 --- a/qcsrc/common/ent_cs.qh +++ b/qcsrc/common/ent_cs.qh @@ -21,6 +21,7 @@ REGISTER_NET_TEMP(CLIENT_ENTCS) .bool has_sv_origin; #endif .int sv_solid; +.int activewepid; // z411 #ifdef SVQC /* diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 37c09eb0b..1958c9519 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -548,6 +548,7 @@ void W_WeaponFrame(Player actor, .entity weaponentity) this.m_weapon = newwep; this.weaponname = newwep.mdl; this.bulletcounter = 0; + actor.activewepid = newwep.m_id; // z411 newwep.wr_setup(newwep, actor, weaponentity); this.state = WS_RAISE;