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 (entity this)
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_random
int g_weaponarena_type
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 100 of file world.qh.

Referenced by GiveWarmupResources(), and MUTATOR_HOOKFUNCTION().

Function Documentation

◆ CheckRules_World()

void CheckRules_World ( )

Definition at line 1734 of file world.qc.

1735{
1736 VoteThink();
1737 MapVote_Think();
1738
1740
1741 if (intermission_running) // someone else quit the game already
1742 {
1743 if(player_count == 0) // Nobody there? Then let's go to the next map
1744 MapVote_Start();
1745 // this will actually check the player count in the next frame
1746 // again, but this shouldn't hurt
1747 return;
1748 }
1749
1750 float timelimit = autocvar_timelimit * 60;
1751 float fraglimit = autocvar_fraglimit;
1752 float leadlimit = autocvar_leadlimit;
1753 if (leadlimit < 0) leadlimit = 0;
1754
1755 if(warmup_stage || time <= game_starttime) // NOTE: this is <= to prevent problems in the very tic where the game starts
1756 {
1757 if(timelimit > 0)
1758 timelimit = 0; // timelimit is not made for warmup
1759 if(fraglimit > 0)
1760 fraglimit = 0; // no fraglimit for now
1761 leadlimit = 0; // no leadlimit for now
1762 }
1763
1764 if (autocvar__endmatch || timelimit < 0)
1765 {
1766 // endmatch
1767 NextLevel();
1768 return;
1769 }
1770
1771 if(timelimit > 0)
1772 timelimit += game_starttime;
1773
1774 int overtimes_prev = overtimes;
1775 int wantovertime = 0;
1776
1778 {
1780 {
1783 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_RACE_FINISHLAP);
1784 else
1785 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_OVERTIME_FRAG);
1786 }
1787 }
1788 else
1789 {
1790 if (timelimit && time >= timelimit)
1791 {
1792 if(g_race && (g_race_qualifying == 2) && timelimit > 0)
1793 {
1794 float totalplayers;
1795 float playerswithlaps;
1796 float readyplayers;
1797 totalplayers = playerswithlaps = readyplayers = 0;
1799 ++totalplayers;
1800 if(GameRules_scoring_add(it, RACE_FASTEST, 0))
1801 ++playerswithlaps;
1802 if(it.ready)
1803 ++readyplayers;
1804 });
1805
1806 // at least 2 of the players have completed a lap: start the RACE
1807 // otherwise, the players should end the qualifying on their own
1808 if(readyplayers || playerswithlaps >= 2)
1809 {
1811 ReadyRestart(true); // go to race
1812 return;
1813 }
1814 else
1815 wantovertime |= InitiateSuddenDeath();
1816 }
1817 else
1818 wantovertime |= InitiateSuddenDeath();
1819 }
1820 }
1821
1823 {
1824 NextLevel();
1825 return;
1826 }
1827
1828 int checkrules_status = WinningCondition_RanOutOfSpawns();
1829 if(checkrules_status == WINNING_YES)
1830 bprint("Hey! Someone ran out of spawns!\n");
1831 else if(MUTATOR_CALLHOOK(CheckRules_World, checkrules_status, timelimit, fraglimit))
1832 checkrules_status = M_ARGV(0, float);
1833 else
1834 checkrules_status = WinningCondition_Scores(fraglimit, leadlimit);
1835
1836 if(checkrules_status == WINNING_STARTSUDDENDEATHOVERTIME)
1837 {
1838 checkrules_status = WINNING_NEVER;
1840 wantovertime |= InitiateSuddenDeath();
1841 }
1842
1843 if(checkrules_status == WINNING_NEVER)
1844 // equality cases! Nobody wins if the overtime ends in a draw.
1845 ClearWinners();
1846
1847 if(wantovertime)
1848 {
1849 if(checkrules_status == WINNING_NEVER)
1851 else
1852 checkrules_status = WINNING_YES;
1853 }
1854
1856 if(checkrules_status != WINNING_NEVER || time >= checkrules_suddendeathend)
1857 checkrules_status = WINNING_YES;
1858
1859 if(checkrules_status == WINNING_YES)
1860 {
1861 if (overtimes == OVERTIME_SUDDENDEATH && overtimes != overtimes_prev)
1862 {
1863 // if suddendeathend overtime has just begun, revert it
1865 overtimes = overtimes_prev;
1866 }
1867 //print("WINNING\n");
1868 NextLevel();
1869 }
1870}
int player_count
Definition api.qh:103
#define MUTATOR_CALLHOOK(name,...)
Definition base.qh:186
#define M_ARGV(idx, type)
Definition base.qh:153
bool warmup_stage
Definition main.qh:120
#define g_race
Definition race.qh:48
#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:1500
#define NULL
Definition post.qh:14
void VoteThink()
Definition vote.qc:336
void ReadyRestart(bool forceWarmupEnd)
Definition vote.qc:532
int g_race_qualifying
Definition race.qh:11
void MapVote_Think()
void MapVote_Start()
#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:1508
int InitiateSuddenDeath()
Definition world.qc:1476
void SetDefaultAlpha()
Definition world.qc:105
void ClearWinners()
Definition world.qc:1563
void CheckRules_World()
Definition world.qc:1734
void NextLevel()
Definition world.qc:1413
float WinningCondition_Scores(float limit, float leadlimit)
Definition world.qc:1569
float WinningCondition_RanOutOfSpawns()
Definition world.qc:1650
const int WINNING_NEVER
Definition world.qh:133
float checkrules_suddendeathwarning
Definition world.qh:36
const int WINNING_STARTSUDDENDEATHOVERTIME
Definition world.qh:134
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:132

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()

void DropToFloor_QC ( entity this)

Definition at line 2272 of file world.qc.

2273{
2274 int nudgeresult;
2275
2276 if(!this || wasfreed(this))
2277 {
2278 LOG_WARN("DropToFloor_QC: can not modify free entity");
2279 return;
2280 }
2281
2282 /* Prior to sv_legacy_bbox_expand 0, both droptofloor and nudgeoutofsolid_OrFallback were done for items
2283 * using box '-16 -16 0' '16 16 48' (without the FL_ITEM expansion applied),
2284 * which often resulted in bboxes partially in solids once expansion was applied.
2285 * We don't want bboxes in solids (bad for gameplay and culling),
2286 * but we also don't want items to land on a "skirting board" or the base of a sloping wall.
2287 * For initial nudgeoutofsolid_OrFallback and droptofloor stages we use a small box
2288 * so they fall as far and in the same place as they traditionally would,
2289 * then we nudge the full size box out of solid, in a direction appropriate for the plane(s).
2290 */
2291 vector saved_mins = this.mins; // gmqcc's used-uninitialized check doesn't handle
2292 vector saved_maxs = this.maxs; // making these assignments FL_ITEM conditional.
2293 if (this.flags & FL_ITEM)
2294 {
2295 // Using the Q3 bbox for best compatibility with all maps, except...
2296 this.mins.x = -15;
2297 this.mins.y = -15;
2298 this.maxs.x = 15;
2299 this.maxs.y = 15;
2300 this.maxs.z = this.mins.z + 30; // ...Nex, Xon and Quake use a different vertical offset, see also: StartItem()
2301 }
2302
2303 /* NOTE: sv_gameplayfix_droptofloorstartsolid_nudgetocorrect isn't checked, so it won't need to be networked to CSQC.
2304 * It was enabled by default in all Xonotic releases and in Nexuiz, so now certain maps depend on it.
2305 * Example: on erbium 0.8.6 the shards @ crylink are too low (in collision with the floor),
2306 * so without this those fall through the floor.
2307 * Q3, Q2 and Quake don't try to move items out of solid.
2308 */
2309 if(!Q3COMPAT_COMMON && autocvar_sv_mapformat_is_quake3) // Xonotic, Nexuiz
2310 {
2311 nudgeresult = nudgeoutofsolid_OrFallback(this);
2312 if (!nudgeresult)
2313 LOG_WARNF("DropToFloor_QC at \"%v\": COULD NOT FIX badly placed entity \"%s\" before drop", this.origin, this.classname);
2314 else if (nudgeresult > 0)
2315 LOG_WARNF("DropToFloor_QC at \"%v\": FIXED badly placed entity \"%s\" before drop", this.origin, this.classname);
2316 }
2318 {
2319 if (this.flags & FL_ITEM)
2320 this.origin.z += 6;
2321 else
2322 this.origin.z += 1; // monsters 1, misc_explobox 2 but we don't support those currently
2323 }
2324
2325 vector end = this.origin;
2327 end.z -= 4096;
2329 end.z -= 128;
2330 else
2331 end.z -= 256; // Quake, QuakeWorld
2332 tracebox(this.origin, this.mins, this.maxs, end, MOVE_NOMONSTERS, this);
2333
2335 {
2338 {
2339 LOG_WARNF("DropToFloor_QC at \"%v\": \"%s\" fell out of the world", this.origin, this.classname);
2340 delete(this);
2341 return;
2342 }
2343 }
2344 else if (trace_allsolid || trace_fraction == 1) // Quake
2345 {
2346 // Quake just deletes badly placed items (and misc_explobox)...
2347 if (this.flags & FL_ITEM)
2348 {
2349 LOG_WARNF("DropToFloor_QC at \"%v\" (Quake compat): DELETING badly placed item \"%s\"", this.origin, this.classname);
2350 delete(this);
2351 return;
2352 }
2353 // ...not monsters though.
2354 LOG_WARNF("DropToFloor_QC at \"%v\" (Quake compat): badly placed entity \"%s\"", this.origin, this.classname);
2355 }
2356
2357 /* NOTE: sv_gameplayfix_droptofloorstartsolid (fallback from tracebox to traceline) isn't implemented.
2358 * It was disabled by default in all Xonotic releases and in Nexuiz.
2359 * Q3 doesn't support it (always uses its '-15 -15 -15' '15 15 15' box when dropping items), neither does Quake or Q2.
2360 */
2361
2362 if (!autocvar_sv_mapformat_is_quake2) // Quake, Q3, Nexuiz, Xonotic
2363 // allow to ride movers (or unset if in freefall)
2364 this.groundentity = trace_ent;
2365
2367 // if support is destroyed, keep suspended (gross hack for floating items in various maps)
2368 // bones_was_here: is this for Q1BSP only? Which maps use it? Do we need it at all? Intentions unclear in DP...
2369 this.move_suspendedinair = true;
2370
2371 if (trace_fraction)
2372 this.origin = trace_endpos;
2373
2374 if (this.flags & FL_ITEM)
2375 {
2376 this.mins = saved_mins;
2377 this.maxs = saved_maxs;
2378
2379 // A side effect of using a small box to drop items (and do the initial nudge) is
2380 // the full size box can end up in collision with a sloping floor or terrain model.
2381 nudgeresult = nudgeoutofsolid_OrFallback(this);
2382 // No warns for successful nudge because it would spam about items on slopes/terrain.
2383 }
2384 else if (trace_allsolid && trace_fraction) // dropped using "proper" bbox but never left solid
2385 {
2386 nudgeresult = nudgeoutofsolid_OrFallback(this);
2387 if (nudgeresult > 0)
2388 LOG_WARNF("DropToFloor_QC at \"%v\": FIXED badly placed entity \"%s\" after drop", this.origin, this.classname);
2389 }
2390 else
2391 nudgeresult = -1;
2392
2393 if (!nudgeresult)
2394 if (!Q3COMPAT_COMMON) // to be expected on Q3 maps like gu3-pewter because we use bigger final bboxes
2395 LOG_WARNF("DropToFloor_QC at \"%v\": COULD NOT FIX stuck entity \"%s\" after drop", this.origin, this.classname);
2396
2397 setorigin(this, this.dropped_origin = this.origin);
2398}
#define Q3COMPAT_COMMON
Definition stats.qh:370
const int FL_ITEM
Definition constants.qh:69
string classname
float Q3SURFACEFLAG_SKY
float flags
const float MOVE_NOMONSTERS
entity trace_ent
vector mins
vector trace_endpos
float trace_startsolid
vector maxs
float trace_dphitq3surfaceflags
vector origin
float trace_fraction
float trace_allsolid
#define LOG_WARNF(...)
Definition log.qh:59
#define LOG_WARN(...)
Definition log.qh:58
entity groundentity
Definition movetypes.qh:97
float move_suspendedinair
Definition movetypes.qh:98
vector
Definition self.qh:96
bool autocvar_sv_mapformat_is_quake3
Definition world.qh:32
vector dropped_origin
Definition world.qh:153
bool autocvar_sv_mapformat_is_quake2
Definition world.qh:33

References autocvar_sv_mapformat_is_quake2, autocvar_sv_mapformat_is_quake3, classname, dropped_origin, entity(), FL_ITEM, flags, groundentity, LOG_WARN, LOG_WARNF, maxs, mins, MOVE_NOMONSTERS, move_suspendedinair, origin, Q3COMPAT_COMMON, Q3SURFACEFLAG_SKY, trace_allsolid, trace_dphitq3surfaceflags, trace_endpos, trace_ent, trace_fraction, trace_startsolid, and vector.

Referenced by DropToFloor_QC_DelayedInit(), and StartItem().

◆ DropToFloor_QC_DelayedInit()

void DropToFloor_QC_DelayedInit ( entity this)

Definition at line 2400 of file world.qc.

2401{
2403}
const int INITPRIO_DROPTOFLOOR
Definition constants.qh:90
void InitializeEntity(entity e, void(entity this) func, int order)
Definition world.qc:2198
void DropToFloor_QC(entity this)
Definition world.qc:2272

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(), and turret_initialize().

◆ DumpStats()

void DumpStats ( float final)

Definition at line 1273 of file world.qc.

1274{
1275 float file;
1276 string s;
1277 float to_console;
1278 float to_eventlog;
1279 float to_file;
1280 float i;
1281
1282 to_console = autocvar_sv_logscores_console;
1283 to_eventlog = autocvar_sv_eventlog;
1285
1286 if(!final)
1287 {
1288 to_console = true; // always print printstats replies
1289 to_eventlog = false; // but never print them to the event log
1290 }
1291
1292 if(to_eventlog)
1294 to_console = false; // otherwise we get the output twice
1295
1296 if(final)
1297 s = ":scores:";
1298 else
1299 s = ":status:";
1300 s = strcat(s, GetGametype(), "_", GetMapname(), ":", ftos(rint(time)));
1301
1302 if(to_console)
1303 LOG_HELP(s);
1304 if(to_eventlog)
1305 GameLogEcho(s);
1306
1307 file = -1;
1308 if(to_file)
1309 {
1311 if(file == -1)
1312 to_file = false;
1313 else
1314 fputs(file, strcat(s, "\n"));
1315 }
1316
1317 s = strcat(":labels:player:", GetPlayerScoreString(NULL, 0));
1318 if(to_console)
1319 LOG_HELP(s);
1320 if(to_eventlog)
1321 GameLogEcho(s);
1322 if(to_file)
1323 fputs(file, strcat(s, "\n"));
1324
1326 s = strcat(":player:see-labels:", GetPlayerScoreString(it, 0), ":");
1327 s = strcat(s, ftos(rint(time - CS(it).jointime)), ":");
1328 if(IS_PLAYER(it) || INGAME_JOINED(it))
1329 s = strcat(s, ftos(it.team), ":");
1330 else
1331 s = strcat(s, "spectator:");
1332
1333 if(to_console)
1334 LOG_HELP(s, playername(it.netname, it.team, false));
1335 if(to_eventlog)
1336 GameLogEcho(strcat(s, ftos(it.playerid), ":", playername(it.netname, it.team, false)));
1337 if(to_file)
1338 fputs(file, strcat(s, playername(it.netname, it.team, false), "\n"));
1339 });
1340
1341 if(teamplay)
1342 {
1343 s = strcat(":labels:teamscores:", GetTeamScoreString(0, 0));
1344 if(to_console)
1345 LOG_HELP(s);
1346 if(to_eventlog)
1347 GameLogEcho(s);
1348 if(to_file)
1349 fputs(file, strcat(s, "\n"));
1350
1351 for(i = 1; i < 16; ++i)
1352 {
1353 s = strcat(":teamscores:see-labels:", GetTeamScoreString(i, 0));
1354 s = strcat(s, ":", ftos(i));
1355 if(to_console)
1356 LOG_HELP(s);
1357 if(to_eventlog)
1358 GameLogEcho(s);
1359 if(to_file)
1360 fputs(file, strcat(s, "\n"));
1361 }
1362 }
1363
1364 if(to_console)
1365 LOG_HELP(":end");
1366 if(to_eventlog)
1367 GameLogEcho(":end");
1368 if(to_file)
1369 {
1370 fputs(file, ":end\n");
1371 fclose(file);
1372 }
1373}
string playername(string thename, int teamid, bool team_colorize)
Definition util.qc:2180
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:83
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:671
string GetPlayerScoreString(entity pl, float shortString)
Returns score strings for eventlog etc.
Definition scores.qc:610
float jointime
Definition client.qh:65
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 2231 of file world.qc.

2232{
2233 entity startoflist = initialize_entity_first;
2236 for (entity e = startoflist; e; e = e.initialize_entity_next)
2237 {
2238 e.remove_except_protected_forbidden = 1;
2239 }
2240 for (entity e = startoflist; e; )
2241 {
2242 e.remove_except_protected_forbidden = 0;
2243 e.initialize_entity_order = 0;
2244 entity next = e.initialize_entity_next;
2245 e.initialize_entity_next = NULL;
2246 var void(entity this) func = e.initialize_entity;
2247 e.initialize_entity = func_null;
2248 if (e.classname == "initialize_entity")
2249 {
2250 entity wrappee = e.enemy;
2251 builtin_remove(e);
2252 e = wrappee;
2253 }
2254 //dprint("Delayed initialization: ", e.classname, "\n");
2255 if (func)
2256 {
2257 func(e);
2258 }
2259 else
2260 {
2261 eprint(e);
2262 backtrace(strcat("Null function in: ", e.classname, "\n"));
2263 }
2264 e = next;
2265 }
2267}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
next
Definition all.qh:75
#define backtrace(msg)
Definition log.qh:96
void eprint(entity e)
var void func_null()
void
Definition self.qh:76
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:120

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 2198 of file world.qc.

2199{
2200 entity prev, cur;
2201
2202 if (!e || e.initialize_entity)
2203 {
2204 // make a proxy initializer entity
2205 entity e_old = e;
2206 e = new(initialize_entity);
2207 e.enemy = e_old;
2208 }
2209
2210 e.initialize_entity = func;
2211 e.initialize_entity_order = order;
2212
2214 prev = NULL;
2215 for (;;)
2216 {
2217 if (!cur || cur.initialize_entity_order > order)
2218 {
2219 // insert between prev and cur
2220 if (prev)
2221 prev.initialize_entity_next = e;
2222 else
2224 e.initialize_entity_next = cur;
2225 return;
2226 }
2227 prev = cur;
2228 cur = cur.initialize_entity_next;
2229 }
2230}
prev
Definition all.qh:53

Referenced by DropToFloor_QC_DelayedInit(), InitGameplayMode(), and readplayerstartcvars().

◆ MatchEnd_RestoreSpectatorAndTeamStatus()

void MatchEnd_RestoreSpectatorAndTeamStatus ( .int prev_team_field)

Definition at line 1379 of file world.qc.

1380{
1381 bool fix_team = (teamplay && prev_team_field != team);
1382 FOREACH_CLIENT(true,
1383 {
1384 if (!IS_PLAYER(it) && INGAME_JOINING(it))
1385 {
1387 PutObserverInServer(it, true, false);
1388 bprint(playername(it.netname, it.team, false), " has been moved back to spectator\n");
1389 it.winning = false;
1390 }
1391 else if (fix_team && INGAME_JOINED(it) && it.(prev_team_field) && it.team != it.(prev_team_field))
1392 {
1394 if (MoveToTeam(it, Team_TeamToIndex(it.(prev_team_field)), 6))
1395 {
1396 string pl_name = playername(it.netname, it.team, false);
1397 bprint(pl_name, " has been moved back to the ", Team_ColoredFullName(it.team), "\n");
1398 }
1399 it.winning = (it.team == WinningConditionHelper_winnerteam);
1400 }
1401 });
1402}
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:345
bool MoveToTeam(entity client, int team_index, int type)
Moves player to the specified team.
Definition teamplay.qc:331
@ TEAM_FORCE_DEFAULT
Don't force any team.
Definition teamplay.qh:154
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 1404 of file world.qc.

1405{
1407}
void MatchEnd_RestoreSpectatorAndTeamStatus(.int prev_team_field)
Definition world.qc:1379

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 1126 of file world.qc.

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

1261{
1262 return MoveToRandomLocationWithinBounds(e, world.mins, world.maxs, goodcontents, badcontents, badsurfaceflags, attempts, maxaboveground, minviewdistance, false);
1263}
#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:1126

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

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

◆ readlevelcvars()

void readlevelcvars ( )

Definition at line 2154 of file world.qc.

2155{
2157 if(cvar("sv_allow_fullbright"))
2159
2161 if(cvar("sv_forbid_pickuptimer"))
2163
2164 sv_ready_restart_after_countdown = cvar("sv_ready_restart_after_countdown");
2165
2166 if(cvar("g_campaign"))
2167 warmup_stage = 0; // no warmup during campaign
2168 else
2169 {
2172 warmup_limit = -1; // don't start until there's enough players
2173 else if (warmup_stage == 1)
2174 {
2175 // this code is duplicated in ReadyCount()
2176 warmup_limit = cvar("g_warmup_limit");
2177 if(warmup_limit == 0)
2179 }
2180 }
2181
2182 g_weapon_stay = cvar(strcat("g_", GetGametype(), "_weapon_stay"));
2183 if (!g_weapon_stay)
2184 g_weapon_stay = cvar("g_weapon_stay");
2185 MUTATOR_CALLHOOK(SetWeaponStay, g_weapon_stay);
2186 g_weapon_stay = M_ARGV(0, int);
2187
2188 MUTATOR_CALLHOOK(ReadLevelCvars);
2189
2191 game_starttime = time + cvar("g_start_delay");
2192
2193 FOREACH(Weapons, it != WEP_Null, { it.wr_init(it); });
2194
2196}
int serverflags
Definition main.qh:211
float warmup_limit
Definition stats.qh:377
const int SERVERFLAG_FORBID_PICKUPTIMER
Definition constants.qh:21
const int SERVERFLAG_ALLOW_FULLBRIGHT
Definition constants.qh:17
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:1970
float g_weapon_stay
Definition world.qh:108
int autocvar_g_warmup
Definition world.qh:9
bool sv_ready_restart_after_countdown
Definition world.qh:115

References autocvar_g_campaign, autocvar_g_warmup, autocvar_timelimit, cvar(), FOREACH, g_weapon_stay, game_starttime, GetGametype(), M_ARGV, 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 1970 of file world.qc.

1971{
1972 // initialize starting values for players
1973 start_weapons = '0 0 0';
1974 start_weapons_default = '0 0 0';
1975 start_weapons_defaultmask = '0 0 0';
1976 start_items = 0;
1978 start_ammo_nails = 0;
1980 start_ammo_cells = 0;
1981 if (random_start_ammo == NULL)
1983 start_health = cvar("g_balance_health_start");
1984 start_armorvalue = cvar("g_balance_armor_start");
1985
1986 string s = cvar_string("g_weaponarena");
1987 MUTATOR_CALLHOOK(SetWeaponArena, s);
1988 s = M_ARGV(0, string);
1989 switch (s)
1990 {
1991 case "0": case "": case "off":
1993 g_weaponarena_weapons = '0 0 0';
1994 break;
1995 case "all": case "1":
1998 break;
1999 case "devall":
2002 break;
2003 case "standard": case "most":
2006 break;
2007 case "extended":
2010 break;
2011 case "extended_available":
2014 // this needs to run after weaponsInMapAll is initialized
2016 break;
2017 case "all_available":
2020 // this needs to run after weaponsInMapAll is initialized
2022 break;
2023 case "devall_available":
2026 // this needs to run after weaponsInMapAll is initialized
2028 break;
2029 case "standard_available": case "most_available":
2032 // this needs to run after weaponsInMapAll is initialized
2034 break;
2035 case "none":
2037 g_weaponarena_weapons = '0 0 0';
2038 break;
2039 default:
2040 {
2041 g_weaponarena_weapons = '0 0 0';
2042 Weapon wep;
2043 int t = tokenize_console(s);
2044 for (int j = 0; j < t; ++j)
2045 {
2046 wep = Weapon_from_name(argv(j));
2047 if (wep != WEP_Null)
2048 g_weaponarena_weapons |= wep.m_wepset;
2049 }
2051 }
2052 }
2053
2055 {
2056 g_weapon_stay = 0; // incompatible
2059 }
2060 else
2061 FOREACH(Weapons, it != WEP_Null,
2062 {
2063 int w = want_weapon(it, false);
2064 WepSet set = it.m_wepset;
2065 if (w & 1)
2066 start_weapons |= set;
2067 if (w & 2)
2068 start_weapons_default |= set;
2069 if (w & 4)
2071 });
2072
2073 if (cvar("g_balance_superweapons_time") < 0)
2075 if (!cvar("g_use_ammunition"))
2077
2078 start_ammo_shells = cvar("g_start_ammo_shells");
2079 start_ammo_nails = cvar("g_start_ammo_nails");
2080 start_ammo_rockets = cvar("g_start_ammo_rockets");
2081 start_ammo_cells = cvar("g_start_ammo_cells");
2082 start_ammo_fuel = cvar("g_start_ammo_fuel");
2083 random_start_weapons_count = cvar("g_random_start_weapons_count");
2084 SetResource(random_start_ammo, RES_SHELLS, cvar("g_random_start_shells"));
2085 SetResource(random_start_ammo, RES_BULLETS, cvar("g_random_start_bullets"));
2086 SetResource(random_start_ammo, RES_ROCKETS, cvar("g_random_start_rockets"));
2087 SetResource(random_start_ammo, RES_CELLS, cvar("g_random_start_cells"));
2088
2099
2101 {
2102 warmup_start_ammo_shells = cvar("g_warmup_start_ammo_shells");
2103 warmup_start_ammo_nails = cvar("g_warmup_start_ammo_nails");
2104 warmup_start_ammo_rockets = cvar("g_warmup_start_ammo_rockets");
2105 warmup_start_ammo_cells = cvar("g_warmup_start_ammo_cells");
2106 warmup_start_ammo_fuel = cvar("g_warmup_start_ammo_fuel");
2107 warmup_start_health = cvar("g_warmup_start_health");
2108 warmup_start_armorvalue = cvar("g_warmup_start_armor");
2109 warmup_start_weapons = '0 0 0';
2112 FOREACH(Weapons, it != WEP_Null,
2113 {
2115 WepSet set = it.m_wepset;
2116 if (w & 1)
2117 warmup_start_weapons |= set;
2118 if (w & 2)
2120 if (w & 4)
2122 });
2123 }
2124
2126 start_items |= ITEM_Jetpack.m_itemid;
2127
2128 MUTATOR_CALLHOOK(SetStartItems);
2129
2130 if (start_items & ITEM_Jetpack.m_itemid)
2131 {
2132 start_items |= ITEM_FuelRegen.m_itemid;
2133 start_ammo_fuel = max(start_ammo_fuel, cvar("g_balance_fuel_rotstable"));
2134 warmup_start_ammo_fuel = max(warmup_start_ammo_fuel, cvar("g_balance_fuel_rotstable"));
2135 }
2136
2142 SetResource(random_start_ammo, RES_SHELLS, max(0, GetResource(random_start_ammo, RES_SHELLS)));
2143 SetResource(random_start_ammo, RES_BULLETS, max(0, GetResource(random_start_ammo, RES_BULLETS)));
2144 SetResource(random_start_ammo, RES_ROCKETS, max(0, GetResource(random_start_ammo, RES_ROCKETS)));
2145 SetResource(random_start_ammo, RES_CELLS, max(0, GetResource(random_start_ammo, RES_CELLS)));
2146
2152}
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:36
const int IT_UNLIMITED_AMMO
Definition item.qh:23
const int IT_UNLIMITED_SUPERWEAPONS
Definition item.qh:24
const int INITPRIO_SETLOCATION
Definition constants.qh:91
#define tokenize_console
const string cvar_string(string name)
string argv(float n)
float max(float f,...)
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:66
Weapon Weapon_from_name(string s)
Definition all.qh:145
@ WEPARENA_ALL
Definition weapon.qh:275
@ WEPARENA_ALL_AVAILABLE
Definition weapon.qh:276
@ WEPARENA_NONE
Definition weapon.qh:273
@ WEPARENA_EXTENDED_AVAILABLE
Definition weapon.qh:280
@ WEPARENA_STANDARD_AVAILABLE
Definition weapon.qh:278
@ WEPARENA_EXTENDED
Definition weapon.qh:279
@ WEPARENA_DEVALL
Definition weapon.qh:281
@ WEPARENA_STANDARD
Definition weapon.qh:277
@ WEPARENA_DEVALL_AVAILABLE
Definition weapon.qh:282
@ WEPARENA_OFF
Definition weapon.qh:272
@ WEPARENA_CUSTOM
Definition weapon.qh:274
vector WepSet
Definition weapon.qh:13
int want_weapon(entity weaponinfo, int allguns)
Definition world.qc:1872
WepSet weapons_standard()
Definition world.qc:1941
WepSet weapons_all()
Definition world.qc:1923
void weaponarena_available_update(entity this)
Definition world.qc:1963
WepSet weapons_extended()
Definition world.qc:1952
WepSet weapons_devall()
Definition world.qc:1934
WepSet start_weapons
Definition world.qh:79
float warmup_start_ammo_cells
Definition world.qh:104
entity random_start_ammo
Entity that contains amount of ammo to give with random start weapons.
Definition world.qh:94
bool autocvar_g_jetpack
Definition world.qh:8
float start_ammo_shells
Definition world.qh:83
float warmup_start_ammo_rockets
Definition world.qh:103
float warmup_start_ammo_shells
Definition world.qh:101
float start_ammo_fuel
Definition world.qh:87
int start_items
Definition world.qh:82
WepSet start_weapons_default
Definition world.qh:80
int random_start_weapons_count
Number of random start weapons to give to players.
Definition world.qh:89
float warmup_start_ammo_nails
Definition world.qh:102
int autocvar_g_warmup_allguns
Definition world.qh:10
WepSet g_weaponarena_weapons
Definition world.qh:75
float start_ammo_cells
Definition world.qh:86
float warmup_start_health
Definition world.qh:106
WepSet start_weapons_defaultmask
Definition world.qh:81
float start_ammo_rockets
Definition world.qh:85
WepSet warmup_start_weapons_default
Definition world.qh:98
int g_weaponarena_type
Definition world.qh:77
float start_armorvalue
Definition world.qh:96
WepSet warmup_start_weapons_defaultmask
Definition world.qh:99
WepSet warmup_start_weapons
Definition world.qh:97
float warmup_start_ammo_fuel
Definition world.qh:105
float start_health
Definition world.qh:95
float warmup_start_armorvalue
Definition world.qh:107
float start_ammo_nails
Definition world.qh:84

References argv(), autocvar_g_jetpack, autocvar_g_warmup_allguns, cvar(), cvar_string(), FOREACH, g_weapon_stay, g_weaponarena_type, g_weaponarena_weapons, GetResource(), InitializeEntity(), INITPRIO_SETLOCATION, IT_UNLIMITED_AMMO, IT_UNLIMITED_SUPERWEAPONS, M_ARGV, max(), MUTATOR_CALLHOOK, 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, 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_update(), Weapons, weapons_all(), weapons_devall(), weapons_extended(), weapons_standard(), WEPARENA_ALL, WEPARENA_ALL_AVAILABLE, WEPARENA_CUSTOM, WEPARENA_DEVALL, WEPARENA_DEVALL_AVAILABLE, WEPARENA_EXTENDED, WEPARENA_EXTENDED_AVAILABLE, WEPARENA_NONE, WEPARENA_OFF, WEPARENA_STANDARD, and WEPARENA_STANDARD_AVAILABLE.

Referenced by readlevelcvars().

◆ ReadyRestart()

void ReadyRestart ( bool forceWarmupEnd)

Definition at line 532 of file vote.qc.

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

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 2533 of file world.qc.

2534{
2535 float clients_found;
2536
2537 if(redirection_target == "")
2538 return false;
2539
2541 {
2542 cvar_set("sv_public", "-2");
2543 redirection_timeout = time + 0.6; // this will only try twice... should be able to keep more clients
2544 if(redirection_target == "self")
2545 bprint("^3SERVER NOTICE:^7 restarting the server\n");
2546 else
2547 bprint("^3SERVER NOTICE:^7 redirecting everyone to ", redirection_target, "\n");
2548 }
2549
2551 return true;
2552
2554
2555 clients_found = 0;
2557 // TODO add timer
2558 LOG_INFO("Redirecting: sending connect command to ", it.netname);
2559 if(redirection_target == "self")
2560 stuffcmd(it, "\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " reconnect\n");
2561 else
2562 stuffcmd(it, strcat("\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " \"connect ", redirection_target, "\"\n"));
2563 ++clients_found;
2564 });
2565
2566 LOG_INFO("Redirecting: ", ftos(clients_found), " clients left.");
2567
2568 if(time > redirection_timeout || clients_found == 0)
2569 localcmd("\nwait; wait; wait; quit\n");
2570
2571 return true;
2572}
#define LOG_INFO(...)
Definition log.qh:62
void cvar_set(string name, string value)
#define stuffcmd(cl,...)
Definition progsdefs.qh:23
float redirection_nextthink
Definition world.qc:2532
float redirection_timeout
Definition world.qc:2531
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 1548 of file world.qc.

1549{
1550 FOREACH_CLIENT(IS_PLAYER(it) || INGAME(it), { it.winning = (it.(field) == value); });
1551}
#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 1872 of file world.qc.

1873{
1874 int d = 0;
1875 bool allow_mutatorblocked = false;
1876
1877 if(!weaponinfo.m_id)
1878 return 0;
1879
1880 bool mutator_returnvalue = MUTATOR_CALLHOOK(WantWeapon, weaponinfo, d, allguns, allow_mutatorblocked);
1881 d = M_ARGV(1, float);
1882 allguns = M_ARGV(2, int);
1883 allow_mutatorblocked = M_ARGV(3, bool);
1884
1885 if(allguns == 1)
1886 d = boolean(!(weaponinfo.spawnflags & WEP_FLAG_HIDDEN));
1887 else if(allguns == 2)
1888 d = boolean((weaponinfo.spawnflags & WEP_FLAG_NORMAL) && !(weaponinfo.spawnflags & WEP_FLAG_HIDDEN));
1889 else if(!mutator_returnvalue)
1890 d = !(!weaponinfo.weaponstart);
1891
1892 if(!allow_mutatorblocked && (weaponinfo.spawnflags & WEP_FLAG_MUTATORBLOCKED)) // never default mutator blocked guns
1893 d = 0;
1894
1895 float t = weaponinfo.weaponstartoverride;
1896
1897 //LOG_INFOF("want_weapon: %s - d: %d t: %d\n", weaponinfo.netname, d, t);
1898
1899 // bit order in t:
1900 // 1: want or not
1901 // 2: is default?
1902 // 4: is set by default?
1903 if(t < 0)
1904 t = 4 | (3 * d);
1905 else
1906 t |= (2 * d);
1907
1908 return t;
1909}
#define boolean(value)
Definition bool.qh:9
const int WEP_FLAG_MUTATORBLOCKED
hides from impulse 99 etc. (mutators are allowed to clear this flag)
Definition weapon.qh:255
const int WEP_FLAG_HIDDEN
hides from menu
Definition weapon.qh:252
const int WEP_FLAG_NORMAL
in "standard weapons" set
Definition weapon.qh:251

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 1569 of file world.qc.

1570{
1571 // TODO make everything use THIS winning condition (except LMS)
1573
1574 if(teamplay)
1575 {
1576 for (int i = 1; i <= AVAILABLE_TEAMS; ++i)
1577 {
1580 }
1581 }
1582
1583 ClearWinners();
1588
1590 {
1593 limit = -limit;
1594 }
1595
1597 leadlimit = 0; // not supported in this mode
1598
1599 if(MUTATOR_CALLHOOK(Scores_CountFragsRemaining))
1600 {
1601 float fragsleft;
1603 {
1604 fragsleft = 1;
1605 }
1606 else
1607 {
1608 fragsleft = FLOAT_MAX;
1609 float leadingfragsleft = FLOAT_MAX;
1610 if (limit)
1611 fragsleft = limit - WinningConditionHelper_topscore;
1612 if (leadlimit)
1614
1615 if (limit && leadlimit && autocvar_leadlimit_and_fraglimit)
1616 fragsleft = max(fragsleft, leadingfragsleft);
1617 else
1618 fragsleft = min(fragsleft, leadingfragsleft);
1619 }
1620
1621 if (fragsleft_last != fragsleft) // do not announce same remaining frags multiple times
1622 {
1623 if (fragsleft == 1)
1624 Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_REMAINING_FRAG_1);
1625 else if (fragsleft == 2)
1626 Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_REMAINING_FRAG_2);
1627 else if (fragsleft == 3)
1628 Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_REMAINING_FRAG_3);
1629
1630 fragsleft_last = fragsleft;
1631 }
1632 }
1633
1634 bool fraglimit_reached = (limit && WinningConditionHelper_topscore >= limit);
1635 bool leadlimit_reached = (leadlimit && WinningConditionHelper_topscore - WinningConditionHelper_secondscore >= leadlimit);
1636
1637 bool limit_reached;
1638 // only respect leadlimit_and_fraglimit when both limits are set or the game will never end
1639 if (limit && leadlimit && autocvar_leadlimit_and_fraglimit)
1640 limit_reached = (fraglimit_reached && leadlimit_reached);
1641 else
1642 limit_reached = (fraglimit_reached || leadlimit_reached);
1643
1644 return GetWinningCode(
1645 WinningConditionHelper_topscore && limit_reached,
1647 );
1648}
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:803
void WinningConditionHelper(entity this)
Sets the following results for the current scores entities.
Definition scores.qc:440
#define AVAILABLE_TEAMS
Number of teams that exist currently.
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
bool 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:109
entity Team_GetTeamFromIndex(int index)
Returns the global team entity at the given index.
Definition teamplay.qc:86
int Team_IndexToTeam(int index)
Converts team index into team value.
Definition teams.qh:169
int fragsleft_last
Definition world.qc:1568
void SetWinners(.float field, float value)
Definition world.qc:1548
float GetWinningCode(float fraglimitreached, float equality)
Definition world.qc:1519

References autocvar_leadlimit_and_fraglimit, AVAILABLE_TEAMS, 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 91 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

◆ default_player_alpha

◆ default_weapon_alpha

◆ dropped_origin

◆ fog

string fog

Definition at line 65 of file world.qh.

Referenced by Fog_Set().

◆ g_grappling_hook

float g_grappling_hook

Definition at line 112 of file world.qh.

Referenced by PRECACHE(), and REGISTER_MUTATOR().

◆ g_moveables

◆ g_weapon_stay

◆ g_weaponarena_random

float g_weaponarena_random

Definition at line 76 of file world.qh.

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

◆ g_weaponarena_type

◆ g_weaponarena_weapons

◆ gametype_custom_enabled

bool gametype_custom_enabled

◆ initialize_entity_first

entity initialize_entity_first

Definition at line 120 of file world.qh.

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

◆ initialize_entity_next

entity initialize_entity_next

Definition at line 119 of file world.qh.

◆ initialize_entity_order

int initialize_entity_order

Definition at line 118 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 94 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 89 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 80 of file world.qh.

Referenced by readplayerstartcvars().

◆ start_weapons_defaultmask

WepSet start_weapons_defaultmask

Definition at line 81 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 113 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 98 of file world.qh.

Referenced by readplayerstartcvars().

◆ warmup_start_weapons_defaultmask

WepSet warmup_start_weapons_defaultmask

Definition at line 99 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