/*QUAKED worldspawn (0 0 0) ? The worldspawn entity defines global conditions and behavior for the entire level. All brushes not belonging to an explicit entity implicitly belong to worldspawn. -------- KEYS -------- message : The map title. sky : The sky environment map (default unit1_). ambient_light : The ambient light level (e.g. 0.14 0.11 0.12). sun_light : Sun light intensity, a single scalar value 0 - 255. sun_color : Sun light color (e.g. 0.8 0.4 0.7). sun_angles : Sun light angles as "pitch yaw roll" (e.g. 85 225 0). brightness : Global light scale, a single positive scalar value (e.g. 1.125). saturation : Global light saturation, a single positive scalar value (e.g. 0.9). contrast : Global light contrast, a single positive scalar value (e.g. 1.17). patch_size : Surface light patch size (default 64). weather : Weather effects, one of "none, rain, snow" followed optionally by "fog r g b." gravity : Gravity for the level (default 800). gameplay : The gameplay mode, one of "deathmatch, instagib, arena." hook : Enables the grappling hook (unset for gameplay default, 0 = disabled, 1 = enabled)." teams : Enables and enforces teams play (enabled = 1, auto-balance = 2). num_teams : Enforces number of teams (disabled = -1, must be between 2 and 4) ctf : Enables CTF play (enabled = 1, auto-balance = 2). match : Enables match play (round-based elimination with warmup) (enabled = 1). fraglimit : The frag limit (default 20). roundlimit : The round limit (default 20). capturelimit : The capture limit (default 8). timelimit : The time limit in minutes (default 20). give : A comma-delimited item string to give each player on spawn. */ static void G_worldspawn(g_entity_t *ent) { ent->solid = SOLID_BSP; ent->locals.move_type = MOVE_TYPE_NONE; ent->in_use = true; // since the world doesn't use G_Spawn() ent->s.model1 = 0; // world model is always index 1 const g_map_list_map_t *map = G_MapList_Find(NULL, g_level.name); if (ent->locals.message && *ent->locals.message) { g_strlcpy(g_level.title, ent->locals.message, sizeof(g_level.title)); } else // or just the level name { g_strlcpy(g_level.title, g_level.name, sizeof(g_level.title)); } gi.SetConfigString(CS_NAME, g_level.title); if (map && *map->sky) { // prefer maps.lst sky gi.SetConfigString(CS_SKY, map->sky); } else { // or fall back on worldspawn if (g_game.spawn.sky && *g_game.spawn.sky) { gi.SetConfigString(CS_SKY, g_game.spawn.sky); } else // or default to unit1_ { gi.SetConfigString(CS_SKY, "unit1_"); } } if (map && *map->weather) { // prefer maps.lst weather gi.SetConfigString(CS_WEATHER, map->weather); } else { // or fall back on worldspawn if (g_game.spawn.weather && *g_game.spawn.weather) { gi.SetConfigString(CS_WEATHER, g_game.spawn.weather); } else // or default to none { gi.SetConfigString(CS_WEATHER, "none"); } } if (map && map->gravity > 0) { // prefer maps.lst gravity g_level.gravity = map->gravity; } else { // or fall back on worldspawn if (g_game.spawn.gravity && *g_game.spawn.gravity) { g_level.gravity = atoi(g_game.spawn.gravity); } else { g_level.gravity = DEFAULT_GRAVITY; } } if (g_strcmp0(g_gameplay->string, "default")) { // perfer g_gameplay g_level.gameplay = G_GameplayByName(g_gameplay->string); } else if (map && map->gameplay > -1) { // then maps.lst gameplay g_level.gameplay = map->gameplay; } else { // or fall back on worldspawn if (g_game.spawn.gameplay && *g_game.spawn.gameplay) { g_level.gameplay = G_GameplayByName(g_game.spawn.gameplay); } else { g_level.gameplay = GAME_DEATHMATCH; } } gi.SetConfigString(CS_GAMEPLAY, va("%d", g_level.gameplay)); if (map && map->teams > -1) { // prefer maps.lst teams g_level.teams = map->teams; } else { // or fall back on worldspawn if (g_game.spawn.teams && *g_game.spawn.teams) { g_level.teams = atoi(g_game.spawn.teams); } else { g_level.teams = g_teams->integer; } } if (map && map->num_teams > -1) { // prefer maps.lst teams g_level.num_teams = map->num_teams; } else { // or fall back on worldspawn if (g_game.spawn.num_teams && *g_game.spawn.num_teams) { g_level.num_teams = atoi(g_game.spawn.num_teams); } else { if (g_strcmp0(g_num_teams->string, "default")) { g_level.num_teams = g_num_teams->integer; } else { g_level.num_teams = -1; // spawn point function will do this } } } if (g_level.num_teams != -1) { g_level.num_teams = Clamp(g_level.num_teams, 2, MAX_TEAMS); } if (map && map->ctf > -1) { // prefer maps.lst ctf g_level.ctf = map->ctf; } else { // or fall back on worldspawn if (g_game.spawn.ctf && *g_game.spawn.ctf) { g_level.ctf = atoi(g_game.spawn.ctf); } else { g_level.ctf = g_ctf->integer; } } if (map && map->hook > -1) { g_level.hook_map = map->hook; } else { g_level.hook_map = -1; } if (map && map->techs > -1) { g_level.techs_map = map->techs; } else { g_level.techs_map = -1; } if (g_level.teams && g_level.ctf) { // ctf overrides teams g_level.teams = 0; } gi.SetConfigString(CS_CTF, va("%d", g_level.ctf)); gi.SetConfigString(CS_HOOK_PULL_SPEED, g_hook_pull_speed->string); if (map && map->match > -1) { // prefer maps.lst match g_level.match = map->match; } else { // or fall back on worldspawn if (g_game.spawn.match && *g_game.spawn.match) { g_level.match = atoi(g_game.spawn.match); } else { g_level.match = g_match->integer; } } if (map && map->rounds > -1) { // prefer maps.lst rounds g_level.rounds = map->rounds; } else { // or fall back on worldspawn if (g_game.spawn.rounds && *g_game.spawn.rounds) { g_level.rounds = atoi(g_game.spawn.rounds); } else { g_level.rounds = g_rounds->integer; } } if (g_level.match && g_level.rounds) { // rounds overrides match g_level.match = 0; } gi.SetConfigString(CS_MATCH, va("%d", g_level.match)); gi.SetConfigString(CS_ROUNDS, va("%d", g_level.rounds)); if (map && map->frag_limit > -1) { // prefer maps.lst frag_limit g_level.frag_limit = map->frag_limit; } else { // or fall back on worldspawn if (g_game.spawn.frag_limit && *g_game.spawn.frag_limit) { g_level.frag_limit = atoi(g_game.spawn.frag_limit); } else { g_level.frag_limit = g_frag_limit->integer; } } if (map && map->round_limit > -1) { // prefer maps.lst round_limit g_level.round_limit = map->round_limit; } else { // or fall back on worldspawn if (g_game.spawn.round_limit && *g_game.spawn.round_limit) { g_level.round_limit = atoi(g_game.spawn.round_limit); } else { g_level.round_limit = g_round_limit->integer; } } if (map && map->capture_limit > -1) { // prefer maps.lst capture_limit g_level.capture_limit = map->capture_limit; } else { // or fall back on worldspawn if (g_game.spawn.capture_limit && *g_game.spawn.capture_limit) { g_level.capture_limit = atoi(g_game.spawn.capture_limit); } else { g_level.capture_limit = g_capture_limit->integer; } } vec_t time_limit; if (map && map->time_limit > -1) { // prefer maps.lst time_limit time_limit = map->time_limit; } else { // or fall back on worldspawn if (g_game.spawn.time_limit && *g_game.spawn.time_limit) { time_limit = atof(g_game.spawn.time_limit); } else { time_limit = g_time_limit->value; } } g_level.time_limit = time_limit * 60 * 1000; if (map && *map->give) { // prefer maps.lst give g_strlcpy(g_level.give, map->give, sizeof(g_level.give)); } else { // or fall back on worldspawn if (g_game.spawn.give && *g_game.spawn.give) { g_strlcpy(g_level.give, g_game.spawn.give, sizeof(g_level.give)); } else { g_level.give[0] = '\0'; } } if (map && *map->music) { // prefer maps.lst music g_strlcpy(g_level.music, map->music, sizeof(g_level.music)); } else { // or fall back on worldspawn if (g_game.spawn.music && *g_game.spawn.music) { g_strlcpy(g_level.music, g_game.spawn.music, sizeof(g_level.music)); } else { g_level.music[0] = '\0'; } } G_WorldspawnMusic(); gi.SetConfigString(CS_VOTE, ""); }
/*QUAKED worldspawn(0 0 0) ? Only used for the world. "message" "Stress Fractures by Jester" "sky" unit1_ "weather" none, rain, snow, fog 0.5 0.8 0.7 "gravity" 800 "gameplay" deathmatch, instagib, rocket arena "teams" 0 off, 1 on, 2 balanced "ctf" 0 off, 1 on, 2 balanced "match" 0 off, 1 on "round" 0 off, 1 on "frag_limit" 20 frags "round_limit" 20 rounds "capture_limit" 8 captures "time_limit" 20 minutes "give" comma-delimited items list "music" comma-delimited track list */ static void G_worldspawn(g_edict_t *ent) { uint32_t i; g_map_list_elt_t *map; ent->locals.move_type = MOVE_TYPE_PUSH; ent->solid = SOLID_BSP; ent->in_use = true; // since the world doesn't use G_Spawn() ent->s.model1 = 0; // world model is always index 1 map = NULL; // resolve the maps.lst entry for this level for (i = 0; i < g_map_list.count; i++) { if (!g_strcmp0(g_level.name, g_map_list.maps[i].name)) { map = &g_map_list.maps[i]; break; } } if (ent->locals.message && *ent->locals.message) g_strlcpy(g_level.title, ent->locals.message, sizeof(g_level.title)); else // or just the level name g_strlcpy(g_level.title, g_level.name, sizeof(g_level.title)); gi.ConfigString(CS_NAME, g_level.title); if (map && *map->sky) // prefer maps.lst sky gi.ConfigString(CS_SKY, map->sky); else { // or fall back on worldspawn if (g_game.spawn.sky && *g_game.spawn.sky) gi.ConfigString(CS_SKY, g_game.spawn.sky); else // or default to unit1_ gi.ConfigString(CS_SKY, "unit1_"); } if (map && *map->weather) // prefer maps.lst weather gi.ConfigString(CS_WEATHER, map->weather); else { // or fall back on worldspawn if (g_game.spawn.weather && *g_game.spawn.weather) gi.ConfigString(CS_WEATHER, g_game.spawn.weather); else // or default to none gi.ConfigString(CS_WEATHER, "none"); } if (map && map->gravity > 0) // prefer maps.lst gravity g_level.gravity = map->gravity; else { // or fall back on worldspawn if (g_game.spawn.gravity && *g_game.spawn.gravity) g_level.gravity = atoi(g_game.spawn.gravity); else // or default to 800 g_level.gravity = 800; } if (g_strcmp0(g_gameplay->string, "default")) { // perfer g_gameplay g_level.gameplay = G_GameplayByName(g_gameplay->string); } else if (map && map->gameplay > -1) { // then maps.lst gameplay g_level.gameplay = map->gameplay; } else { // or fall back on worldspawn if (g_game.spawn.gameplay && *g_game.spawn.gameplay) g_level.gameplay = G_GameplayByName(g_game.spawn.gameplay); else // or default to deathmatch g_level.gameplay = DEATHMATCH; } if (g_level.gameplay == DEFAULT) g_level.gameplay = DEATHMATCH; gi.ConfigString(CS_GAMEPLAY, va("%d", g_level.gameplay)); if (map && map->teams > -1) // prefer maps.lst teams g_level.teams = map->teams; else { // or fall back on worldspawn if (g_game.spawn.teams && *g_game.spawn.teams) g_level.teams = atoi(g_game.spawn.teams); else // or default to cvar g_level.teams = g_teams->integer; } if (map && map->ctf > -1) // prefer maps.lst ctf g_level.ctf = map->ctf; else { // or fall back on worldspawn if (g_game.spawn.ctf && *g_game.spawn.ctf) g_level.ctf = atoi(g_game.spawn.ctf); else // or default to cvar g_level.ctf = g_ctf->integer; } if (g_level.teams && g_level.ctf) // ctf overrides teams g_level.teams = 0; gi.ConfigString(CS_TEAMS, va("%d", g_level.teams)); gi.ConfigString(CS_CTF, va("%d", g_level.ctf)); if (map && map->match > -1) // prefer maps.lst match g_level.match = map->match; else { // or fall back on worldspawn if (g_game.spawn.match && *g_game.spawn.match) g_level.match = atoi(g_game.spawn.match); else // or default to cvar g_level.match = g_match->integer; } if (map && map->rounds > -1) // prefer maps.lst rounds g_level.rounds = map->rounds; else { // or fall back on worldspawn if (g_game.spawn.rounds && *g_game.spawn.rounds) g_level.rounds = atoi(g_game.spawn.rounds); else // or default to cvar g_level.rounds = g_rounds->integer; } if (g_level.match && g_level.rounds) // rounds overrides match g_level.match = 0; gi.ConfigString(CS_MATCH, va("%d", g_level.match)); gi.ConfigString(CS_ROUNDS, va("%d", g_level.rounds)); if (map && map->frag_limit > -1) // prefer maps.lst frag_limit g_level.frag_limit = map->frag_limit; else { // or fall back on worldspawn if (g_game.spawn.frag_limit && *g_game.spawn.frag_limit) g_level.frag_limit = atoi(g_game.spawn.frag_limit); else // or default to cvar g_level.frag_limit = g_frag_limit->integer; } if (map && map->round_limit > -1) // prefer maps.lst round_limit g_level.round_limit = map->round_limit; else { // or fall back on worldspawn if (g_game.spawn.round_limit && *g_game.spawn.round_limit) g_level.round_limit = atoi(g_game.spawn.round_limit); else // or default to cvar g_level.round_limit = g_round_limit->integer; } if (map && map->capture_limit > -1) // prefer maps.lst capture_limit g_level.capture_limit = map->capture_limit; else { // or fall back on worldspawn if (g_game.spawn.capture_limit && *g_game.spawn.capture_limit) g_level.capture_limit = atoi(g_game.spawn.capture_limit); else // or default to cvar g_level.capture_limit = g_capture_limit->integer; } vec_t time_limit; if (map && map->time_limit > -1) // prefer maps.lst time_limit time_limit = map->time_limit; else { // or fall back on worldspawn if (g_game.spawn.time_limit && *g_game.spawn.time_limit) time_limit = atof(g_game.spawn.time_limit); else // or default to cvar time_limit = g_time_limit->value; } g_level.time_limit = time_limit * 60 * 1000; if (map && *map->give) // prefer maps.lst give g_strlcpy(g_level.give, map->give, sizeof(g_level.give)); else { // or fall back on worldspawn if (g_game.spawn.give && *g_game.spawn.give) g_strlcpy(g_level.give, g_game.spawn.give, sizeof(g_level.give)); else // or clean it g_level.give[0] = '\0'; } if (map && *map->music) // prefer maps.lst music g_strlcpy(g_level.music, map->music, sizeof(g_level.music)); else { // or fall back on worldspawn if (g_game.spawn.music && *g_game.spawn.music) g_strlcpy(g_level.music, g_game.spawn.music, sizeof(g_level.music)); else g_level.music[0] = '\0'; } G_WorldspawnMusic(); G_PrecacheItem(G_FindItem("Blaster")); G_PrecacheItem(G_FindItem("Shotgun")); G_PrecacheItem(G_FindItem("Shuper Shotgun")); G_PrecacheItem(G_FindItem("Machinegun")); G_PrecacheItem(G_FindItem("Grenade Launcher")); G_PrecacheItem(G_FindItem("Rocket Launcher")); G_PrecacheItem(G_FindItem("Hyperblaster")); G_PrecacheItem(G_FindItem("Lightning")); G_PrecacheItem(G_FindItem("Railgun")); G_PrecacheItem(G_FindItem("BFG10K")); gi.SoundIndex("world/water_in"); gi.SoundIndex("world/water_out"); gi.SoundIndex("weapons/common/no_ammo"); gi.SoundIndex("weapons/common/pickup"); gi.SoundIndex("weapons/common/switch"); gi.ConfigString(CS_VOTE, ""); gi.ConfigString(CS_TEAM_GOOD, g_team_good.name); gi.ConfigString(CS_TEAM_EVIL, g_team_evil.name); }