float autocvar_g_freezetag_frozen_maxtime;
float autocvar_g_freezetag_revive_clearspeed;
float autocvar_g_freezetag_round_timelimit;
-int autocvar_g_freezetag_teams;
+//int autocvar_g_freezetag_teams;
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);
return 1;
}
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)
{
- FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), LAMBDA(
+ float t;
+ FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), {
if (STAT(FROZEN, it) == 1)
{
if(vdist(it.origin - org, >, sradius))
continue;
navigation_routerating(this, it, ratingscale, 2000);
}
- else
+ else if(vdist(it.origin - org, >, 400)) // avoid gathering all teammates in one place
{
// If teamate is not frozen still seek them out as fight better
// in a group.
- navigation_routerating(this, it, ratingscale/3, 2000);
+ 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))
havocbot_goalrating_items(this, 10000, this.origin, 10000);
havocbot_goalrating_enemyplayers(this, 20000, this.origin, 10000);
havocbot_goalrating_freeplayers(this, 9000, this.origin, 10000);
- //havocbot_goalrating_waypoints(1, this.origin, 1000);
+ havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
navigation_goalrating_end(this);
}
}
havocbot_goalrating_items(this, 8000, this.origin, 10000);
havocbot_goalrating_enemyplayers(this, 10000, this.origin, 10000);
havocbot_goalrating_freeplayers(this, 20000, this.origin, 10000);
- //havocbot_goalrating_waypoints(1, this.origin, 1000);
+ havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
navigation_goalrating_end(this);
}
}
}
else
{
- if(IS_PLAYER(frag_target))
- Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_FROZEN, frag_attacker.netname);
- if(IS_PLAYER(frag_attacker))
- Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_FREEZETAG_FREEZE, frag_target.netname);
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_FREEZE, frag_target.netname, frag_attacker.netname);
}
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;
}
MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
{
- if(gameover)
+ if(game_stopped)
return true;
- entity player = M_ARGV(0, entity);
-
- if(STAT(FROZEN, player) == 1)
- {
- // keep health = 1
- player.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
- }
-
if(round_handler_IsActive())
if(!round_handler_IsRoundStarted())
return true;
int n;
-
- entity o;
- o = NULL;
+ entity o = NULL;
+ entity player = M_ARGV(0, entity);
//if(STAT(FROZEN, player))
//if(player.freezetag_frozen_timeout > 0 && time < player.freezetag_frozen_timeout)
//player.iceblock.alpha = ICE_MIN_ALPHA + (ICE_MAX_ALPHA - ICE_MIN_ALPHA) * (player.freezetag_frozen_timeout - time) / (player.freezetag_frozen_timeout - player.freezetag_frozen_time);
{
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
{
M_ARGV(0, string) = "most";
}
+MUTATOR_HOOKFUNCTION(ft, FragCenterMessage)
+{
+ entity frag_attacker = M_ARGV(0, entity);
+ entity frag_target = M_ARGV(1, entity);
+ //float frag_deathtype = M_ARGV(2, float);
+ int kill_count_to_attacker = M_ARGV(3, int);
+ int kill_count_to_target = M_ARGV(4, int);
+
+ 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 : 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;
+}
+
void freezetag_Initialize()
{
freezetag_teams = autocvar_g_freezetag_teams_override;
if(freezetag_teams < 2)
- freezetag_teams = autocvar_g_freezetag_teams;
- 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 = cvar("g_freezetag_teams"); // read the cvar directly as it gets written earlier in the same frame
- 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);