int autocvar_g_freezetag_teams_override;
float autocvar_g_freezetag_warmup;
-void freezetag_ScoreRules(int teams)
-{
- ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, true); // SFL_SORT_PRIO_PRIMARY
- ScoreInfo_SetLabel_PlayerScore(SP_FREEZETAG_REVIVALS, "revivals", 0);
- ScoreRules_basics_end();
-}
-
void freezetag_count_alive_players()
{
total_players = redalive = bluealive = yellowalive = pinkalive = 0;
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
switch(it.team)
{
case NUM_TEAM_1: ++total_players; if(it.health >= 1 && STAT(FROZEN, it) != 1) ++redalive; break;
case NUM_TEAM_3: ++total_players; if(it.health >= 1 && STAT(FROZEN, it) != 1) ++yellowalive; break;
case NUM_TEAM_4: ++total_players; if(it.health >= 1 && STAT(FROZEN, it) != 1) ++pinkalive; break;
}
- ));
- FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+ });
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), {
it.redalive_stat = redalive;
it.bluealive_stat = bluealive;
it.yellowalive_stat = yellowalive;
it.pinkalive_stat = pinkalive;
- ));
+ });
eliminatedPlayers.SendFlags |= 1;
}
{
Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_OVER);
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_OVER);
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
it.freezetag_frozen_timeout = 0;
nades_Clear(it);
- ));
+ });
game_stopped = true;
round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
return 1;
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_TIED);
}
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it), {
it.freezetag_frozen_timeout = 0;
nades_Clear(it);
- ));
+ });
game_stopped = true;
round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
entity freezetag_LastPlayerForTeam(entity this)
{
entity last_pl = NULL;
- FOREACH_CLIENT(IS_PLAYER(it) && it != this, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it != this, {
if(it.health >= 1)
if(!STAT(FROZEN, it))
if(SAME_TEAM(it, this))
last_pl = it;
else
return NULL;
- ));
+ });
return last_pl;
}
{
// you froze your own dumb targ
// counted as "suicide" already
- PlayerScore_Add(targ, SP_SCORE, -1);
+ GameRules_scoring_add(targ, SCORE, -1);
}
else if(IS_PLAYER(attacker))
{
// got frozen by an enemy
// counted as "kill" and "death" already
- PlayerScore_Add(targ, SP_SCORE, -1);
- PlayerScore_Add(attacker, SP_SCORE, +1);
+ GameRules_scoring_add(targ, SCORE, -1);
+ GameRules_scoring_add(attacker, SCORE, +1);
}
// else nothing - got frozen by the game type rules themselves
}
void havocbot_goalrating_freeplayers(entity this, float ratingscale, vector org, float sradius)
{
float t;
- FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), {
if (STAT(FROZEN, it) == 1)
{
if(vdist(it.origin - org, >, sradius))
t = 0.2 * 150 / (this.health + this.armorvalue);
navigation_routerating(this, it, t * ratingscale, 2000);
}
- ));
+ });
}
void havocbot_role_ft_offense(entity this)
// Count how many players on team are unfrozen.
int unfrozen = 0;
- FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, this) && !(STAT(FROZEN, it) != 1), LAMBDA(unfrozen++));
+ FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, this) && !(STAT(FROZEN, it) != 1), { unfrozen++; });
// If only one left on team or if role has timed out then start trying to free players.
if (((unfrozen == 0) && (!STAT(FROZEN, this))) || (time > this.havocbot_role_timeout))
MUTATOR_HOOKFUNCTION(ft, reset_map_players)
{
- FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
- it.killcount = 0;
+ FOREACH_CLIENT(IS_PLAYER(it), {
+ CS(it).killcount = 0;
it.freezetag_frozen_timeout = -1;
PutClientInServer(it);
it.freezetag_frozen_timeout = 0;
- ));
+ });
freezetag_count_alive_players();
return true;
}
{
vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
n = 0;
- FOREACH_CLIENT(IS_PLAYER(it) && it != player, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it != player, {
if(STAT(FROZEN, it) == 0)
if(!IS_DEAD(it))
if(SAME_TEAM(it, player))
it.reviving = true;
++n;
}
- ));
+ });
}
}
// EVERY team mate nearby gets a point (even if multiple!)
- FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, LAMBDA(
- PlayerScore_Add(it, SP_FREEZETAG_REVIVALS, +1);
- PlayerScore_Add(it, SP_SCORE, +1);
+ FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, {
+ GameRules_scoring_add(it, FREEZETAG_REVIVALS, +1);
+ GameRules_scoring_add(it, SCORE, +1);
nades_GiveBonus(it,autocvar_g_nades_bonus_score_low);
- ));
+ });
Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED, player.netname, o.netname);
}
- FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, {
it.revive_progress = player.revive_progress;
it.reviving = false;
- ));
+ });
}
else if(!n && STAT(FROZEN, player) == 1) // only if no teammate is nearby will we reset
{
if(STAT(FROZEN, frag_target))
return; // target was already frozen, so this is just pushing them off the cliff
- Send_Notification(NOTIF_ONE, frag_attacker, MSG_CHOICE, CHOICE_FRAG_FREEZE, frag_target.netname, kill_count_to_attacker, (IS_BOT_CLIENT(frag_target) ? -1 : frag_target.ping));
- Send_Notification(NOTIF_ONE, frag_target, MSG_CHOICE, CHOICE_FRAGGED_FREEZE, frag_attacker.netname, kill_count_to_target, frag_attacker.health, frag_attacker.armorvalue, (IS_BOT_CLIENT(frag_attacker) ? -1 : frag_attacker.ping));
+ Send_Notification(NOTIF_ONE, frag_attacker, MSG_CHOICE, CHOICE_FRAG_FREEZE, frag_target.netname, kill_count_to_attacker, (IS_BOT_CLIENT(frag_target) ? -1 : CS(frag_target).ping));
+ Send_Notification(NOTIF_ONE, frag_target, MSG_CHOICE, CHOICE_FRAGGED_FREEZE, frag_attacker.netname, kill_count_to_target, frag_attacker.health, frag_attacker.armorvalue, (IS_BOT_CLIENT(frag_attacker) ? -1 : CS(frag_attacker).ping));
return true;
}
freezetag_teams = autocvar_g_freezetag_teams_override;
if(freezetag_teams < 2)
freezetag_teams = cvar("g_freezetag_teams"); // read the cvar directly as it gets written earlier in the same frame
- freezetag_teams = bound(2, freezetag_teams, 4);
-
- int teams = 0;
- if(freezetag_teams >= 1) teams |= BIT(0);
- if(freezetag_teams >= 2) teams |= BIT(1);
- if(freezetag_teams >= 3) teams |= BIT(2);
- if(freezetag_teams >= 4) teams |= BIT(3);
- freezetag_teams = teams; // now set it?
- freezetag_ScoreRules(freezetag_teams);
+ freezetag_teams = BITS(bound(2, freezetag_teams, 4));
+ GameRules_scoring(freezetag_teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, {
+ field(SP_FREEZETAG_REVIVALS, "revivals", 0);
+ });
round_handler_Spawn(freezetag_CheckTeams, freezetag_CheckWinner, func_null);
round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);