}
}
-#ifdef IS_REVIVING
- #undef IS_REVIVING
+#ifdef IN_REVIVING_RANGE
+ #undef IN_REVIVING_RANGE
#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) \
+#define IN_REVIVING_RANGE(player, it, revive_extra_size) \
+ (it != player && !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 (!(frametime && IS_PLAYER(player)))
return true;
- entity reviving_players_last = NULL;
- entity reviving_players_first = NULL;
+ entity revivers_last = NULL;
+ entity revivers_first = NULL;
+ bool player_is_reviving = false;
int n = 0;
vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
- FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), {
+ FOREACH_CLIENT(IS_PLAYER(it), {
+ // check if player is reviving anyone
+ if (STAT(FROZEN, it) == FROZEN_NORMAL)
+ {
+ if ((STAT(FROZEN, player) == FROZEN_NORMAL))
+ continue;
+ if (!IN_REVIVING_RANGE(player, it, revive_extra_size))
+ continue;
+ player_is_reviving = true;
+ break;
+ }
+
+ if (!(STAT(FROZEN, player) == FROZEN_NORMAL))
+ continue; // both player and it are NOT frozen
+ if (!IN_REVIVING_RANGE(player, it, revive_extra_size))
+ continue;
+
+ // found a teammate that is reviving player
if (autocvar_g_freezetag_revive_time_to_score > 0 && STAT(FROZEN, player) == FROZEN_NORMAL)
{
it.freezetag_revive_time += frametime / autocvar_g_freezetag_revive_time_to_score;
it.freezetag_revive_time -= 1;
}
}
- if (reviving_players_last)
- reviving_players_last.chain = it;
- reviving_players_last = it;
- if (!reviving_players_first)
- reviving_players_first = it;
+ if (revivers_last)
+ revivers_last.chain = it;
+ revivers_last = it;
+ if (!revivers_first)
+ revivers_first = it;
++n;
});
- if (reviving_players_last)
- reviving_players_last.chain = NULL;
+ if (revivers_last)
+ revivers_last.chain = NULL;
// allow normal revival during automatic revival
- // (not allowing it IS_REVIVING should check freezetag_frozen_timeout too)
+ // (if we wouldn't allow it then freezetag_frozen_timeout should be checked too in the previous loop)
+ //if (STAT(FROZEN, player) == FROZEN_NORMAL) // redundant check
if (!n && player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout)
n = -1;
else
STAT(REVIVE_PROGRESS, player) = bound(base_progress, STAT(REVIVE_PROGRESS, player) - frametime * clearspeed * (1 - base_progress), 1);
}
- else if (!STAT(FROZEN, player))
+ else if (!STAT(FROZEN, player) && !player_is_reviving)
STAT(REVIVE_PROGRESS, player) = base_progress; // thawing nobody
}
else if (STAT(FROZEN, player) == FROZEN_NORMAL) // OK, there is at least one teammate reviving us
if(n == -1)
{
+ if(autocvar_sv_eventlog)
+ GameLogEcho(strcat(":ft:autorevival:", ftos(player.playerid)));
Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_AUTO_REVIVED, frozen_time);
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_AUTO_REVIVED, player.netname, frozen_time);
return true;
}
// EVERY team mate nearby gets a point (even if multiple!)
- for(entity it = reviving_players_first; it; it = it.chain)
+ for(entity it = revivers_first; it; it = it.chain)
{
GameRules_scoring_add(it, FREEZETAG_REVIVALS, +1);
if (autocvar_g_freezetag_revive_time_to_score <= 0)
nades_GiveBonus(it, autocvar_g_nades_bonus_score_low);
}
- entity first = reviving_players_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);
+ Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, revivers_first.netname);
+ Send_Notification(NOTIF_ONE, revivers_first, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
+ Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED, player.netname, revivers_first.netname);
+ if(autocvar_sv_eventlog)
+ {
+ string revivers = "";
+ for(entity it = revivers_first; it; it = it.chain)
+ revivers = strcat(revivers, ftos(it.playerid), ",");
+ revivers = substring(revivers, 0, strlen(revivers) - 1);
+ GameLogEcho(strcat(":ft:revival:", ftos(player.playerid), ":", revivers));
+ }
}
- for(entity it = reviving_players_first; it; it = it.chain)
+ for(entity it = revivers_first; it; it = it.chain)
STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player);
}
freezetag_teams = cvar("g_freezetag_teams"); // read the cvar directly as it gets written earlier in the same frame
freezetag_teams = BITS(bound(2, freezetag_teams, 4));
- GameRules_scoring(freezetag_teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, {
+ GameRules_scoring(freezetag_teams, SFL_SORT_PRIO_PRIMARY, 0, {
field_team(ST_FT_ROUNDS, "rounds", SFL_SORT_PRIO_PRIMARY);
field(SP_FREEZETAG_REVIVALS, "revivals", 0);
});