From: terencehill Date: Sun, 23 Sep 2018 16:35:39 +0000 (+0200) Subject: Fix #2079: "Progress indicator sometimes missing when reviving teammates in FT" X-Git-Tag: xonotic-v0.8.5~1827^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=580576b90652584173de870eb97dc8584308497e;p=xonotic%2Fxonotic-data.pk3dir.git Fix #2079: "Progress indicator sometimes missing when reviving teammates in FT" --- diff --git a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc index be6e92523..32a956857 100644 --- a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc +++ b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc @@ -454,6 +454,15 @@ MUTATOR_HOOKFUNCTION(ft, Unfreeze) targ.freezetag_frozen_timeout = 0; } +#ifdef IS_REVIVING + #undef IS_REVIVING +#endif + +// returns true if player is reviving it +#define IS_REVIVING(player, it, revive_extra_size) \ + (it != player && !STAT(FROZEN, it) && !IS_DEAD(it) && SAME_TEAM(it, player) \ + && boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax)) + MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST) { if(game_stopped) @@ -465,6 +474,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST) int n; entity o = NULL; + vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size; entity player = M_ARGV(0, entity); //if (STAT(FROZEN, player) == FROZEN_NORMAL) //if(player.freezetag_frozen_timeout > 0 && time < player.freezetag_frozen_timeout) @@ -474,18 +484,11 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST) n = -1; else { - vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size; n = 0; - FOREACH_CLIENT(IS_PLAYER(it) && it != player, { - if (!STAT(FROZEN, it) && !IS_DEAD(it) && SAME_TEAM(it, player)) - if(boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax)) - { - if(!o) - o = it; - if (STAT(FROZEN, player) == FROZEN_NORMAL) - it.reviving = true; - ++n; - } + FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), { + if(!o) + o = it; + ++n; }); } @@ -507,10 +510,10 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST) } // EVERY team mate nearby gets a point (even if multiple!) - FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, { + FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), { GameRules_scoring_add(it, FREEZETAG_REVIVALS, +1); GameRules_scoring_add(it, SCORE, +1); - nades_GiveBonus(it,autocvar_g_nades_bonus_score_low); + nades_GiveBonus(it, autocvar_g_nades_bonus_score_low); }); Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname); @@ -518,9 +521,8 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST) Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED, player.netname, o.netname); } - FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, { + FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), { STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player); - it.reviving = false; }); } else if (!n && STAT(FROZEN, player) == FROZEN_NORMAL) // only if no teammate is nearby will we reset diff --git a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qh b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qh index 4a3d80fd1..d637ae46f 100644 --- a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qh +++ b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qh @@ -27,8 +27,6 @@ const float ICE_MAX_ALPHA = 1; const float ICE_MIN_ALPHA = 0.1; float freezetag_teams; -.float reviving; // temp var - float autocvar_g_freezetag_revive_extra_size; float autocvar_g_freezetag_revive_speed; bool autocvar_g_freezetag_revive_nade; diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index b6dafe760..45a6bae97 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -1258,6 +1258,15 @@ MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST) } } +#ifdef IS_REVIVING + #undef IS_REVIVING +#endif + +// returns true if player is reviving it +#define IS_REVIVING(player, it, revive_extra_size) \ + (it != player && !STAT(FROZEN, it) && !IS_DEAD(it) && SAME_TEAM(it, player) \ + && boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax)) + MUTATOR_HOOKFUNCTION(nades, PlayerPreThink) { entity player = M_ARGV(0, entity); @@ -1330,21 +1339,16 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink) int n = 0; entity o = NULL; + vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size; if(player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout) n = -1; else if (STAT(FROZEN, player) == FROZEN_TEMP_DYING) { - vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size; n = 0; - FOREACH_CLIENT(IS_PLAYER(it) && it != player, { - if (!IS_DEAD(it) && !STAT(FROZEN, it) && SAME_TEAM(it, player)) - if(boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax)) - { - if(!o) - o = it; - it.reviving = true; - ++n; - } + FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), { + if(!o) + o = it; + ++n; }); } @@ -1361,9 +1365,8 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink) Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname); } - FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, { + FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), { STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player); - it.reviving = false; }); } }