Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
world.qh File Reference
Include dependency graph for world.qh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define autocvar_g_weaponarena   cvar_string("g_weaponarena")
#define WARMUP_START_WEAPONS   ((autocvar_g_warmup_allguns == 1) ? (warmup_start_weapons & (weaponsInMap | start_weapons)) : warmup_start_weapons)

Functions

void CheckRules_World ()
void DropToFloor_QC_DelayedInit (entity this)
void DumpStats (float final)
void InitializeEntitiesRun ()
void InitializeEntity (entity e, void(entity this) func, int order)
void MatchEnd_RestoreSpectatorAndTeamStatus (.int prev_team_field)
void MatchEnd_RestoreSpectatorStatus ()
bool MoveToRandomLocationWithinBounds (entity e, vector boundmin, vector boundmax, float goodcontents, float badcontents, float badsurfaceflags, int attempts, float maxaboveground, float minviewdistance, bool frompos)
float MoveToRandomMapLocation (entity e, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance)
void readlevelcvars ()
void readplayerstartcvars ()
void ReadyRestart (bool forceWarmupEnd)
float RedirectionThink ()
void SetWinners (.float field, float value)
 STATIC_INIT (g_moveables)
 void (entity this) initialize_entity
int want_weapon (entity weaponinfo, int allguns)
float WinningCondition_Scores (float limit, float leadlimit)

Variables

bool autocvar__endmatch
bool autocvar__sv_init
string autocvar__sv_vote_gametype_custom
bool autocvar_g_jetpack
string autocvar_g_random_start_weapons
 Holds a list of possible random start weapons.
bool autocvar_g_use_ammunition
int autocvar_g_warmup
int autocvar_g_warmup_allguns
bool autocvar_g_warmup_allow_timeout
string autocvar_quit_and_redirect
float autocvar_quit_and_redirect_timer
bool autocvar_quit_when_empty
string autocvar_sessionid
bool autocvar_sv_curl_serverpackages_auto
bool autocvar_sv_db_saveasdump
bool autocvar_sv_dedicated
bool autocvar_sv_logscores_bots
bool autocvar_sv_logscores_console
bool autocvar_sv_logscores_file
string autocvar_sv_logscores_filename
float autocvar_sv_mapchange_delay
bool autocvar_sv_mapformat_is_quake2
bool autocvar_sv_mapformat_is_quake3
string autocvar_sv_termsofservice_url
float autocvar_timelimit_decrement
float autocvar_timelimit_increment
float autocvar_timelimit_max
float autocvar_timelimit_min
float autocvar_timelimit_overtime
int autocvar_timelimit_overtimes
float autocvar_timelimit_suddendeath
string cache_lastmutatormsg
string cache_mutatormsg
float checkrules_equality
int checkrules_overtimesadded
float checkrules_suddendeathend
float checkrules_suddendeathwarning
string clientstuff
string cvar_changes
string cvar_purechanges
float cvar_purechanges_count
float default_player_alpha
float default_weapon_alpha
vector dropped_origin
string fog
float g_grappling_hook
IntrusiveList g_moveables
float g_weapon_stay
float g_weaponarena
string g_weaponarena_list
float g_weaponarena_random
WepSet g_weaponarena_weapons
bool gametype_custom_enabled
entity initialize_entity_first
entity initialize_entity_next
int initialize_entity_order
string loaded_gametype_custom_string
string matchid
string modname
bool observe_blocked_if_eliminated = false
entity random_start_ammo
 Entity that contains amount of ammo to give with random start weapons.
int random_start_weapons_count
 Number of random start weapons to give to players.
string record_type
string redirection_target
float ServerProgsDB
float start_ammo_cells
float start_ammo_fuel
float start_ammo_nails
float start_ammo_rockets
float start_ammo_shells
float start_armorvalue
float start_health
int start_items
WepSet start_weapons
WepSet start_weapons_default
WepSet start_weapons_defaultmask
bool sv_ready_restart_after_countdown
string sv_termsofservice_url_escaped
float TemporaryDB
int warmup_stage
float warmup_start_ammo_cells
float warmup_start_ammo_fuel
float warmup_start_ammo_nails
float warmup_start_ammo_rockets
float warmup_start_ammo_shells
float warmup_start_armorvalue
float warmup_start_health
WepSet warmup_start_weapons
WepSet warmup_start_weapons_default
WepSet warmup_start_weapons_defaultmask
float winning
const int WINNING_NEVER = 2
const int WINNING_NO = 0
const int WINNING_STARTSUDDENDEATHOVERTIME = 3
const int WINNING_YES = 1
int world_initialized

Macro Definition Documentation

◆ autocvar_g_weaponarena

#define autocvar_g_weaponarena   cvar_string("g_weaponarena")

Definition at line 12 of file world.qh.

Referenced by GameLogInit().

◆ WARMUP_START_WEAPONS

#define WARMUP_START_WEAPONS   ((autocvar_g_warmup_allguns == 1) ? (warmup_start_weapons & (weaponsInMap | start_weapons)) : warmup_start_weapons)

Definition at line 101 of file world.qh.

Referenced by GiveWarmupResources(), and MUTATOR_HOOKFUNCTION().

Function Documentation

◆ CheckRules_World()

void CheckRules_World ( )

Definition at line 1721 of file world.qc.

1722{
1723 VoteThink();
1724 MapVote_Think();
1725
1727
1728 if (intermission_running) // someone else quit the game already
1729 {
1730 if(player_count == 0) // Nobody there? Then let's go to the next map
1731 MapVote_Start();
1732 // this will actually check the player count in the next frame
1733 // again, but this shouldn't hurt
1734 return;
1735 }
1736
1737 float timelimit = autocvar_timelimit * 60;
1738 float fraglimit = autocvar_fraglimit;
1739 float leadlimit = autocvar_leadlimit;
1740 if (leadlimit < 0) leadlimit = 0;
1741
1742 if(warmup_stage || time <= game_starttime) // NOTE: this is <= to prevent problems in the very tic where the game starts
1743 {
1744 if(timelimit > 0)
1745 timelimit = 0; // timelimit is not made for warmup
1746 if(fraglimit > 0)
1747 fraglimit = 0; // no fraglimit for now
1748 leadlimit = 0; // no leadlimit for now
1749 }
1750
1751 if (autocvar__endmatch || timelimit < 0)
1752 {
1753 // endmatch
1754 NextLevel();
1755 return;
1756 }
1757
1758 if(timelimit > 0)
1759 timelimit += game_starttime;
1760
1761 int overtimes_prev = overtimes;
1762 int wantovertime = 0;
1763
1765 {
1767 {
1770 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_RACE_FINISHLAP);
1771 else
1772 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_OVERTIME_FRAG);
1773 }
1774 }
1775 else
1776 {
1777 if (timelimit && time >= timelimit)
1778 {
1779 if(g_race && (g_race_qualifying == 2) && timelimit > 0)
1780 {
1781 float totalplayers;
1782 float playerswithlaps;
1783 float readyplayers;
1784 totalplayers = playerswithlaps = readyplayers = 0;
1786 ++totalplayers;
1787 if(GameRules_scoring_add(it, RACE_FASTEST, 0))
1788 ++playerswithlaps;
1789 if(it.ready)
1790 ++readyplayers;
1791 });
1792
1793 // at least 2 of the players have completed a lap: start the RACE
1794 // otherwise, the players should end the qualifying on their own
1795 if(readyplayers || playerswithlaps >= 2)
1796 {
1798 ReadyRestart(true); // go to race
1799 return;
1800 }
1801 else
1802 wantovertime |= InitiateSuddenDeath();
1803 }
1804 else
1805 wantovertime |= InitiateSuddenDeath();
1806 }
1807 }
1808
1810 {
1811 NextLevel();
1812 return;
1813 }
1814
1815 int checkrules_status = WinningCondition_RanOutOfSpawns();
1816 if(checkrules_status == WINNING_YES)
1817 bprint("Hey! Someone ran out of spawns!\n");
1818 else if(MUTATOR_CALLHOOK(CheckRules_World, checkrules_status, timelimit, fraglimit))
1819 checkrules_status = M_ARGV(0, float);
1820 else
1821 checkrules_status = WinningCondition_Scores(fraglimit, leadlimit);
1822
1823 if(checkrules_status == WINNING_STARTSUDDENDEATHOVERTIME)
1824 {
1825 checkrules_status = WINNING_NEVER;
1827 wantovertime |= InitiateSuddenDeath();
1828 }
1829
1830 if(checkrules_status == WINNING_NEVER)
1831 // equality cases! Nobody wins if the overtime ends in a draw.
1832 ClearWinners();
1833
1834 if(wantovertime)
1835 {
1836 if(checkrules_status == WINNING_NEVER)
1838 else
1839 checkrules_status = WINNING_YES;
1840 }
1841
1843 if(checkrules_status != WINNING_NEVER || time >= checkrules_suddendeathend)
1844 checkrules_status = WINNING_YES;
1845
1846 if(checkrules_status == WINNING_YES)
1847 {
1848 if (overtimes == OVERTIME_SUDDENDEATH && overtimes != overtimes_prev)
1849 {
1850 // if suddendeathend overtime has just begun, revert it
1852 overtimes = overtimes_prev;
1853 }
1854 //print("WINNING\n");
1855 NextLevel();
1856 }
1857}
int player_count
Definition api.qh:103
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
bool warmup_stage
Definition main.qh:120
#define g_race
Definition race.qh:48
#define M_ARGV(x, type)
Definition events.qh:17
#define IS_PLAYER(s)
Definition player.qh:242
const int OVERTIME_SUDDENDEATH
Definition stats.qh:77
#define autocvar_timelimit
Definition stats.qh:92
#define autocvar_fraglimit
Definition stats.qh:90
float game_starttime
Definition stats.qh:82
int overtimes
Definition stats.qh:86
int autocvar_leadlimit
Definition stats.qh:84
float time
bool intermission_running
void bprint(string text,...)
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
Definition all.qc:1573
#define NULL
Definition post.qh:14
void VoteThink()
Definition vote.qc:336
void ReadyRestart(bool forceWarmupEnd)
Definition vote.qc:526
void MapVote_Think()
Definition mapvoting.qc:758
void MapVote_Start()
Definition mapvoting.qc:743
int g_race_qualifying
Definition race.qh:13
#define GameRules_scoring_add(client, fld, value)
Definition sv_rules.qh:85
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:52
void InitiateOvertime()
Definition world.qc:1495
int InitiateSuddenDeath()
Definition world.qc:1463
void SetDefaultAlpha()
Definition world.qc:105
void ClearWinners()
Definition world.qc:1550
void CheckRules_World()
Definition world.qc:1721
void NextLevel()
Definition world.qc:1400
float WinningCondition_Scores(float limit, float leadlimit)
Definition world.qc:1556
float WinningCondition_RanOutOfSpawns()
Definition world.qc:1637
const int WINNING_NEVER
Definition world.qh:134
float checkrules_suddendeathwarning
Definition world.qh:36
const int WINNING_STARTSUDDENDEATHOVERTIME
Definition world.qh:135
int checkrules_overtimesadded
Definition world.qh:38
float checkrules_suddendeathend
Definition world.qh:37
bool autocvar__endmatch
Definition world.qh:6
const int WINNING_YES
Definition world.qh:133

References autocvar__endmatch, autocvar_fraglimit, autocvar_leadlimit, autocvar_timelimit, bprint(), checkrules_overtimesadded, checkrules_suddendeathend, checkrules_suddendeathwarning, CheckRules_World(), ClearWinners(), FOREACH_CLIENT, g_race, g_race_qualifying, game_starttime, GameRules_scoring_add, InitiateOvertime(), InitiateSuddenDeath(), intermission_running, IS_PLAYER, M_ARGV, MapVote_Start(), MapVote_Think(), MUTATOR_CALLHOOK, NextLevel(), NULL, OVERTIME_SUDDENDEATH, overtimes, player_count, ReadyRestart(), Send_Notification(), SetDefaultAlpha(), time, VoteThink(), warmup_stage, WINNING_NEVER, WINNING_STARTSUDDENDEATHOVERTIME, WINNING_YES, WinningCondition_RanOutOfSpawns(), and WinningCondition_Scores().

Referenced by CheckRules_World(), MUTATOR_HOOKABLE(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), and StartFrame().

◆ DropToFloor_QC_DelayedInit()

void DropToFloor_QC_DelayedInit ( entity this)

Definition at line 2423 of file world.qc.

2424{
2426}
const int INITPRIO_DROPTOFLOOR
Definition constants.qh:97
void InitializeEntity(entity e, void(entity this) func, int order)
Definition world.qc:2225
void DropToFloor_QC(entity this)
Definition world.qc:2299

References DropToFloor_QC(), entity(), InitializeEntity(), and INITPRIO_DROPTOFLOOR.

Referenced by ctf_FlagSetup(), dom_controlpoint_setup(), MUTATOR_HOOKFUNCTION(), ons_ControlPoint_Setup(), ons_GeneratorSetup(), spawn_item_key(), StartItem(), and turret_initialize().

◆ DumpStats()

void DumpStats ( float final)

Definition at line 1260 of file world.qc.

1261{
1262 float file;
1263 string s;
1264 float to_console;
1265 float to_eventlog;
1266 float to_file;
1267 float i;
1268
1269 to_console = autocvar_sv_logscores_console;
1270 to_eventlog = autocvar_sv_eventlog;
1272
1273 if(!final)
1274 {
1275 to_console = true; // always print printstats replies
1276 to_eventlog = false; // but never print them to the event log
1277 }
1278
1279 if(to_eventlog)
1281 to_console = false; // otherwise we get the output twice
1282
1283 if(final)
1284 s = ":scores:";
1285 else
1286 s = ":status:";
1287 s = strcat(s, GetGametype(), "_", GetMapname(), ":", ftos(rint(time)));
1288
1289 if(to_console)
1290 LOG_HELP(s);
1291 if(to_eventlog)
1292 GameLogEcho(s);
1293
1294 file = -1;
1295 if(to_file)
1296 {
1298 if(file == -1)
1299 to_file = false;
1300 else
1301 fputs(file, strcat(s, "\n"));
1302 }
1303
1304 s = strcat(":labels:player:", GetPlayerScoreString(NULL, 0));
1305 if(to_console)
1306 LOG_HELP(s);
1307 if(to_eventlog)
1308 GameLogEcho(s);
1309 if(to_file)
1310 fputs(file, strcat(s, "\n"));
1311
1313 s = strcat(":player:see-labels:", GetPlayerScoreString(it, 0), ":");
1314 s = strcat(s, ftos(rint(time - CS(it).jointime)), ":");
1315 if(IS_PLAYER(it) || INGAME_JOINED(it))
1316 s = strcat(s, ftos(it.team), ":");
1317 else
1318 s = strcat(s, "spectator:");
1319
1320 if(to_console)
1321 LOG_HELP(s, playername(it.netname, it.team, false));
1322 if(to_eventlog)
1323 GameLogEcho(strcat(s, ftos(it.playerid), ":", playername(it.netname, it.team, false)));
1324 if(to_file)
1325 fputs(file, strcat(s, playername(it.netname, it.team, false), "\n"));
1326 });
1327
1328 if(teamplay)
1329 {
1330 s = strcat(":labels:teamscores:", GetTeamScoreString(0, 0));
1331 if(to_console)
1332 LOG_HELP(s);
1333 if(to_eventlog)
1334 GameLogEcho(s);
1335 if(to_file)
1336 fputs(file, strcat(s, "\n"));
1337
1338 for(i = 1; i < 16; ++i)
1339 {
1340 s = strcat(":teamscores:see-labels:", GetTeamScoreString(i, 0));
1341 s = strcat(s, ":", ftos(i));
1342 if(to_console)
1343 LOG_HELP(s);
1344 if(to_eventlog)
1345 GameLogEcho(s);
1346 if(to_file)
1347 fputs(file, strcat(s, "\n"));
1348 }
1349 }
1350
1351 if(to_console)
1352 LOG_HELP(":end");
1353 if(to_eventlog)
1354 GameLogEcho(":end");
1355 if(to_file)
1356 {
1357 fputs(file, ":end\n");
1358 fclose(file);
1359 }
1360}
string playername(string thename, int teamid, bool team_colorize)
Definition util.qc:2188
const float FILE_APPEND
void GameLogEcho(string s)
Definition gamelog.qc:15
bool autocvar_sv_eventlog_console
Definition gamelog.qh:4
bool autocvar_sv_eventlog
Definition gamelog.qh:3
string GetMapname()
string GetGametype()
#define LOG_HELP(...)
Definition log.qh:85
void fclose(float fhandle)
void fputs(float fhandle, string s)
float fopen(string filename, float mode)
float rint(float f)
string ftos(float f)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
string GetTeamScoreString(int tm, float shortString)
Definition scores.qc:674
string GetPlayerScoreString(entity pl, float shortString)
Returns score strings for eventlog etc.
Definition scores.qc:613
float jointime
Definition client.qh:66
ClientState CS(Client this)
Definition state.qh:47
#define INGAME_JOINED(it)
Definition sv_rules.qh:25
bool teamplay
Definition teams.qh:59
#define IS_REAL_CLIENT(v)
Definition utils.qh:17
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
Definition utils.qh:15
bool autocvar_sv_logscores_file
Definition world.qh:21
bool autocvar_sv_logscores_console
Definition world.qh:20
bool autocvar_sv_logscores_bots
Definition world.qh:19
string autocvar_sv_logscores_filename
Definition world.qh:22

References autocvar_sv_eventlog, autocvar_sv_eventlog_console, autocvar_sv_logscores_bots, autocvar_sv_logscores_console, autocvar_sv_logscores_file, autocvar_sv_logscores_filename, CS(), fclose(), FILE_APPEND, fopen(), FOREACH_CLIENT, fputs(), ftos(), GameLogEcho(), GetGametype(), GetMapname(), GetPlayerScoreString(), GetTeamScoreString(), INGAME_JOINED, IS_BOT_CLIENT, IS_PLAYER, IS_REAL_CLIENT, jointime, LOG_HELP, NULL, playername(), rint(), strcat(), teamplay, and time.

Referenced by GameCommand_printstats(), and NextLevel().

◆ InitializeEntitiesRun()

void InitializeEntitiesRun ( )

Definition at line 2258 of file world.qc.

2259{
2260 entity startoflist = initialize_entity_first;
2263 for (entity e = startoflist; e; e = e.initialize_entity_next)
2264 {
2265 e.remove_except_protected_forbidden = 1;
2266 }
2267 for (entity e = startoflist; e; )
2268 {
2269 e.remove_except_protected_forbidden = 0;
2270 e.initialize_entity_order = 0;
2271 entity next = e.initialize_entity_next;
2272 e.initialize_entity_next = NULL;
2273 var void(entity this) func = e.initialize_entity;
2274 e.initialize_entity = func_null;
2275 if (e.classname == "initialize_entity")
2276 {
2277 entity wrappee = e.enemy;
2278 builtin_remove(e);
2279 e = wrappee;
2280 }
2281 //dprint("Delayed initialization: ", e.classname, "\n");
2282 if (func)
2283 {
2284 func(e);
2285 }
2286 else
2287 {
2288 eprint(e);
2289 backtrace(strcat("Null function in: ", e.classname, "\n"));
2290 }
2291 e = next;
2292 }
2294}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
next
Definition all.qh:93
#define backtrace(msg)
Definition log.qh:99
void eprint(entity e)
var void func_null()
void
Definition self.qh:72
void remove_unsafely(entity e)
Definition main.qc:276
void remove_except_protected(entity e)
Definition main.qc:269
var void delete_fn(entity e)
entity initialize_entity_first
Definition world.qh:121

References backtrace, delete_fn(), entity(), eprint(), func_null(), initialize_entity_first, next, NULL, remove_except_protected(), remove_unsafely(), strcat(), and void.

Referenced by StartFrame().

◆ InitializeEntity()

void InitializeEntity ( entity e,
void(entity this) func,
int order )

Definition at line 2225 of file world.qc.

2226{
2227 entity prev, cur;
2228
2229 if (!e || e.initialize_entity)
2230 {
2231 // make a proxy initializer entity
2232 entity e_old = e;
2233 e = new(initialize_entity);
2234 e.enemy = e_old;
2235 }
2236
2237 e.initialize_entity = func;
2238 e.initialize_entity_order = order;
2239
2241 prev = NULL;
2242 for (;;)
2243 {
2244 if (!cur || cur.initialize_entity_order > order)
2245 {
2246 // insert between prev and cur
2247 if (prev)
2248 prev.initialize_entity_next = e;
2249 else
2251 e.initialize_entity_next = cur;
2252 return;
2253 }
2254 prev = cur;
2255 cur = cur.initialize_entity_next;
2256 }
2257}
prev
Definition all.qh:71

References entity(), initialize_entity_first, NULL, and prev.

Referenced by buffs_Initialize(), ctf_FlagSetup(), ctf_Initialize(), dom_Initialize(), DropToFloor_QC_DelayedInit(), g_clientmodel_init(), g_model_init(), InitGameplayMode(), invasion_Initialize(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), nb_Initialize(), ons_ControlPoint_Setup(), ons_GeneratorSetup(), ons_Initialize(), readplayerstartcvars(), REGISTER_MUTATOR(), relocate_spawnpoint(), SetBrushEntityModel(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), StartItem(), target_checkpoint_setup(), tdm_Initialize(), tmayhem_Initialize(), and turret_initialize().

◆ MatchEnd_RestoreSpectatorAndTeamStatus()

void MatchEnd_RestoreSpectatorAndTeamStatus ( .int prev_team_field)

Definition at line 1366 of file world.qc.

1367{
1368 bool fix_team = (teamplay && prev_team_field != team);
1369 FOREACH_CLIENT(true,
1370 {
1371 if (!IS_PLAYER(it) && INGAME_JOINING(it))
1372 {
1374 PutObserverInServer(it, true, false);
1375 bprint(playername(it.netname, it.team, false), " has been moved back to spectator");
1376 it.winning = false;
1377 }
1378 else if (fix_team && INGAME_JOINED(it) && it.(prev_team_field) && it.team != it.(prev_team_field))
1379 {
1381 if (MoveToTeam(it, Team_TeamToIndex(it.(prev_team_field)), 6))
1382 {
1383 string pl_name = playername(it.netname, it.team, false);
1384 bprint(pl_name, " has been moved back to the ", Team_ColoredFullName(it.team));
1385 }
1386 it.winning = (it.team == WinningConditionHelper_winnerteam);
1387 }
1388 });
1389}
int team
Definition main.qh:188
void PutObserverInServer(entity this, bool is_forced, bool use_spawnpoint)
putting a client as observer in the server
Definition client.qc:261
float WinningConditionHelper_winnerteam
the color of the winning team, or -1 if none
Definition scores.qh:109
#define INGAME_STATUS_CLEAR(it)
Definition sv_rules.qh:22
#define INGAME_JOINING(it)
Definition sv_rules.qh:26
void Player_SetForcedTeamIndex(entity player, int team_index)
Sets the index of the forced team of the given player.
Definition teamplay.qc:323
bool MoveToTeam(entity client, int team_index, int type)
Moves player to the specified team.
Definition teamplay.qc:299
@ TEAM_FORCE_DEFAULT
Don't force any team.
Definition teamplay.qh:138
int Team_TeamToIndex(int team_num)
Converts team value into team index.
Definition teams.qh:184
#define Team_ColoredFullName(teamid)
Definition teams.qh:232

References bprint(), FOREACH_CLIENT, INGAME_JOINED, INGAME_JOINING, INGAME_STATUS_CLEAR, IS_PLAYER, MoveToTeam(), Player_SetForcedTeamIndex(), playername(), PutObserverInServer(), team, Team_ColoredFullName, TEAM_FORCE_DEFAULT, Team_TeamToIndex(), teamplay, and WinningConditionHelper_winnerteam.

Referenced by MatchEnd_RestoreSpectatorStatus(), and MUTATOR_HOOKFUNCTION().

◆ MatchEnd_RestoreSpectatorStatus()

void MatchEnd_RestoreSpectatorStatus ( )

Definition at line 1391 of file world.qc.

1392{
1394}
void MatchEnd_RestoreSpectatorAndTeamStatus(.int prev_team_field)
Definition world.qc:1366

References MatchEnd_RestoreSpectatorAndTeamStatus(), and team.

Referenced by MUTATOR_HOOKFUNCTION().

◆ MoveToRandomLocationWithinBounds()

bool MoveToRandomLocationWithinBounds ( entity e,
vector boundmin,
vector boundmax,
float goodcontents,
float badcontents,
float badsurfaceflags,
int attempts,
float maxaboveground,
float minviewdistance,
bool frompos )

Definition at line 1113 of file world.qc.

1114{
1115 float m = e.dphitcontentsmask;
1116 e.dphitcontentsmask = goodcontents | badcontents;
1117
1118 vector org = boundmin;
1119 vector delta = boundmax - boundmin;
1120
1121 vector start, end;
1122 start = end = org;
1123 int j; // used after the loop
1124 for(j = 0; j < attempts; ++j)
1125 {
1126 start.x = org.x + random() * delta.x;
1127 start.y = org.y + random() * delta.y;
1128 start.z = org.z + random() * delta.z;
1129
1130 // rule 1: start inside world bounds, and outside
1131 // solid, and don't start from somewhere where you can
1132 // fall down to evil
1133 tracebox(start, e.mins, e.maxs, start - '0 0 1' * delta.z, MOVE_NORMAL, e);
1134 if (trace_fraction >= 1)
1135 continue;
1136 if (trace_startsolid)
1137 continue;
1138 if (trace_dphitcontents & badcontents)
1139 continue;
1140 if (trace_dphitq3surfaceflags & badsurfaceflags)
1141 continue;
1142
1143 // rule 2: if we are too high, lower the point
1144 if (trace_fraction * delta.z > maxaboveground)
1145 start = trace_endpos + '0 0 1' * maxaboveground;
1146 vector enddown = trace_endpos;
1147
1148 // rule 3: make sure we aren't outside the map. This only works
1149 // for somewhat well formed maps. A good rule of thumb is that
1150 // the map should have a convex outside hull.
1151 // these can be traceLINES as we already verified the starting box
1152 vector mstart = start + 0.5 * (e.mins + e.maxs);
1153 traceline(mstart, mstart + '1 0 0' * delta.x, MOVE_NORMAL, e);
1154 if (trace_fraction >= 1 || trace_dphittexturename == "common/caulk")
1155 continue;
1156 traceline(mstart, mstart - '1 0 0' * delta.x, MOVE_NORMAL, e);
1157 if (trace_fraction >= 1 || trace_dphittexturename == "common/caulk")
1158 continue;
1159 traceline(mstart, mstart + '0 1 0' * delta.y, MOVE_NORMAL, e);
1160 if (trace_fraction >= 1 || trace_dphittexturename == "common/caulk")
1161 continue;
1162 traceline(mstart, mstart - '0 1 0' * delta.y, MOVE_NORMAL, e);
1163 if (trace_fraction >= 1 || trace_dphittexturename == "common/caulk")
1164 continue;
1165 traceline(mstart, mstart + '0 0 1' * delta.z, MOVE_NORMAL, e);
1166 if (trace_fraction >= 1 || trace_dphittexturename == "common/caulk")
1167 continue;
1168
1169 // rule 4: we must "be seen" by some spawnpoint or item
1170 // Note that checkpvs from mstart to item can detect visibility if mstart is behind
1171 // patch brushes (curved walls) that don't block visibility from the outside, however
1172 // the next traceline from item to mstart correctly detects invisibility in this case
1173 entity sp = NULL;
1174 if(frompos)
1175 {
1176 if((traceline(e.origin, mstart, MOVE_NORMAL, e), trace_fraction) >= 1)
1177 sp = e;
1178 }
1179 if(!sp)
1180 {
1181 IL_EACH(g_spawnpoints, checkpvs(mstart, it),
1182 {
1183 if((traceline(it.origin, mstart, MOVE_NORMAL, e), trace_fraction) >= 1)
1184 {
1185 sp = it;
1186 break;
1187 }
1188 });
1189 }
1190 if(!sp)
1191 {
1192 int items_checked = 0;
1193 IL_EACH(g_items, checkpvs(mstart, it),
1194 {
1195 if((traceline(it.origin + (it.mins + it.maxs) * 0.5, mstart, MOVE_NORMAL, e), trace_fraction) >= 1)
1196 {
1197 sp = it;
1198 break;
1199 }
1200
1201 ++items_checked;
1202 if(items_checked >= attempts)
1203 break; // sanity
1204 });
1205
1206 if(!sp)
1207 continue;
1208 }
1209
1210 float vlen_delta = vlen(delta);
1211 // find a random vector to "look at"
1212 end.x = org.x + random() * delta.x;
1213 end.y = org.y + random() * delta.y;
1214 end.z = org.z + random() * delta.z;
1215 end = start + normalize(end - start) * vlen_delta;
1216
1217 // rule 4: start TO end must not be too short
1218 tracebox(start, e.mins, e.maxs, end, MOVE_NORMAL, e);
1220 continue;
1221 if(trace_fraction < minviewdistance / vlen_delta)
1222 continue;
1223
1224 // rule 5: don't want to look at sky
1226 continue;
1227
1228 // rule 6: we must not end up in trigger_hurt
1229 if(tracebox_hits_trigger_hurt(start, e.mins, e.maxs, enddown))
1230 continue;
1231
1232 break;
1233 }
1234
1235 e.dphitcontentsmask = m;
1236
1237 if(j < attempts)
1238 {
1239 setorigin(e, start);
1240 e.angles = vectoangles(end - start);
1241 LOG_DEBUG("Needed ", ftos(j + 1), " attempts");
1242 return true;
1243 }
1244 return false;
1245}
float Q3SURFACEFLAG_SKY
float trace_dphitcontents
const float MOVE_NORMAL
string trace_dphittexturename
vector trace_endpos
float checkpvs(vector viewpos, entity viewee)
float trace_startsolid
float trace_dphitq3surfaceflags
float trace_fraction
bool tracebox_hits_trigger_hurt(vector start, vector e_min, vector e_max, vector end)
Definition hurt.qc:79
#define IL_EACH(this, cond, body)
#define LOG_DEBUG(...)
Definition log.qh:80
float random(void)
float vlen(vector v)
vector vectoangles(vector v)
vector normalize(vector v)
vector
Definition self.qh:92
vector org
Definition self.qh:92
IntrusiveList g_items
Definition items.qh:119
IntrusiveList g_spawnpoints

References checkpvs(), entity(), ftos(), g_items, g_spawnpoints, IL_EACH, LOG_DEBUG, MOVE_NORMAL, normalize(), NULL, org, Q3SURFACEFLAG_SKY, random(), trace_dphitcontents, trace_dphitq3surfaceflags, trace_dphittexturename, trace_endpos, trace_fraction, trace_startsolid, tracebox_hits_trigger_hurt(), vectoangles(), vector, and vlen().

Referenced by M_Mage_Attack_Teleport(), and MoveToRandomMapLocation().

◆ MoveToRandomMapLocation()

float MoveToRandomMapLocation ( entity e,
float goodcontents,
float badcontents,
float badsurfaceflags,
float attempts,
float maxaboveground,
float minviewdistance )

Definition at line 1247 of file world.qc.

1248{
1249 return MoveToRandomLocationWithinBounds(e, world.mins, world.maxs, goodcontents, badcontents, badsurfaceflags, attempts, maxaboveground, minviewdistance, false);
1250}
#define world
Definition post.qh:15
bool MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax, float goodcontents, float badcontents, float badsurfaceflags, int attempts, float maxaboveground, float minviewdistance, bool frompos)
Definition world.qc:1113

References entity(), MoveToRandomLocationWithinBounds(), and world.

Referenced by buff_Respawn(), CheatImpulse(), invasion_SpawnChosenMonster(), ka_RespawnBall(), and tka_RespawnBall().

◆ readlevelcvars()

void readlevelcvars ( )

Definition at line 2183 of file world.qc.

2184{
2186 if(cvar("sv_allow_fullbright"))
2188
2190 if(cvar("sv_forbid_pickuptimer"))
2192
2193 sv_ready_restart_after_countdown = cvar("sv_ready_restart_after_countdown");
2194
2195 if(cvar("g_campaign"))
2196 warmup_stage = 0; // no warmup during campaign
2197 else
2198 {
2201 warmup_limit = -1; // don't start until there's enough players
2202 else if (warmup_stage == 1)
2203 {
2204 // this code is duplicated in ReadyCount()
2205 warmup_limit = cvar("g_warmup_limit");
2206 if(warmup_limit == 0)
2208 }
2209 }
2210
2211 g_weapon_stay = cvar(strcat("g_", GetGametype(), "_weapon_stay"));
2212 if(!g_weapon_stay)
2213 g_weapon_stay = cvar("g_weapon_stay");
2214
2215 MUTATOR_CALLHOOK(ReadLevelCvars);
2216
2218 game_starttime = time + cvar("g_start_delay");
2219
2220 FOREACH(Weapons, it != WEP_Null, { it.wr_init(it); });
2221
2223}
int serverflags
Definition main.qh:211
float warmup_limit
Definition stats.qh:377
const int SERVERFLAG_FORBID_PICKUPTIMER
Definition constants.qh:20
const int SERVERFLAG_ALLOW_FULLBRIGHT
Definition constants.qh:16
Weapons
Definition guide.qh:113
#define FOREACH(list, cond, body)
Definition iter.qh:19
bool autocvar_g_campaign
Definition menu.qc:752
float cvar(string name)
void readplayerstartcvars()
Definition world.qc:1979
float g_weapon_stay
Definition world.qh:109
int autocvar_g_warmup
Definition world.qh:9
bool sv_ready_restart_after_countdown
Definition world.qh:116

References autocvar_g_campaign, autocvar_g_warmup, autocvar_timelimit, cvar(), FOREACH, g_weapon_stay, game_starttime, GetGametype(), MUTATOR_CALLHOOK, readplayerstartcvars(), SERVERFLAG_ALLOW_FULLBRIGHT, SERVERFLAG_FORBID_PICKUPTIMER, serverflags, strcat(), sv_ready_restart_after_countdown, time, warmup_limit, warmup_stage, and Weapons.

Referenced by spawnfunc().

◆ readplayerstartcvars()

void readplayerstartcvars ( )

Definition at line 1979 of file world.qc.

1980{
1981 // initialize starting values for players
1982 start_weapons = '0 0 0';
1983 start_weapons_default = '0 0 0';
1984 start_weapons_defaultmask = '0 0 0';
1985 start_items = 0;
1987 start_ammo_nails = 0;
1989 start_ammo_cells = 0;
1990 if (random_start_ammo == NULL)
1991 {
1993 }
1994 start_health = cvar("g_balance_health_start");
1995 start_armorvalue = cvar("g_balance_armor_start");
1996
1997 g_weaponarena = 0;
1998 g_weaponarena_weapons = '0 0 0';
1999
2000 string s = cvar_string("g_weaponarena");
2001
2002 MUTATOR_CALLHOOK(SetWeaponArena, s);
2003 s = M_ARGV(0, string);
2004
2005 if (s == "0" || s == "")
2006 {
2007 // no arena
2008 }
2009 else if (s == "off")
2010 {
2011 // forcibly turn off weaponarena
2012 }
2013 else if (s == "all" || s == "1")
2014 {
2015 g_weaponarena = 1;
2016 g_weaponarena_list = "All Weapons Arena";
2018 }
2019 else if (s == "devall")
2020 {
2021 g_weaponarena = 1;
2022 g_weaponarena_list = "Dev All Weapons Arena";
2024 }
2025 else if (s == "most")
2026 {
2027 g_weaponarena = 1;
2028 g_weaponarena_list = "Most Weapons Arena";
2030 }
2031 else if (s == "all_available")
2032 {
2033 g_weaponarena = 1;
2034 g_weaponarena_list = "All Available Weapons Arena";
2035
2036 // this needs to run after weaponsInMapAll is initialized
2038 }
2039 else if (s == "devall_available")
2040 {
2041 g_weaponarena = 1;
2042 g_weaponarena_list = "Dev All Available Weapons Arena";
2043
2044 // this needs to run after weaponsInMapAll is initialized
2046 }
2047 else if (s == "most_available")
2048 {
2049 g_weaponarena = 1;
2050 g_weaponarena_list = "Most Available Weapons Arena";
2051
2052 // this needs to run after weaponsInMapAll is initialized
2054 }
2055 else if (s == "none")
2056 {
2057 g_weaponarena = 1;
2058 g_weaponarena_list = "No Weapons Arena";
2059 }
2060 else
2061 {
2062 g_weaponarena = 1;
2063 float t = tokenize_console(s);
2064 g_weaponarena_list = "";
2065 for (int j = 0; j < t; ++j)
2066 {
2067 s = argv(j);
2068 Weapon wep = Weapon_from_name(s);
2069 if(wep != WEP_Null)
2070 {
2071 g_weaponarena_weapons |= (wep.m_wepset);
2073 }
2074 }
2075 if (g_weaponarena_list != "") // remove trailing " & "
2077 else // no valid weapon found
2078 g_weaponarena_list = "No Weapons Arena";
2079 }
2080
2081 if (g_weaponarena)
2082 {
2083 g_weapon_stay = 0; // incompatible
2087 }
2088 else
2089 {
2090 FOREACH(Weapons, it != WEP_Null, {
2091 int w = want_weapon(it, false);
2092 WepSet s = it.m_wepset;
2093 if(w & 1)
2094 start_weapons |= s;
2095 if(w & 2)
2097 if(w & 4)
2099 });
2100 }
2101
2102 if(cvar("g_balance_superweapons_time") < 0)
2104
2105 if(!cvar("g_use_ammunition"))
2107
2108 start_ammo_shells = cvar("g_start_ammo_shells");
2109 start_ammo_nails = cvar("g_start_ammo_nails");
2110 start_ammo_rockets = cvar("g_start_ammo_rockets");
2111 start_ammo_cells = cvar("g_start_ammo_cells");
2112 start_ammo_fuel = cvar("g_start_ammo_fuel");
2113 random_start_weapons_count = cvar("g_random_start_weapons_count");
2114 SetResource(random_start_ammo, RES_SHELLS, cvar("g_random_start_shells"));
2115 SetResource(random_start_ammo, RES_BULLETS, cvar("g_random_start_bullets"));
2116 SetResource(random_start_ammo, RES_ROCKETS, cvar("g_random_start_rockets"));
2117 SetResource(random_start_ammo, RES_CELLS, cvar("g_random_start_cells"));
2118
2129
2130 if (!g_weaponarena)
2131 {
2132 warmup_start_ammo_shells = cvar("g_warmup_start_ammo_shells");
2133 warmup_start_ammo_nails = cvar("g_warmup_start_ammo_nails");
2134 warmup_start_ammo_rockets = cvar("g_warmup_start_ammo_rockets");
2135 warmup_start_ammo_cells = cvar("g_warmup_start_ammo_cells");
2136 warmup_start_ammo_fuel = cvar("g_warmup_start_ammo_fuel");
2137 warmup_start_health = cvar("g_warmup_start_health");
2138 warmup_start_armorvalue = cvar("g_warmup_start_armor");
2139 warmup_start_weapons = '0 0 0';
2142 FOREACH(Weapons, it != WEP_Null, {
2144 WepSet s = it.m_wepset;
2145 if(w & 1)
2147 if(w & 2)
2149 if(w & 4)
2151 });
2152 }
2153
2155 start_items |= ITEM_Jetpack.m_itemid;
2156
2157 MUTATOR_CALLHOOK(SetStartItems);
2158
2159 if (start_items & ITEM_Jetpack.m_itemid)
2160 {
2161 start_items |= ITEM_FuelRegen.m_itemid;
2162 start_ammo_fuel = max(start_ammo_fuel, cvar("g_balance_fuel_rotstable"));
2163 warmup_start_ammo_fuel = max(warmup_start_ammo_fuel, cvar("g_balance_fuel_rotstable"));
2164 }
2165
2171 SetResource(random_start_ammo, RES_SHELLS, max(0, GetResource(random_start_ammo, RES_SHELLS)));
2172 SetResource(random_start_ammo, RES_BULLETS, max(0, GetResource(random_start_ammo, RES_BULLETS)));
2173 SetResource(random_start_ammo, RES_ROCKETS, max(0, GetResource(random_start_ammo, RES_ROCKETS)));
2174 SetResource(random_start_ammo, RES_CELLS, max(0, GetResource(random_start_ammo, RES_CELLS)));
2175
2181}
void SetResource(entity e, Resource res_type, float amount)
Sets the current amount of resource the given entity will have.
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition weapon.qh:44
string netname
M: refname : reference name name.
Definition weapon.qh:79
const int IT_UNLIMITED_AMMO
Definition item.qh:23
const int IT_UNLIMITED_SUPERWEAPONS
Definition item.qh:24
const int INITPRIO_FINDTARGET
Definition constants.qh:96
#define strlen
#define tokenize_console
string substring(string s, float start, float length)
const string cvar_string(string name)
string strzone(string s)
string argv(float n)
float max(float f,...)
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:67
Weapon Weapon_from_name(string s)
Definition all.qh:144
vector WepSet
Definition weapon.qh:14
int want_weapon(entity weaponinfo, int allguns)
Definition world.qc:1859
WepSet weapons_most()
Definition world.qc:1930
WepSet weapons_all()
Definition world.qc:1910
void weaponarena_available_all_update(entity this)
Definition world.qc:1940
void weaponarena_available_devall_update(entity this)
Definition world.qc:1953
void weaponarena_available_most_update(entity this)
Definition world.qc:1966
WepSet weapons_devall()
Definition world.qc:1920
WepSet start_weapons
Definition world.qh:80
float warmup_start_ammo_cells
Definition world.qh:105
entity random_start_ammo
Entity that contains amount of ammo to give with random start weapons.
Definition world.qh:95
bool autocvar_g_jetpack
Definition world.qh:8
float start_ammo_shells
Definition world.qh:84
float warmup_start_ammo_rockets
Definition world.qh:104
float warmup_start_ammo_shells
Definition world.qh:102
float start_ammo_fuel
Definition world.qh:88
int start_items
Definition world.qh:83
WepSet start_weapons_default
Definition world.qh:81
int random_start_weapons_count
Number of random start weapons to give to players.
Definition world.qh:90
float warmup_start_ammo_nails
Definition world.qh:103
int autocvar_g_warmup_allguns
Definition world.qh:10
WepSet g_weaponarena_weapons
Definition world.qh:76
float start_ammo_cells
Definition world.qh:87
float g_weaponarena
Definition world.qh:75
float warmup_start_health
Definition world.qh:107
WepSet start_weapons_defaultmask
Definition world.qh:82
float start_ammo_rockets
Definition world.qh:86
WepSet warmup_start_weapons_default
Definition world.qh:99
float start_armorvalue
Definition world.qh:97
WepSet warmup_start_weapons_defaultmask
Definition world.qh:100
WepSet warmup_start_weapons
Definition world.qh:98
float warmup_start_ammo_fuel
Definition world.qh:106
string g_weaponarena_list
Definition world.qh:78
float start_health
Definition world.qh:96
float warmup_start_armorvalue
Definition world.qh:108
float start_ammo_nails
Definition world.qh:85

References argv(), autocvar_g_jetpack, autocvar_g_warmup_allguns, cvar(), cvar_string(), FOREACH, g_weapon_stay, g_weaponarena, g_weaponarena_list, g_weaponarena_weapons, GetResource(), InitializeEntity(), INITPRIO_FINDTARGET, IT_UNLIMITED_AMMO, IT_UNLIMITED_SUPERWEAPONS, M_ARGV, max(), MUTATOR_CALLHOOK, Weapon::netname, new_pure, NULL, random_start_ammo, random_start_weapons_count, SetResource(), start_ammo_cells, start_ammo_fuel, start_ammo_nails, start_ammo_rockets, start_ammo_shells, start_armorvalue, start_health, start_items, start_weapons, start_weapons_default, start_weapons_defaultmask, strcat(), strlen, strzone(), substring(), tokenize_console, want_weapon(), warmup_start_ammo_cells, warmup_start_ammo_fuel, warmup_start_ammo_nails, warmup_start_ammo_rockets, warmup_start_ammo_shells, warmup_start_armorvalue, warmup_start_health, warmup_start_weapons, warmup_start_weapons_default, warmup_start_weapons_defaultmask, Weapon_from_name(), weaponarena_available_all_update(), weaponarena_available_devall_update(), weaponarena_available_most_update(), Weapons, weapons_all(), weapons_devall(), and weapons_most().

Referenced by readlevelcvars().

◆ ReadyRestart()

void ReadyRestart ( bool forceWarmupEnd)

Definition at line 526 of file vote.qc.

527{
528 if (MUTATOR_CALLHOOK(ReadyRestart_Deny))
529 {
530 // NOTE: ReadyRestart support is mandatory in campaign
532 error("ReadyRestart must be supported in campaign mode!");
533 localcmd("restart\n"); // if ReadyRestart is denied, restart the server
534 }
535 else if (intermission_running || race_completing) // game is over, ReadyRestart no longer available
536 localcmd("restart\n");
537 else
538 localcmd("\nsv_hook_readyrestart\n");
539
540 if(forceWarmupEnd || autocvar_g_campaign)
541 warmup_stage = 0; // forcefully end warmup and go to match stage
542 else
543 warmup_stage = autocvar_g_warmup; // go into warmup if it's enabled, otherwise restart into match stage
544
545 ReadyRestart_force(false);
546}
void localcmd(string command,...)
#define error
Definition pre.qh:6
void ReadyRestart_force(bool is_fake_round_start)
Definition vote.qc:441
float race_completing
Definition race.qh:28

References autocvar_g_campaign, autocvar_g_warmup, error, intermission_running, localcmd(), MUTATOR_CALLHOOK, race_completing, ReadyRestart_force(), and warmup_stage.

Referenced by CheckRules_World(), GameCommand_allready(), GameCommand_resetmatch(), Join(), ReadyCount(), and StartFrame().

◆ RedirectionThink()

float RedirectionThink ( )

Definition at line 2556 of file world.qc.

2557{
2558 float clients_found;
2559
2560 if(redirection_target == "")
2561 return false;
2562
2564 {
2565 cvar_set("sv_public", "-2");
2566 redirection_timeout = time + 0.6; // this will only try twice... should be able to keep more clients
2567 if(redirection_target == "self")
2568 bprint("^3SERVER NOTICE:^7 restarting the server\n");
2569 else
2570 bprint("^3SERVER NOTICE:^7 redirecting everyone to ", redirection_target, "\n");
2571 }
2572
2574 return true;
2575
2577
2578 clients_found = 0;
2580 // TODO add timer
2581 LOG_INFO("Redirecting: sending connect command to ", it.netname);
2582 if(redirection_target == "self")
2583 stuffcmd(it, "\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " reconnect\n");
2584 else
2585 stuffcmd(it, strcat("\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " \"connect ", redirection_target, "\"\n"));
2586 ++clients_found;
2587 });
2588
2589 LOG_INFO("Redirecting: ", ftos(clients_found), " clients left.");
2590
2591 if(time > redirection_timeout || clients_found == 0)
2592 localcmd("\nwait; wait; wait; quit\n");
2593
2594 return true;
2595}
#define LOG_INFO(...)
Definition log.qh:65
void cvar_set(string name, string value)
#define stuffcmd(cl,...)
Definition progsdefs.qh:23
float redirection_nextthink
Definition world.qc:2555
float redirection_timeout
Definition world.qc:2554
float autocvar_quit_and_redirect_timer
Definition world.qh:14
string redirection_target
Definition world.qh:67

References autocvar_quit_and_redirect_timer, bprint(), cvar_set(), FOREACH_CLIENT, ftos(), IS_REAL_CLIENT, localcmd(), LOG_INFO, redirection_nextthink, redirection_target, redirection_timeout, strcat(), stuffcmd, and time.

Referenced by StartFrame().

◆ SetWinners()

void SetWinners ( .float field,
float value )

Definition at line 1535 of file world.qc.

1536{
1537 FOREACH_CLIENT(IS_PLAYER(it) || INGAME(it), { it.winning = (it.(field) == value); });
1538}
#define INGAME(it)
Definition sv_rules.qh:24

References FOREACH_CLIENT, INGAME, and IS_PLAYER.

Referenced by WinningCondition_Assault(), WinningCondition_Invasion(), and WinningCondition_Scores().

◆ STATIC_INIT()

STATIC_INIT ( g_moveables )

Definition at line 158 of file world.qh.

158{ g_moveables = IL_NEW(); }
#define IL_NEW()
IntrusiveList g_moveables
Definition world.qh:157

References g_moveables, and IL_NEW.

◆ void()

void ( entity this)

References entity().

◆ want_weapon()

int want_weapon ( entity weaponinfo,
int allguns )

Definition at line 1859 of file world.qc.

1860{
1861 int d = 0;
1862 bool allow_mutatorblocked = false;
1863
1864 if(!weaponinfo.m_id)
1865 return 0;
1866
1867 bool mutator_returnvalue = MUTATOR_CALLHOOK(WantWeapon, weaponinfo, d, allguns, allow_mutatorblocked);
1868 d = M_ARGV(1, float);
1869 allguns = M_ARGV(2, int);
1870 allow_mutatorblocked = M_ARGV(3, bool);
1871
1872 if(allguns == 1)
1873 d = boolean(!(weaponinfo.spawnflags & WEP_FLAG_HIDDEN));
1874 else if(allguns == 2)
1875 d = boolean((weaponinfo.spawnflags & WEP_FLAG_NORMAL) && !(weaponinfo.spawnflags & WEP_FLAG_HIDDEN));
1876 else if(!mutator_returnvalue)
1877 d = !(!weaponinfo.weaponstart);
1878
1879 if(!allow_mutatorblocked && (weaponinfo.spawnflags & WEP_FLAG_MUTATORBLOCKED)) // never default mutator blocked guns
1880 d = 0;
1881
1882 float t = weaponinfo.weaponstartoverride;
1883
1884 //LOG_INFOF("want_weapon: %s - d: %d t: %d\n", weaponinfo.netname, d, t);
1885
1886 // bit order in t:
1887 // 1: want or not
1888 // 2: is default?
1889 // 4: is set by default?
1890 if(t < 0)
1891 t = 4 | (3 * d);
1892 else
1893 t |= (2 * d);
1894
1895 return t;
1896}
#define boolean(value)
Definition bool.qh:9
const int WEP_FLAG_MUTATORBLOCKED
Definition weapon.qh:219
const int WEP_FLAG_HIDDEN
Definition weapon.qh:216
const int WEP_FLAG_NORMAL
Definition weapon.qh:215

References boolean, entity(), M_ARGV, MUTATOR_CALLHOOK, WEP_FLAG_HIDDEN, WEP_FLAG_MUTATORBLOCKED, and WEP_FLAG_NORMAL.

Referenced by readplayerstartcvars(), and weapons_start().

◆ WinningCondition_Scores()

float WinningCondition_Scores ( float limit,
float leadlimit )

Definition at line 1556 of file world.qc.

1557{
1558 // TODO make everything use THIS winning condition (except LMS)
1560
1561 if(teamplay)
1562 {
1563 for (int i = 1; i < 5; ++i)
1564 {
1567 }
1568 }
1569
1570 ClearWinners();
1575
1577 {
1580 limit = -limit;
1581 }
1582
1584 leadlimit = 0; // not supported in this mode
1585
1586 if(MUTATOR_CALLHOOK(Scores_CountFragsRemaining))
1587 {
1588 float fragsleft;
1590 {
1591 fragsleft = 1;
1592 }
1593 else
1594 {
1595 fragsleft = FLOAT_MAX;
1596 float leadingfragsleft = FLOAT_MAX;
1597 if (limit)
1598 fragsleft = limit - WinningConditionHelper_topscore;
1599 if (leadlimit)
1601
1602 if (limit && leadlimit && autocvar_leadlimit_and_fraglimit)
1603 fragsleft = max(fragsleft, leadingfragsleft);
1604 else
1605 fragsleft = min(fragsleft, leadingfragsleft);
1606 }
1607
1608 if (fragsleft_last != fragsleft) // do not announce same remaining frags multiple times
1609 {
1610 if (fragsleft == 1)
1611 Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_REMAINING_FRAG_1);
1612 else if (fragsleft == 2)
1613 Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_REMAINING_FRAG_2);
1614 else if (fragsleft == 3)
1615 Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_REMAINING_FRAG_3);
1616
1617 fragsleft_last = fragsleft;
1618 }
1619 }
1620
1621 bool fraglimit_reached = (limit && WinningConditionHelper_topscore >= limit);
1622 bool leadlimit_reached = (leadlimit && WinningConditionHelper_topscore - WinningConditionHelper_secondscore >= leadlimit);
1623
1624 bool limit_reached;
1625 // only respect leadlimit_and_fraglimit when both limits are set or the game will never end
1626 if (limit && leadlimit && autocvar_leadlimit_and_fraglimit)
1627 limit_reached = (fraglimit_reached && leadlimit_reached);
1628 else
1629 limit_reached = (fraglimit_reached || leadlimit_reached);
1630
1631 return GetWinningCode(
1632 WinningConditionHelper_topscore && limit_reached,
1634 );
1635}
const float FLOAT_MAX
Definition float.qh:3
float min(float f,...)
float TeamScore_GetCompareValue(float t)
Returns a value indicating the team score (and higher is better).
Definition scores.qc:806
void WinningConditionHelper(entity this)
Sets the following results for the current scores entities.
Definition scores.qc:443
float WinningConditionHelper_secondscore
second highest score
Definition scores.qh:108
entity WinningConditionHelper_winner
the winning player, or NULL if none
Definition scores.qh:112
float WinningConditionHelper_topscore
highest score
Definition scores.qh:107
float WinningConditionHelper_equality
we have no winner
Definition scores.qh:111
float WinningConditionHelper_lowerisbetter
lower is better, duh
Definition scores.qh:114
float WinningConditionHelper_zeroisworst
zero is worst, duh
Definition scores.qh:115
int autocvar_leadlimit_and_fraglimit
Definition sv_rules.qh:8
void Team_SetTeamScore(entity team_ent, float score)
Sets the score of the team.
Definition teamplay.qc:80
entity Team_GetTeamFromIndex(int index)
Returns the global team entity at the given index.
Definition teamplay.qc:57
int Team_IndexToTeam(int index)
Converts team index into team value.
Definition teams.qh:169
int fragsleft_last
Definition world.qc:1555
void SetWinners(.float field, float value)
Definition world.qc:1535
float GetWinningCode(float fraglimitreached, float equality)
Definition world.qc:1506

References autocvar_leadlimit_and_fraglimit, checkrules_suddendeathend, ClearWinners(), FLOAT_MAX, fragsleft_last, GetWinningCode(), max(), min(), MUTATOR_CALLHOOK, NULL, Send_Notification(), SetWinners(), team, Team_GetTeamFromIndex(), Team_IndexToTeam(), Team_SetTeamScore(), teamplay, TeamScore_GetCompareValue(), time, WinningConditionHelper(), WinningConditionHelper_equality, WinningConditionHelper_lowerisbetter, WinningConditionHelper_secondscore, WinningConditionHelper_topscore, WinningConditionHelper_winner, WinningConditionHelper_winnerteam, and WinningConditionHelper_zeroisworst.

Referenced by CheckRules_World(), WinningCondition_QualifyingThenRace(), and WinningCondition_Race().

Variable Documentation

◆ autocvar__endmatch

bool autocvar__endmatch

Definition at line 6 of file world.qh.

Referenced by CheckRules_World(), Pause_TryPause_Dedicated(), and SV_PausedTic().

◆ autocvar__sv_init

bool autocvar__sv_init

Definition at line 5 of file world.qh.

Referenced by GotoFirstMap().

◆ autocvar__sv_vote_gametype_custom

string autocvar__sv_vote_gametype_custom

Definition at line 51 of file world.qh.

Referenced by InitGameplayMode().

◆ autocvar_g_jetpack

bool autocvar_g_jetpack

Definition at line 8 of file world.qh.

Referenced by readplayerstartcvars(), and SendWelcomeMessage().

◆ autocvar_g_random_start_weapons

string autocvar_g_random_start_weapons

Holds a list of possible random start weapons.

Definition at line 92 of file world.qh.

Referenced by PutPlayerInServer().

◆ autocvar_g_use_ammunition

bool autocvar_g_use_ammunition

Definition at line 7 of file world.qh.

Referenced by GameLogInit().

◆ autocvar_g_warmup

int autocvar_g_warmup

Definition at line 9 of file world.qh.

Referenced by readlevelcvars(), ReadyCount(), ReadyRestart(), and SendWelcomeMessage().

◆ autocvar_g_warmup_allguns

int autocvar_g_warmup_allguns

Definition at line 10 of file world.qh.

Referenced by readplayerstartcvars().

◆ autocvar_g_warmup_allow_timeout

bool autocvar_g_warmup_allow_timeout

Definition at line 11 of file world.qh.

Referenced by CommonCommand_timeout().

◆ autocvar_quit_and_redirect

string autocvar_quit_and_redirect

Definition at line 13 of file world.qh.

Referenced by DoNextMapOverride().

◆ autocvar_quit_and_redirect_timer

float autocvar_quit_and_redirect_timer

Definition at line 14 of file world.qh.

Referenced by RedirectionThink().

◆ autocvar_quit_when_empty

bool autocvar_quit_when_empty

Definition at line 15 of file world.qh.

Referenced by DoNextMapOverride().

◆ autocvar_sessionid

string autocvar_sessionid

Definition at line 16 of file world.qh.

Referenced by RestoreGame(), Shutdown(), and spawnfunc().

◆ autocvar_sv_curl_serverpackages_auto

bool autocvar_sv_curl_serverpackages_auto

Definition at line 17 of file world.qh.

Referenced by spawnfunc().

◆ autocvar_sv_db_saveasdump

bool autocvar_sv_db_saveasdump

Definition at line 18 of file world.qh.

Referenced by Shutdown().

◆ autocvar_sv_dedicated

◆ autocvar_sv_logscores_bots

bool autocvar_sv_logscores_bots

Definition at line 19 of file world.qh.

Referenced by DumpStats().

◆ autocvar_sv_logscores_console

bool autocvar_sv_logscores_console

Definition at line 20 of file world.qh.

Referenced by DumpStats().

◆ autocvar_sv_logscores_file

bool autocvar_sv_logscores_file

Definition at line 21 of file world.qh.

Referenced by DumpStats().

◆ autocvar_sv_logscores_filename

string autocvar_sv_logscores_filename

Definition at line 22 of file world.qh.

Referenced by DumpStats().

◆ autocvar_sv_mapchange_delay

float autocvar_sv_mapchange_delay

Definition at line 23 of file world.qh.

Referenced by NextLevel().

◆ autocvar_sv_mapformat_is_quake2

bool autocvar_sv_mapformat_is_quake2

Definition at line 33 of file world.qh.

Referenced by DropToFloor_QC(), and Physics_UpdateStats().

◆ autocvar_sv_mapformat_is_quake3

bool autocvar_sv_mapformat_is_quake3

Definition at line 32 of file world.qh.

Referenced by DropToFloor_QC(), Physics_UpdateStats(), and PutPlayerInServer().

◆ autocvar_sv_termsofservice_url

string autocvar_sv_termsofservice_url

Definition at line 57 of file world.qh.

Referenced by spawnfunc().

◆ autocvar_timelimit_decrement

float autocvar_timelimit_decrement

Definition at line 25 of file world.qh.

Referenced by GameCommand_reducematchtime().

◆ autocvar_timelimit_increment

float autocvar_timelimit_increment

Definition at line 24 of file world.qh.

Referenced by GameCommand_extendmatchtime().

◆ autocvar_timelimit_max

float autocvar_timelimit_max

◆ autocvar_timelimit_min

float autocvar_timelimit_min

◆ autocvar_timelimit_overtime

float autocvar_timelimit_overtime

Definition at line 28 of file world.qh.

Referenced by InitiateOvertime(), InitiateSuddenDeath(), and ReadyRestart_force().

◆ autocvar_timelimit_overtimes

int autocvar_timelimit_overtimes

Definition at line 29 of file world.qh.

Referenced by InitiateSuddenDeath().

◆ autocvar_timelimit_suddendeath

float autocvar_timelimit_suddendeath

Definition at line 30 of file world.qh.

Referenced by InitiateSuddenDeath(), and Onslaught_CheckWinner().

◆ cache_lastmutatormsg

string cache_lastmutatormsg

Definition at line 70 of file world.qh.

Referenced by InitGameplayMode(), and SendWelcomeMessage().

◆ cache_mutatormsg

string cache_mutatormsg

Definition at line 69 of file world.qh.

Referenced by InitGameplayMode(), net_handle_ServerWelcome(), and SendWelcomeMessage().

◆ checkrules_equality

float checkrules_equality

Definition at line 35 of file world.qh.

Referenced by CampaignPreIntermission(), and WinningCondition_RanOutOfSpawns().

◆ checkrules_overtimesadded

int checkrules_overtimesadded

◆ checkrules_suddendeathend

float checkrules_suddendeathend

◆ checkrules_suddendeathwarning

float checkrules_suddendeathwarning

Definition at line 36 of file world.qh.

Referenced by CheckRules_World(), and ReadyRestart_force().

◆ clientstuff

string clientstuff

Definition at line 61 of file world.qh.

Referenced by ClientConnect(), InitGameplayMode(), and spawnfunc().

◆ cvar_changes

string cvar_changes

Definition at line 45 of file world.qh.

Referenced by COMMON_COMMAND(), CommonCommand_cvar_changes(), and cvar_changes_init().

◆ cvar_purechanges

string cvar_purechanges

◆ cvar_purechanges_count

float cvar_purechanges_count

◆ default_player_alpha

◆ default_weapon_alpha

◆ dropped_origin

◆ fog

string fog

Definition at line 65 of file world.qh.

◆ g_grappling_hook

float g_grappling_hook

Definition at line 113 of file world.qh.

Referenced by PRECACHE(), and REGISTER_MUTATOR().

◆ g_moveables

◆ g_weapon_stay

◆ g_weaponarena

◆ g_weaponarena_list

string g_weaponarena_list

Definition at line 78 of file world.qh.

Referenced by readplayerstartcvars(), and SendWelcomeMessage().

◆ g_weaponarena_random

float g_weaponarena_random

Definition at line 77 of file world.qh.

Referenced by MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ g_weaponarena_weapons

◆ gametype_custom_enabled

bool gametype_custom_enabled

◆ initialize_entity_first

entity initialize_entity_first

Definition at line 121 of file world.qh.

Referenced by InitializeEntitiesRun(), InitializeEntity(), and make_safe_for_remove().

◆ initialize_entity_next

entity initialize_entity_next

Definition at line 120 of file world.qh.

◆ initialize_entity_order

int initialize_entity_order

Definition at line 119 of file world.qh.

◆ loaded_gametype_custom_string

string loaded_gametype_custom_string

◆ matchid

◆ modname

◆ observe_blocked_if_eliminated

bool observe_blocked_if_eliminated = false

◆ random_start_ammo

entity random_start_ammo

Entity that contains amount of ammo to give with random start weapons.

Definition at line 95 of file world.qh.

Referenced by PutPlayerInServer(), and readplayerstartcvars().

◆ random_start_weapons_count

int random_start_weapons_count

Number of random start weapons to give to players.

Definition at line 90 of file world.qh.

Referenced by PutPlayerInServer(), and readplayerstartcvars().

◆ record_type

◆ redirection_target

string redirection_target

Definition at line 67 of file world.qh.

Referenced by DoNextMapOverride(), and RedirectionThink().

◆ ServerProgsDB

◆ start_ammo_cells

◆ start_ammo_fuel

◆ start_ammo_nails

◆ start_ammo_rockets

◆ start_ammo_shells

◆ start_armorvalue

◆ start_health

◆ start_items

◆ start_weapons

◆ start_weapons_default

WepSet start_weapons_default

Definition at line 81 of file world.qh.

Referenced by readplayerstartcvars().

◆ start_weapons_defaultmask

WepSet start_weapons_defaultmask

Definition at line 82 of file world.qh.

Referenced by MUTATOR_HOOKFUNCTION(), and readplayerstartcvars().

◆ sv_ready_restart_after_countdown

bool sv_ready_restart_after_countdown

◆ sv_termsofservice_url_escaped

string sv_termsofservice_url_escaped

Definition at line 59 of file world.qh.

Referenced by Shutdown(), spawnfunc(), and WinningConditionHelper().

◆ TemporaryDB

float TemporaryDB

◆ warmup_stage

int warmup_stage

Definition at line 114 of file world.qh.

◆ warmup_start_ammo_cells

◆ warmup_start_ammo_fuel

◆ warmup_start_ammo_nails

◆ warmup_start_ammo_rockets

◆ warmup_start_ammo_shells

◆ warmup_start_armorvalue

◆ warmup_start_health

◆ warmup_start_weapons

◆ warmup_start_weapons_default

WepSet warmup_start_weapons_default

Definition at line 99 of file world.qh.

Referenced by readplayerstartcvars().

◆ warmup_start_weapons_defaultmask

WepSet warmup_start_weapons_defaultmask

Definition at line 100 of file world.qh.

Referenced by MUTATOR_HOOKFUNCTION(), and readplayerstartcvars().

◆ winning

◆ WINNING_NEVER

const int WINNING_NEVER = 2

◆ WINNING_NO

◆ WINNING_STARTSUDDENDEATHOVERTIME

const int WINNING_STARTSUDDENDEATHOVERTIME = 3

◆ WINNING_YES

◆ world_initialized