}
const int ST_NEXBALL_GOALS = 1;
-void nb_ScoreRules(int teams)
-{
- GameRules_scoring(teams, 0, 0, {
- field_team(ST_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
- field(SP_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
- field(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
- });
-}
void LogNB(string mode, entity actor)
{
//nb_teams += 1;
}
-void nb_spawnteams()
-{
- bool t_red = false, t_blue = false, t_yellow = false, t_pink = false;
- entity e;
- for(e = NULL; (e = find(e, classname, "nexball_goal"));)
- {
- switch(e.team)
- {
- case NUM_TEAM_1:
- if(!t_red)
- {
- nb_spawnteam("Red", e.team-1) ;
- nb_teams |= BIT(0);
- t_red = true;
- }
- break;
- case NUM_TEAM_2:
- if(!t_blue)
- {
- nb_spawnteam("Blue", e.team-1) ;
- t_blue = true;
- nb_teams |= BIT(1);
- }
- break;
- case NUM_TEAM_3:
- if(!t_yellow)
- {
- nb_spawnteam("Yellow", e.team-1);
- t_yellow = true;
- nb_teams |= BIT(2);
- }
- break;
- case NUM_TEAM_4:
- if(!t_pink)
- {
- nb_spawnteam("Pink", e.team-1) ;
- t_pink = true;
- nb_teams |= BIT(3);
- }
- break;
- }
- }
-}
-
-void nb_delayedinit(entity this)
-{
- if(find(NULL, classname, "nexball_team") == NULL)
- nb_spawnteams();
- nb_ScoreRules(nb_teams);
-}
-
-
//=======================//
// spawnfuncs //
//=======================//
*/
radar_showennemies = autocvar_g_nexball_radar_showallplayers;
- InitializeEntity(NULL, nb_delayedinit, INITPRIO_GAMETYPE);
+ if (find(NULL, classname, "nexball_team") == NULL) {
+ int t_1 = 0, t_2 = 0, t_3 = 0, t_4 = 0;
+ for (entity e = NULL; (e = find(e, classname, "nexball_goal")); ) {
+ switch (e.team) {
+ case NUM_TEAM_1: if (!t_1++) { nb_spawnteam("Red", e.team - 1); nb_teams |= BIT(0); } break;
+ case NUM_TEAM_2: if (!t_2++) { nb_spawnteam("Blue", e.team - 1); nb_teams |= BIT(1); } break;
+ case NUM_TEAM_3: if (!t_3++) { nb_spawnteam("Yellow", e.team - 1); nb_teams |= BIT(2); } break;
+ case NUM_TEAM_4: if (!t_4++) { nb_spawnteam("Pink", e.team - 1); nb_teams |= BIT(3); } break;
+ }
+ }
+ }
+ GameRules_scoring(nb_teams, 0, 0, {
+ field_team(ST_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
+ field(SP_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
+ field(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
+ });
WEP_NEXBALL.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
GameRules_teams(true);
ons_GeneratorSetup(this);
}
-// scoreboard setup
-void ons_ScoreRules()
-{
- CheckAllowedTeams(NULL);
- int teams = 0;
- if(c1 >= 0) teams |= BIT(0);
- if(c2 >= 0) teams |= BIT(1);
- if(c3 >= 0) teams |= BIT(2);
- if(c4 >= 0) teams |= BIT(3);
- GameRules_scoring(teams, SFL_SORT_PRIO_PRIMARY, 0, {
- field_team(ST_ONS_CAPS, "destroyed", SFL_SORT_PRIO_PRIMARY);
- field(SP_ONS_CAPS, "caps", SFL_SORT_PRIO_SECONDARY);
- field(SP_ONS_TAKES, "takes", 0);
- });
-}
-
-void ons_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up
-{
- ons_ScoreRules();
-
- round_handler_Spawn(Onslaught_CheckPlayers, Onslaught_CheckWinner, Onslaught_RoundStart);
- round_handler_Init(5, autocvar_g_onslaught_warmup, autocvar_g_onslaught_round_timelimit);
-}
-
void ons_Initialize()
{
g_onslaught = true;
cam = new(objective_camera);
- InitializeEntity(NULL, ons_DelayedInit, INITPRIO_GAMETYPE);
+ CheckAllowedTeams(NULL);
+ int teams = 0;
+ if (c1 >= 0) teams |= BIT(0);
+ if (c2 >= 0) teams |= BIT(1);
+ if (c3 >= 0) teams |= BIT(2);
+ if (c4 >= 0) teams |= BIT(3);
+ GameRules_scoring(teams, SFL_SORT_PRIO_PRIMARY, 0, {
+ field_team(ST_ONS_CAPS, "destroyed", SFL_SORT_PRIO_PRIMARY);
+ field(SP_ONS_CAPS, "caps", SFL_SORT_PRIO_SECONDARY);
+ field(SP_ONS_TAKES, "takes", 0);
+ });
+
+ round_handler_Spawn(Onslaught_CheckPlayers, Onslaught_CheckWinner, Onslaught_RoundStart);
+ round_handler_Init(5, autocvar_g_onslaught_warmup, autocvar_g_onslaught_round_timelimit);
}
PlayerStats_GameReport_Init(); // we need this to be initiated before InitGameplayMode
InitGameplayMode();
+ __spawnfunc_spawn_all();
static_init_late();
static_init_precache();
readlevelcvars();
WinningConditionHelper(this); // set worldstatus
world_initialized = 1;
- __spawnfunc_spawn_all();
}
spawnfunc(light)
// Initialization
// ==============
-// scoreboard setup
-void ctf_ScoreRules(int teams)
-{
- CheckAllowedTeams(NULL);
- GameRules_scoring(teams, SFL_SORT_PRIO_PRIMARY, 0, {
- field_team(ST_CTF_CAPS, "caps", SFL_SORT_PRIO_PRIMARY);
- field(SP_CTF_CAPS, "caps", SFL_SORT_PRIO_SECONDARY);
- field(SP_CTF_CAPTIME, "captime", SFL_LOWER_IS_BETTER | SFL_TIME);
- field(SP_CTF_PICKUPS, "pickups", 0);
- field(SP_CTF_FCKILLS, "fckills", 0);
- field(SP_CTF_RETURNS, "returns", 0);
- field(SP_CTF_DROPS, "drops", SFL_LOWER_IS_BETTER);
- });
-}
-
// code from here on is just to support maps that don't have flag and team entities
void ctf_SpawnTeam (string teamname, int teamcolor)
{
this.team = teamcolor;
}
-void ctf_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up.
-{
- ctf_teams = 0;
-
- entity tmp_entity;
- for(tmp_entity = ctf_worldflaglist; tmp_entity; tmp_entity = tmp_entity.ctf_worldflagnext)
- {
- //if(tmp_entity.team == NUM_TEAM_3) { ctf_teams = max(3, ctf_teams); }
- //if(tmp_entity.team == NUM_TEAM_4) { ctf_teams = max(4, ctf_teams); }
-
- switch(tmp_entity.team)
- {
- case NUM_TEAM_1: BITSET_ASSIGN(ctf_teams, BIT(0)); break;
- case NUM_TEAM_2: BITSET_ASSIGN(ctf_teams, BIT(1)); break;
- case NUM_TEAM_3: BITSET_ASSIGN(ctf_teams, BIT(2)); break;
- case NUM_TEAM_4: BITSET_ASSIGN(ctf_teams, BIT(3)); break;
- }
- if(tmp_entity.team == 0) { ctf_oneflag = true; }
- }
-
- havocbot_ctf_calculate_middlepoint();
-
- if(NumTeams(ctf_teams) < 2) // somehow, there's not enough flags!
- {
- ctf_teams = 0; // so set the default red and blue teams
- BITSET_ASSIGN(ctf_teams, BIT(0));
- BITSET_ASSIGN(ctf_teams, BIT(1));
- }
-
- //ctf_teams = bound(2, ctf_teams, 4);
-
- // if no teams are found, spawn defaults
- if(find(NULL, classname, "ctf_team") == NULL)
- {
- LOG_TRACE("No \"ctf_team\" entities found on this map, creating them anyway.");
- if(ctf_teams & BIT(0))
- ctf_SpawnTeam("Red", NUM_TEAM_1);
- if(ctf_teams & BIT(1))
- ctf_SpawnTeam("Blue", NUM_TEAM_2);
- if(ctf_teams & BIT(2))
- ctf_SpawnTeam("Yellow", NUM_TEAM_3);
- if(ctf_teams & BIT(3))
- ctf_SpawnTeam("Pink", NUM_TEAM_4);
- }
-
- ctf_ScoreRules(ctf_teams);
-}
-
void ctf_Initialize()
{
ctf_captimerecord = stof(db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time")));
ctf_captureshield_max_ratio = autocvar_g_ctf_shield_max_ratio;
ctf_captureshield_force = autocvar_g_ctf_shield_force;
- InitializeEntity(NULL, ctf_DelayedInit, INITPRIO_GAMETYPE);
+ ctf_teams = 0;
+
+ for (entity tmp_entity = ctf_worldflaglist; tmp_entity; tmp_entity = tmp_entity.ctf_worldflagnext) {
+ //if(tmp_entity.team == NUM_TEAM_3) { ctf_teams = max(3, ctf_teams); }
+ //if(tmp_entity.team == NUM_TEAM_4) { ctf_teams = max(4, ctf_teams); }
+
+ switch (tmp_entity.team) {
+ case NUM_TEAM_1: BITSET_ASSIGN(ctf_teams, BIT(0)); break;
+ case NUM_TEAM_2: BITSET_ASSIGN(ctf_teams, BIT(1)); break;
+ case NUM_TEAM_3: BITSET_ASSIGN(ctf_teams, BIT(2)); break;
+ case NUM_TEAM_4: BITSET_ASSIGN(ctf_teams, BIT(3)); break;
+ }
+ if (tmp_entity.team == 0) { ctf_oneflag = true; }
+ }
+
+ havocbot_ctf_calculate_middlepoint();
+
+ if (NumTeams(ctf_teams) < 2) { // somehow, there's not enough flags!
+ ctf_teams = 0; // so set the default red and blue teams
+ BITSET_ASSIGN(ctf_teams, BIT(0));
+ BITSET_ASSIGN(ctf_teams, BIT(1));
+ }
+
+ //ctf_teams = bound(2, ctf_teams, 4);
+
+ // if no teams are found, spawn defaults
+ if (find(NULL, classname, "ctf_team") == NULL) {
+ LOG_TRACE("No \"ctf_team\" entities found on this map, creating them anyway.");
+ if (ctf_teams & BIT(0)) ctf_SpawnTeam("Red", NUM_TEAM_1);
+ if (ctf_teams & BIT(1)) ctf_SpawnTeam("Blue", NUM_TEAM_2);
+ if (ctf_teams & BIT(2)) ctf_SpawnTeam("Yellow", NUM_TEAM_3);
+ if (ctf_teams & BIT(3)) ctf_SpawnTeam("Pink", NUM_TEAM_4);
+ }
+
+ CheckAllowedTeams(NULL);
+ GameRules_scoring(ctf_teams, SFL_SORT_PRIO_PRIMARY, 0, {
+ field_team(ST_CTF_CAPS, "caps", SFL_SORT_PRIO_PRIMARY);
+ field(SP_CTF_CAPS, "caps", SFL_SORT_PRIO_SECONDARY);
+ field(SP_CTF_CAPTIME, "captime", SFL_LOWER_IS_BETTER | SFL_TIME);
+ field(SP_CTF_PICKUPS, "pickups", 0);
+ field(SP_CTF_FCKILLS, "fckills", 0);
+ field(SP_CTF_RETURNS, "returns", 0);
+ field(SP_CTF_DROPS, "drops", SFL_LOWER_IS_BETTER);
+ });
}
this.team = this.cnt + 1; // WHY are these different anyway?
}
-// scoreboard setup
-void ScoreRules_dom(int teams)
-{
- if(domination_roundbased)
- {
- GameRules_scoring(teams, SFL_SORT_PRIO_PRIMARY, 0, {
- field_team(ST_DOM_CAPS, "caps", SFL_SORT_PRIO_PRIMARY);
- field(SP_DOM_TAKES, "takes", 0);
- });
- }
- else
- {
- float sp_domticks, sp_score;
- sp_score = sp_domticks = 0;
- if(autocvar_g_domination_disable_frags)
- sp_domticks = SFL_SORT_PRIO_PRIMARY;
- else
- sp_score = SFL_SORT_PRIO_PRIMARY;
- GameRules_scoring(teams, sp_score, sp_score, {
- field_team(ST_DOM_TICKS, "ticks", sp_domticks);
- field(SP_DOM_TICKS, "ticks", sp_domticks);
- field(SP_DOM_TAKES, "takes", 0);
- });
- }
-}
-
// code from here on is just to support maps that don't have control point and team entities
void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float pointskin, Sound capsound, string capnarration, string capmessage)
{
dom_spawnteam("", 0, "models/domination/dom_unclaimed.md3", 0, SND_Null, "", "");
}
-void dom_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up.
+void dom_Initialize()
{
+ g_domination = true;
// if no teams are found, spawn defaults
if(find(NULL, classname, "dom_team") == NULL || autocvar_g_domination_teams_override >= 2)
{
domination_roundbased = autocvar_g_domination_roundbased;
- ScoreRules_dom(domination_teams);
+ if (domination_roundbased) {
+ GameRules_scoring(teams, SFL_SORT_PRIO_PRIMARY, 0, {
+ field_team(ST_DOM_CAPS, "caps", SFL_SORT_PRIO_PRIMARY);
+ field(SP_DOM_TAKES, "takes", 0);
+ });
+ } else {
+ float sp_score = autocvar_g_domination_disable_frags ? 0 : SFL_SORT_PRIO_PRIMARY;
+ float sp_domticks = autocvar_g_domination_disable_frags ? SFL_SORT_PRIO_PRIMARY : 0;
+ GameRules_scoring(teams, sp_score, sp_score, {
+ field_team(ST_DOM_TICKS, "ticks", sp_domticks);
+ field(SP_DOM_TICKS, "ticks", sp_domticks);
+ field(SP_DOM_TAKES, "takes", 0);
+ });
+ }
- if(domination_roundbased)
- {
+ if (domination_roundbased) {
round_handler_Spawn(Domination_CheckPlayers, Domination_CheckWinner, Domination_RoundStart);
round_handler_Init(5, autocvar_g_domination_warmup, autocvar_g_domination_round_timelimit);
}
}
-
-void dom_Initialize()
-{
- g_domination = true;
- InitializeEntity(NULL, dom_DelayedInit, INITPRIO_GAMETYPE);
-}
return true;
}
-void invasion_ScoreRules(int inv_teams)
-{
- if(inv_teams) { CheckAllowedTeams(NULL); }
- GameRules_score_enabled(false);
- GameRules_scoring(inv_teams, 0, 0, {
- if (inv_teams) {
- field_team(ST_INV_KILLS, "frags", SFL_SORT_PRIO_PRIMARY);
- }
- field(SP_KILLS, "frags", ((inv_teams) ? SFL_SORT_PRIO_SECONDARY : SFL_SORT_PRIO_PRIMARY));
- });
-}
-
-void invasion_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up.
+void invasion_Initialize()
{
if(autocvar_g_invasion_type == INV_TYPE_HUNT || autocvar_g_invasion_type == INV_TYPE_STAGE)
cvar_set("fraglimit", "0");
- if(autocvar_g_invasion_teams)
- {
- invasion_teams = BITS(bound(2, autocvar_g_invasion_teams, 4));
- }
- else
- invasion_teams = 0;
+ invasion_teams = autocvar_g_invasion_teams ? BITS(bound(2, autocvar_g_invasion_teams, 4)) : 0;
independent_players = 1; // to disable extra useless scores
- invasion_ScoreRules(invasion_teams);
+ if (invasion_teams) { CheckAllowedTeams(NULL); }
+ GameRules_score_enabled(false);
+ GameRules_scoring(invasion_teams, 0, 0, {
+ if (invasion_teams) {
+ field_team(ST_INV_KILLS, "frags", SFL_SORT_PRIO_PRIMARY);
+ }
+ field(SP_KILLS, "frags", ((invasion_teams) ? SFL_SORT_PRIO_SECONDARY : SFL_SORT_PRIO_PRIMARY));
+ });
independent_players = 0;
- if(autocvar_g_invasion_type == INV_TYPE_ROUND)
- {
+ if (autocvar_g_invasion_type == INV_TYPE_ROUND) {
round_handler_Spawn(Invasion_CheckPlayers, Invasion_CheckWinner, Invasion_RoundStart);
round_handler_Init(5, autocvar_g_invasion_warmup, autocvar_g_invasion_round_timelimit);
inv_maxrounds = 15; // 15?
}
}
-
-void invasion_Initialize()
-{
- InitializeEntity(NULL, invasion_DelayedInit, INITPRIO_GAMETYPE);
-}
#include "gamemode_tdm.qh"
-int autocvar_g_tdm_teams;
-int autocvar_g_tdm_teams_override;
-
/*QUAKED spawnfunc_tdm_team (0 .5 .8) (-16 -16 -24) (16 16 32)
Team declaration for TDM gameplay, this allows you to decide what team names and control point models are used in your map.
Note: If you use spawnfunc_tdm_team entities you must define at least 2! However, unlike domination, you don't need to make a blank one too.
//spawnfunc_tdm_team(this);
}
-void tdm_DelayedInit(entity this)
-{
- // if no teams are found, spawn defaults
- if(find(NULL, classname, "tdm_team") == NULL)
- {
- LOG_TRACE("No \"tdm_team\" entities found on this map, creating them anyway.");
-
- int numteams = autocvar_g_tdm_teams_override;
- if(numteams < 2) { numteams = autocvar_g_tdm_teams; }
-
- int teams = BITS(bound(2, numteams, 4));
- if(teams & BIT(0))
- tdm_SpawnTeam("Red", NUM_TEAM_1);
- if(teams & BIT(1))
- tdm_SpawnTeam("Blue", NUM_TEAM_2);
- if(teams & BIT(2))
- tdm_SpawnTeam("Yellow", NUM_TEAM_3);
- if(teams & BIT(3))
- tdm_SpawnTeam("Pink", NUM_TEAM_4);
- }
-}
-
MUTATOR_HOOKFUNCTION(tdm, CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
{
M_ARGV(1, string) = "tdm_team";
int autocvar_g_tdm_point_limit;
int autocvar_g_tdm_point_leadlimit;
bool autocvar_g_tdm_team_spawns;
-void tdm_DelayedInit(entity this);
+int autocvar_g_tdm_teams;
+int autocvar_g_tdm_teams_override;
+
+void tdm_SpawnTeam (string teamname, int teamcolor);
REGISTER_MUTATOR(tdm, false)
{
GameRules_limit_score(autocvar_g_tdm_point_limit);
GameRules_limit_lead(autocvar_g_tdm_point_leadlimit);
- InitializeEntity(NULL, tdm_DelayedInit, INITPRIO_GAMETYPE);
+ // if no teams are found, spawn defaults
+ if (find(NULL, classname, "tdm_team") == NULL) {
+ LOG_TRACE("No \"tdm_team\" entities found on this map, creating them anyway.");
+
+ int numteams = autocvar_g_tdm_teams_override;
+ if (numteams < 2) { numteams = autocvar_g_tdm_teams; }
+
+ int teams = BITS(bound(2, numteams, 4));
+ if (teams & BIT(0)) tdm_SpawnTeam("Red", NUM_TEAM_1);
+ if (teams & BIT(1)) tdm_SpawnTeam("Blue", NUM_TEAM_2);
+ if (teams & BIT(2)) tdm_SpawnTeam("Yellow", NUM_TEAM_3);
+ if (teams & BIT(3)) tdm_SpawnTeam("Pink", NUM_TEAM_4);
+ }
}
return 0;
}