entity e;
total_players = redalive = bluealive = yellowalive = pinkalive = 0;
FOR_EACH_PLAYER(e) {
- if(e.team == COLOR_TEAM1 && e.health >= 1)
+ if(e.team == NUM_TEAM_1 && e.health >= 1)
{
++total_players;
if (!e.freezetag_frozen) ++redalive;
}
- else if(e.team == COLOR_TEAM2 && e.health >= 1)
+ else if(e.team == NUM_TEAM_2 && e.health >= 1)
{
++total_players;
if (!e.freezetag_frozen) ++bluealive;
}
- else if(e.team == COLOR_TEAM3 && e.health >= 1)
+ else if(e.team == NUM_TEAM_3 && e.health >= 1)
{
++total_players;
if (!e.freezetag_frozen) ++yellowalive;
}
- else if(e.team == COLOR_TEAM4 && e.health >= 1)
+ else if(e.team == NUM_TEAM_4 && e.health >= 1)
{
++total_players;
if (!e.freezetag_frozen) ++pinkalive;
#define FREEZETAG_ALIVE_TEAMS() ((redalive > 0) + (bluealive > 0) + (yellowalive > 0) + (pinkalive > 0))
#define FREEZETAG_ALIVE_TEAMS_OK() (FREEZETAG_ALIVE_TEAMS() == freezetag_teams)
-float prev_total_players;
+float prev_missing_teams_mask;
float freezetag_CheckTeams()
{
- entity e;
if(FREEZETAG_ALIVE_TEAMS_OK())
{
- if(prev_total_players != -1)
- {
- FOR_EACH_REALCLIENT(e)
- Send_CSQC_Centerprint_Generic_Expire(e, CPID_WAITING_PLAYERS);
- }
- prev_total_players = -1;
+ if(prev_missing_teams_mask > 0)
+ Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_MISSING_TEAMS);
+ prev_missing_teams_mask = -1;
return 1;
}
- if(prev_total_players != total_players)
+ if(total_players == 0)
{
- string teams_missing = "";
- if(!redalive) teams_missing = strcat(teams_missing, ColoredTeamName(COLOR_TEAM1), ", ");
- if(!bluealive) teams_missing = strcat(teams_missing, ColoredTeamName(COLOR_TEAM2), ", ");
- if(freezetag_teams >= 3)
- if(!yellowalive) teams_missing = strcat(teams_missing, ColoredTeamName(COLOR_TEAM3), ", ");
- if(freezetag_teams == 4)
- if(!pinkalive) teams_missing = strcat(teams_missing, ColoredTeamName(COLOR_TEAM4), ", ");
- teams_missing = substring(teams_missing, 0, strlen(teams_missing)-2);
-
- FOR_EACH_REALCLIENT(e)
- Send_CSQC_Centerprint_Generic(e, CPID_WAITING_PLAYERS, strcat("Waiting for players to join...\n\nNeed active players for: ", teams_missing), -1, 0);
- prev_total_players = total_players;
+ if(prev_missing_teams_mask > 0)
+ Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_MISSING_TEAMS);
+ prev_missing_teams_mask = -1;
+ return 0;
+ }
+ float missing_teams_mask = (!redalive) + (!bluealive) * 2;
+ if(freezetag_teams >= 3) missing_teams_mask += (!yellowalive) * 4;
+ if(freezetag_teams >= 4) missing_teams_mask += (!pinkalive) * 8;
+ if(prev_missing_teams_mask != missing_teams_mask)
+ {
+ Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_MISSING_TEAMS, missing_teams_mask);
+ prev_missing_teams_mask = missing_teams_mask;
}
return 0;
}
{
float winner_team = 0;
if(redalive >= 1)
- winner_team = COLOR_TEAM1;
+ winner_team = NUM_TEAM_1;
if(bluealive >= 1)
{
if(winner_team) return 0;
- winner_team = COLOR_TEAM2;
+ winner_team = NUM_TEAM_2;
}
if(yellowalive >= 1)
{
if(winner_team) return 0;
- winner_team = COLOR_TEAM3;
+ winner_team = NUM_TEAM_3;
}
if(pinkalive >= 1)
{
if(winner_team) return 0;
- winner_team = COLOR_TEAM4;
+ winner_team = NUM_TEAM_4;
}
if(winner_team)
return winner_team;
float freezetag_CheckWinner()
{
entity e;
- if(round_handler_GetTimeLeft() <= 0)
+ if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)
{
- FOR_EACH_REALCLIENT(e)
- centerprint(e, "Round over, there's no winner");
- bprint("Round over, there's no winner.\n");
+ Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_OVER);
+ Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_OVER);
FOR_EACH_PLAYER(e)
+ {
e.freezetag_frozen_timeout = 0;
+ e.freezetag_revive_progress = 0;
+ }
round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
return 1;
}
return 0;
float winner_team;
- string teamname;
winner_team = freezetag_getWinnerTeam();
if(winner_team > 0)
{
- teamname = ColoredTeamName(winner_team);
- FOR_EACH_REALCLIENT(e)
- centerprint(e, strcat(teamname, "^5 wins the round, all other teams were frozen."));
- bprint(teamname, "^5 wins the round since all the other teams were frozen.\n");
+ Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM_4(winner_team, CENTER_ROUND_TEAM_WIN_));
+ Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(winner_team, INFO_ROUND_TEAM_WIN_));
TeamScore_AddToTeam(winner_team, ST_SCORE, +1);
}
else if(winner_team == -1)
{
- FOR_EACH_REALCLIENT(e)
- centerprint(e, "^5Round tied! All teams were frozen.");
- bprint("^5Round tied! All teams were frozen.\n");
+ Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_TIED);
+ Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_TIED);
}
FOR_EACH_PLAYER(e)
+ {
e.freezetag_frozen_timeout = 0;
+ e.freezetag_revive_progress = 0;
+ }
round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
return 1;
}
+entity freezetag_LastPlayerForTeam()
+{
+ entity pl, last_pl = world;
+ FOR_EACH_PLAYER(pl)
+ {
+ if(pl.health >= 1)
+ if(!pl.freezetag_frozen)
+ if(pl != self)
+ if(pl.team == self.team)
+ if(!last_pl)
+ last_pl = pl;
+ else
+ return world;
+ }
+ return last_pl;
+}
+
+void freezetag_LastPlayerForTeam_Notify()
+{
+ if(round_handler_IsActive())
+ if(round_handler_IsRoundStarted())
+ {
+ entity pl = freezetag_LastPlayerForTeam();
+ if(pl)
+ Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE);
+ }
+}
+
// this is needed to allow the player to turn his view around (fixangle can't
// be used to freeze his view, as that also changes the angles), while not
// turning that ice object with the player
// counted as "suicide" already
PlayerScore_Add(self, SP_SCORE, -1);
}
- else if(attacker.classname == "player")
+ else if(IS_PLAYER(attacker))
{
// got frozen by an enemy
// counted as "kill" and "death" already
ice.nextthink = time;
ice.frame = floor(random() * 21); // ice model has 20 different looking frames
ice.alpha = ICE_MAX_ALPHA;
- ice.colormod = TeamColor(self.team);
+ ice.colormod = Team_ColorRGB(self.team);
ice.glowmod = ice.colormod;
setmodel(ice, "models/ice/ice.md3");
MUTATOR_HOOKFUNCTION(freezetag_RemovePlayer)
{
self.health = 0; // neccessary to update correctly alive stats
+ if(!self.freezetag_frozen)
+ freezetag_LastPlayerForTeam_Notify();
freezetag_Unfreeze(world);
freezetag_count_alive_players();
return 1;
{
freezetag_Add_Score(frag_attacker);
freezetag_count_alive_players();
+ freezetag_LastPlayerForTeam_Notify();
}
else
freezetag_Unfreeze(world); // remove ice
return 1;
freezetag_Freeze(frag_attacker);
+ freezetag_LastPlayerForTeam_Notify();
if(frag_attacker == frag_target || frag_attacker == world)
{
- if(frag_target.classname == STR_PLAYER)
- centerprint(frag_target, "^1You froze yourself.\n");
- bprint("^7", frag_target.netname, "^1 froze himself.\n");
+ if(IS_PLAYER(frag_target))
+ Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_SELF);
+ Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_SELF, frag_target.netname);
}
else
{
- if(frag_target.classname == STR_PLAYER)
- centerprint(frag_target, strcat("^1You were frozen by ^7", frag_attacker.netname, ".\n"));
- if(frag_attacker.classname == STR_PLAYER)
- centerprint(frag_attacker, strcat("^2You froze ^7", frag_target.netname, ".\n"));
- bprint("^7", frag_target.netname, "^1 was frozen by ^7", frag_attacker.netname, ".\n");
+ 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, world, MSG_INFO, INFO_FREEZETAG_FREEZE, frag_target.netname, frag_attacker.netname);
}
frag_target.health = 1; // "respawn" the player :P
if(round_handler_IsActive())
if(round_handler_IsRoundStarted())
{
- centerprint(self, "^1Round already started, you spawn as frozen.");
+ Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_FREEZETAG_SPAWN_LATE);
freezetag_Freeze(world);
}
{
FOR_EACH_PLAYER(self)
{
+ self.killcount = 0;
if (self.freezetag_frozen)
freezetag_Unfreeze(world);
self.freezetag_frozen_timeout = -1;
if(n && self.freezetag_frozen) // OK, there is at least one teammate reviving us
{
- self.freezetag_revive_progress = bound(0, self.freezetag_revive_progress + frametime * autocvar_g_freezetag_revive_speed, 1);
- self.health = max(1, self.freezetag_revive_progress * autocvar_g_balance_health_start);
+ self.freezetag_revive_progress = bound(0, self.freezetag_revive_progress + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
+ if(warmup_stage)
+ self.health = max(1, self.freezetag_revive_progress * warmup_start_health);
+ else
+ self.health = max(1, self.freezetag_revive_progress * start_health);
if(self.freezetag_revive_progress >= 1)
{
if(n == -1)
{
- string s = ftos(autocvar_g_freezetag_frozen_maxtime);
- centerprint(self, strcat("^5You were automatically revived after ", s, " seconds^5.\n"));
- bprint("^7", self.netname, "^5 were automatically revived after ", s, " seconds^5.\n");
+ Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_FREEZETAG_AUTO_REVIVED, autocvar_g_freezetag_frozen_maxtime);
+ Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_AUTO_REVIVED, self.netname, autocvar_g_freezetag_frozen_maxtime);
return 1;
}
}
}
- if(n > 1)
- centerprint(self, strcat("^5You were revived by ^7", o.netname, "^5 et al.\n"));
- else
- centerprint(self, strcat("^5You were revived by ^7", o.netname, "^5.\n"));
- centerprint(o, strcat("^5You revived ^7", self.netname, "^5.\n"));
- if(n > 1)
- bprint("^7", o.netname, "^5 et al revived ^7", self.netname, "^5.\n");
- else
- bprint("^7", o.netname, "^5 revived ^7", self.netname, "^5.\n");
+ Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
+ Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, self.netname);
+ Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_REVIVED, self.netname, o.netname);
}
FOR_EACH_PLAYER(other)
else if(!n && self.freezetag_frozen) // only if no teammate is nearby will we reset
{
self.freezetag_revive_progress = bound(0, self.freezetag_revive_progress - frametime * autocvar_g_freezetag_revive_clearspeed, 1);
- self.health = max(1, self.freezetag_revive_progress * autocvar_g_balance_health_start);
+ if(warmup_stage)
+ self.health = max(1, self.freezetag_revive_progress * warmup_start_health);
+ else
+ self.health = max(1, self.freezetag_revive_progress * start_health);
}
else if(!n)
{
{
if(self.freezetag_frozen)
{
- self.movement = '0 0 0';
+ if(autocvar_sv_dodging_frozen && IS_REAL_CLIENT(self))
+ {
+ self.movement_x = bound(-5, self.movement_x, 5);
+ self.movement_y = bound(-5, self.movement_y, 5);
+ self.movement_z = bound(-5, self.movement_z, 5);
+ }
+ else
+ self.movement = '0 0 0';
+
self.disableclientprediction = 1;
}
return 1;
{
if(frag_target.freezetag_frozen && frag_deathtype != DEATH_HURTTRIGGER)
{
+ if(autocvar_g_freezetag_revive_falldamage > 0)
+ if(frag_deathtype == DEATH_FALL)
+ if(frag_damage >= autocvar_g_freezetag_revive_falldamage)
+ {
+ freezetag_Unfreeze(frag_target);
+ frag_target.health = autocvar_g_freezetag_revive_falldamage_health;
+ pointparticles(particleeffectnum("iceorglass"), frag_target.origin, '0 0 0', 3);
+ Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_REVIVED_FALL, frag_target.netname);
+ Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_FALL);
+ }
+
frag_damage = 0;
frag_force = frag_force * autocvar_g_freezetag_frozen_force;
}
return 1;
}
+MUTATOR_HOOKFUNCTION(freezetag_PlayerJump)
+{
+ if(self.freezetag_frozen)
+ return TRUE; // no jumping in freezetag when frozen
+
+ return FALSE;
+}
+
MUTATOR_HOOKFUNCTION(freezetag_ForbidThrowCurrentWeapon)
{
if (self.freezetag_frozen)
return 0;
}
+MUTATOR_HOOKFUNCTION(freezetag_ItemTouch)
+{
+ if (other.freezetag_frozen)
+ return MUT_ITEMTOUCH_RETURN;
+ return MUT_ITEMTOUCH_CONTINUE;
+}
+
MUTATOR_HOOKFUNCTION(freezetag_BotRoles)
{
- if not(self.deadflag)
+ if (!self.deadflag)
{
if (random() < 0.5)
self.havocbot_role = havocbot_role_ft_freeing;
MUTATOR_HOOKFUNCTION(freezetag_GetTeamCount)
{
- freezetag_teams = autocvar_g_freezetag_teams_override;
- if(freezetag_teams < 2)
- freezetag_teams = autocvar_g_freezetag_teams;
- freezetag_teams = bound(2, freezetag_teams, 4);
ret_float = freezetag_teams;
return 0;
}
+MUTATOR_HOOKFUNCTION(freezetag_VehicleTouch)
+{
+ if(other.freezetag_frozen)
+ return TRUE;
+
+ return FALSE;
+}
+
void freezetag_Initialize()
{
precache_model("models/ice/ice.md3");
- ScoreRules_freezetag();
+
+ freezetag_teams = autocvar_g_freezetag_teams_override;
+ if(freezetag_teams < 2)
+ freezetag_teams = autocvar_g_freezetag_teams;
+ freezetag_teams = bound(2, freezetag_teams, 4);
+ ScoreRules_freezetag(freezetag_teams);
round_handler_Spawn(freezetag_CheckTeams, freezetag_CheckWinner, func_null);
round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
MUTATOR_HOOK(PlayerPreThink, freezetag_PlayerPreThink, CBC_ORDER_FIRST);
MUTATOR_HOOK(PlayerPhysics, freezetag_PlayerPhysics, CBC_ORDER_FIRST);
MUTATOR_HOOK(PlayerDamage_Calculate, freezetag_PlayerDamage_Calculate, CBC_ORDER_ANY);
+ MUTATOR_HOOK(PlayerJump, freezetag_PlayerJump, CBC_ORDER_ANY);
MUTATOR_HOOK(ForbidThrowCurrentWeapon, freezetag_ForbidThrowCurrentWeapon, CBC_ORDER_ANY);
- MUTATOR_HOOK(HavocBot_ChooseRule, freezetag_BotRoles, CBC_ORDER_ANY);
+ MUTATOR_HOOK(ItemTouch, freezetag_ItemTouch, CBC_ORDER_ANY);
+ MUTATOR_HOOK(HavocBot_ChooseRole, freezetag_BotRoles, CBC_ORDER_ANY);
MUTATOR_HOOK(SpectateCopy, freezetag_SpectateCopy, CBC_ORDER_ANY);
MUTATOR_HOOK(GetTeamCount, freezetag_GetTeamCount, CBC_ORDER_EXCLUSIVE);
+ MUTATOR_HOOK(VehicleTouch, freezetag_VehicleTouch, CBC_ORDER_ANY);
MUTATOR_ONADD
{