From 809c36fa22f9220e9b405b2fcc4003dc0b8fcf86 Mon Sep 17 00:00:00 2001 From: z411 Date: Sat, 3 Oct 2020 02:07:24 -0300 Subject: [PATCH] Added defense medal in CA and FT --- qcsrc/client/hud/panel/scoreboard.qc | 7 ++-- qcsrc/client/main.qc | 2 -- .../gamemode/clanarena/sv_clanarena.qc | 21 ++++++++++++ .../gamemode/freezetag/sv_freezetag.qc | 21 ++++++++++++ qcsrc/common/medals.qh | 33 ------------------- qcsrc/common/medals/all.qh | 33 ------------------- 6 files changed, 47 insertions(+), 70 deletions(-) delete mode 100644 qcsrc/common/medals.qh delete mode 100644 qcsrc/common/medals/all.qh diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index 0fcb5c560..5e75693fb 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -1442,9 +1442,7 @@ vector Scoreboard_MedalStats_Draw(vector pos) total_medals = 0; pos = Scoreboard_DrawMedal(pos, "gfx/medal/airshot", height, pl.(scores(SP_MEDAL_AIRSHOT))); - pos = Scoreboard_DrawMedal(pos, "gfx/medal/assist", height, pl.(scores(SP_MEDAL_ASSIST))); pos = Scoreboard_DrawMedal(pos, "gfx/medal/damage", height, pl.(scores(SP_MEDAL_DAMAGE))); - pos = Scoreboard_DrawMedal(pos, "gfx/medal/defense", height, pl.(scores(SP_MEDAL_DEFENSE))); pos = Scoreboard_DrawMedal(pos, "gfx/medal/electrobitch", height, pl.(scores(SP_MEDAL_ELECTROBITCH))); pos = Scoreboard_DrawMedal(pos, "gfx/medal/excellent", height, pl.(scores(SP_MEDAL_EXCELLENT))); pos = Scoreboard_DrawMedal(pos, "gfx/medal/firstblood", height, pl.(scores(SP_MEDAL_FIRSTBLOOD))); @@ -1453,6 +1451,11 @@ vector Scoreboard_MedalStats_Draw(vector pos) pos = Scoreboard_DrawMedal(pos, "gfx/medal/impressive", height, pl.(scores(SP_MEDAL_IMPRESSIVE))); pos = Scoreboard_DrawMedal(pos, "gfx/medal/yoda", height, pl.(scores(SP_MEDAL_YODA))); + pos.x += hud_fontsize.x * 2; + + pos = Scoreboard_DrawMedal(pos, "gfx/medal/assist", height, pl.(scores(SP_MEDAL_ASSIST))); + pos = Scoreboard_DrawMedal(pos, "gfx/medal/defense", height, pl.(scores(SP_MEDAL_DEFENSE))); + if(!total_medals) return orig; drawstring(title_pos, sprintf(_("Medal stats (total %d)"), total_medals), diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index dd01090f3..74bb88ca9 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -635,8 +635,6 @@ NET_HANDLE(ENT_CLIENT_ACCURACY, bool isnew) } f = (f == 0x800000) ? 1 : f * 2; } - - LOG_INFOF("Accuracy stats Client %d", entnum); return true; } diff --git a/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc b/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc index 1992f14b9..6c18b2d33 100644 --- a/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc +++ b/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc @@ -62,6 +62,22 @@ int CA_GetWinnerTeam() void nades_Clear(entity player); +entity ca_LastPlayer(float tm) +{ + entity last_pl = NULL; + FOREACH_CLIENT(IS_PLAYER(it) && it.team == tm, { + if (!IS_DEAD(it)) + { + if (!last_pl) + last_pl = it; + else + return NULL; + } + }); + return last_pl; +} + + float CA_CheckWinner() { if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0) @@ -87,6 +103,11 @@ float CA_CheckWinner() int winner_team = CA_GetWinnerTeam(); if(winner_team > 0) { + entity last_pl = ca_LastPlayer(winner_team); + if(last_pl) { + Give_Medal(last_pl, DEFENSE); + } + Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN)); Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN)); Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, APP_TEAM_NUM(winner_team, ANNCE_ROUND_TEAM_WIN)); diff --git a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc index 7c505abfe..88e16a1ad 100644 --- a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc +++ b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc @@ -105,6 +105,21 @@ int freezetag_getWinnerTeam() void nades_Clear(entity); void nades_GiveBonus(entity player, float score); +entity freezetag_LastPlayer(float tm) +{ + entity last_pl = NULL; + FOREACH_CLIENT(IS_PLAYER(it) && it.team == tm, { + if (STAT(FROZEN, it) != FROZEN_NORMAL && GetResource(it, RES_HEALTH) >= 1) + { + if (!last_pl) + last_pl = it; + else + return NULL; + } + }); + return last_pl; +} + bool freezetag_CheckWinner() { if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0) @@ -131,6 +146,11 @@ bool freezetag_CheckWinner() int winner_team = freezetag_getWinnerTeam(); if(winner_team > 0) { + entity last_pl = freezetag_LastPlayer(winner_team); + if(last_pl) { + Give_Medal(last_pl, DEFENSE); + } + Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_SCORES)); Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_SCORES)); Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, APP_TEAM_NUM(winner_team, ANNCE_ROUND_TEAM_WIN)); @@ -563,6 +583,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST) Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, first.netname); Send_Notification(NOTIF_ONE, first, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname); Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED, player.netname, first.netname); + Give_Medal(first, ASSIST); } for(entity it = reviving_players_first; it; it = it.chain) diff --git a/qcsrc/common/medals.qh b/qcsrc/common/medals.qh deleted file mode 100644 index b12581bb0..000000000 --- a/qcsrc/common/medals.qh +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include - -#include - -REGISTRY(Medals, 32) -REGISTER_REGISTRY(Medals) -#define REGISTER_MEDAL(id, class) REGISTER(Medals, MEDAL, id, m_id, NEW(class)) - -REGISTRY_SORT(Medals) -REGISTRY_CHECK(Medals) - -REGISTRY_DEFINE_GET(Medals, NULL) -STATIC_INIT(Medals) { FOREACH(Medals, true, it.m_id = i); } - -CLASS(Medal, Object) -ENDCLASS(Medal) - -REGISTER_MEDAL(Airshot, Medal) { - this.netname = "airshot"; - this.m_name = _("Airshot"); - this.m_icon = "airshot"; - this.m_annce = ANNCE_ACHIEVEMENT_IMPRESSIVE; -} - -REGISTER_MEDAL(Impressive, Medal) { - this.netname = "impressive"; - this.m_name = _("Impressive"); - this.m_icon = "impressive"; - //this.m_annce = ANNCE_ACHIEVEMENT_IMPRESSIVE; -} - diff --git a/qcsrc/common/medals/all.qh b/qcsrc/common/medals/all.qh deleted file mode 100644 index bfbc6104a..000000000 --- a/qcsrc/common/medals/all.qh +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include - -#include "medal.qh" - -// NOTE: 24 is the limit for the .items field -REGISTRY(Medals, 32) -REGISTER_REGISTRY(Medals) -#define REGISTER_MEDAL(id, class) REGISTER(Medals, MEDAL, id, m_id, NEW(class)) - -REGISTRY_SORT(Medals) -REGISTRY_CHECK(Medals) - -REGISTRY_DEFINE_GET(Medals, NULL) -STATIC_INIT(Medals) { FOREACH(Medals, true, it.m_id = i); } - -CLASS(Medal) -ENDCLASS(Medal) - -REGISTER_ITEM(Impressive, Medal) { -#ifdef GAMEQC - this.spawnflags = ITEM_FLAG_NORMAL | ITEM_FLAG_RESOURCE; - this.m_model = MDL_HealthSmall_ITEM; - this.m_sound = SND_HealthSmall; -#endif - this.netname = "impressive"; - this.m_name = _("Impressive"); - this.m_icon = "impressive"; -#ifdef SVQC - this.annce = ANNCE_ACHIEVEMENT_IMPRESSIVE; -#endif -} -- 2.39.2