From a2c029c53b1d042f029331d6ebe8eec20dbbc531 Mon Sep 17 00:00:00 2001 From: Lyberta Date: Mon, 11 Jun 2018 18:14:53 +0300 Subject: [PATCH] GunGame: Even more polish. --- .../gamemodes/gamemode/gungame/sv_gungame.qc | 39 +++++++++++++------ qcsrc/common/notifications/all.inc | 4 ++ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/gungame/sv_gungame.qc b/qcsrc/common/gamemodes/gamemode/gungame/sv_gungame.qc index 0a748964a..cccfc72dc 100644 --- a/qcsrc/common/gamemodes/gamemode/gungame/sv_gungame.qc +++ b/qcsrc/common/gamemodes/gamemode/gungame/sv_gungame.qc @@ -14,7 +14,7 @@ const string GUNGAME_WEAPONS_CVAR = "g_gg_weapons"; /// \brief Number of kills needed to advance to the next weapon. int autocvar_g_gg_kills_per_weapon; -int gungame_max_level; ///< Player who reaches this level wins. +int gungame_win_level; ///< Player who reaches this level wins. string gungame_weapons; ///< Holds weapons corresponding to levels. entity gungame_leading_player; ///< Holds the leading player. @@ -44,13 +44,13 @@ void GunGame_Initialize() void GunGame_Reset() { strcpy(gungame_weapons, cvar_string(GUNGAME_WEAPONS_CVAR)); - gungame_max_level = tokenize_console(gungame_weapons) * + gungame_win_level = tokenize_console(gungame_weapons) * autocvar_g_gg_kills_per_weapon; - if (gungame_max_level == 0) + if (gungame_win_level == 0) { LOG_FATAL("GunGame: Invalid weapon configuration."); } - GameRules_limit_score(gungame_max_level); + GameRules_limit_score(gungame_win_level); gungame_leading_player = NULL; gungame_leading_level = 0; gungame_leading_weapon = GunGame_GetWeapon(0); @@ -59,7 +59,7 @@ void GunGame_Reset() entity GunGame_GetWeapon(int level) { - if (level >= gungame_max_level) + if (level >= gungame_win_level) { return NULL; } @@ -131,16 +131,33 @@ void GunGame_UpdateStats() void GunGame_GivePlayerWeapon(entity player) { int level = GunGame_GetPlayerLevel(player); - if (level >= gungame_max_level) + if (level >= gungame_win_level) { return; } entity weapon = GunGame_GetWeapon(level); STAT(WEAPONS, player) |= weapon.m_wepset; - Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_GUNGAME_NEW_LEVEL, - level + 1, weapon.m_id); - Send_Notification(NOTIF_ONE, player, MSG_INFO, INFO_GUNGAME_NEW_LEVEL, - level + 1, weapon.m_id); + int levels_left = gungame_win_level - level; + if (levels_left > 3) + { + Send_Notification(NOTIF_ONE, player, MSG_CENTER, + CENTER_GUNGAME_NEW_LEVEL, level + 1, weapon.m_id); + Send_Notification(NOTIF_ONE, player, MSG_INFO, INFO_GUNGAME_NEW_LEVEL, + level + 1, weapon.m_id); + return; + } + if (levels_left > 1) + { + Send_Notification(NOTIF_ONE, player, MSG_CENTER, + CENTER_GUNGAME_LEVELS_LEFT, levels_left, weapon.m_id); + Send_Notification(NOTIF_ONE, player, MSG_INFO, INFO_GUNGAME_LEVELS_LEFT, + levels_left, weapon.m_id); + return; + } + Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_GUNGAME_LAST_LEVEL, + weapon.m_id); + Send_Notification(NOTIF_ONE, player, MSG_INFO, INFO_GUNGAME_LAST_LEVEL, + weapon.m_id); } //============================= Hooks ======================================== @@ -215,7 +232,7 @@ MUTATOR_HOOKFUNCTION(gg, PlayerDies) GunGame_UpdateLeadingPlayer(); entity attacker = M_ARGV(1, entity); if (!IS_PLAYER(attacker) || IS_DEAD(attacker) || (GunGame_GetPlayerLevel( - attacker) >= gungame_max_level)) + attacker) >= gungame_win_level)) { return; } diff --git a/qcsrc/common/notifications/all.inc b/qcsrc/common/notifications/all.inc index eee8a3a1e..25606a722 100644 --- a/qcsrc/common/notifications/all.inc +++ b/qcsrc/common/notifications/all.inc @@ -375,6 +375,8 @@ MSG_INFO_NOTIF(GODMODE_OFF, N_CONSOLE, 0, 1, "f1", "", "", _("^BGGodmode saved you %s units of damage, cheater!"), "") MSG_INFO_NOTIF(GUNGAME_NEW_LEVEL, N_CONSOLE, 0, 2, "f1 item_wepname2", "", "", _("^BGYou are on level %s: ^F1%s"), "") + MSG_INFO_NOTIF(GUNGAME_LEVELS_LEFT, N_CONSOLE, 0, 2, "f1 item_wepname2", "", "", _("^BG%s levels left: ^F1%s"), "") + MSG_INFO_NOTIF(GUNGAME_LAST_LEVEL, N_CONSOLE, 0, 1, "item_wepname", "", "", _("^BGLAST LEVEL: ^F1%s"), "") MSG_INFO_NOTIF(ITEM_BUFF, N_CONSOLE, 1, 1, "s1 item_buffname", "", "", _("^BG%s^BG got the %s^BG buff!"), "") MSG_INFO_NOTIF(ITEM_BUFF_LOST, N_CONSOLE, 1, 1, "s1 item_buffname", "", "", _("^BG%s^BG lost the %s^BG buff!"), "") @@ -695,6 +697,8 @@ MSG_CENTER_NOTIF(FREEZETAG_SPAWN_LATE, N_ENABLE, 0, 0, "", CPID_Null, "0 0", _("^K1Round already started, you spawn as frozen"), "") MSG_CENTER_NOTIF(GUNGAME_NEW_LEVEL, N_ENABLE, 0, 2, "f1 item_wepname2", CPID_Null, "0 0", _("^F2Level %s: ^F1%s"), "") + MSG_CENTER_NOTIF(GUNGAME_LEVELS_LEFT, N_ENABLE, 0, 2, "f1 item_wepname2", CPID_Null, "0 0", _("^F2%s levels left: ^F1%s"), "") + MSG_CENTER_NOTIF(GUNGAME_LAST_LEVEL, N_ENABLE, 0, 1, "item_wepname", CPID_Null, "0 0", _("^F2LAST LEVEL: ^F1%s"), "") MSG_CENTER_NOTIF(INVASION_SUPERMONSTER, N_ENABLE, 1, 0, "s1", CPID_Null, "0 0", _("^K1A %s has arrived!"), "") -- 2.39.2