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

Go to the source code of this file.

Typedefs

using spawn_evalfunc_t = vector(entity this, entity player, entity spot, vector current)

Functions

entity SelectSpawnPoint (entity this, bool anypoint)
entity Spawn_FilterOutBadSpots (entity this, entity firstspot, float mindist, float teamcheck, bool targetcheck)
bool SpawnEvent_Send (entity this, entity to, int sf)
 spawnfunc (info_player_deathmatch)
void spawnpoint_use (entity this, entity actor, entity trigger)
 STATIC_INIT (g_spawnpoints)

Variables

int autocvar_g_spawn_alloweffects
float autocvar_g_spawn_furthest
bool autocvar_g_spawn_useallspawns
bool autocvar_g_spawnpoints_auto_move_out_of_solid
float autocvar_r_showbboxes
IntrusiveList g_spawnpoints
int have_team_spawns
int have_team_spawns_forteams
int restriction
bool some_spawn_has_been_used
spawn_evalfunc_t spawn_evalfunc
const int SPAWN_PRIO_GOOD_DISTANCE = 10
const int SPAWN_PRIO_NEAR_TEAMMATE_FOUND = 200
const int SPAWN_PRIO_NEAR_TEAMMATE_SAMETEAM = 100
const int SPAWN_PRIO_RACE_PREVIOUS_SPAWN = 50
float spawnpoint_nag
vector spawnpoint_score

Typedef Documentation

◆ spawn_evalfunc_t

using spawn_evalfunc_t = vector(entity this, entity player, entity spot, vector current)

Definition at line 27 of file spawnpoints.qh.

Function Documentation

◆ SelectSpawnPoint()

entity SelectSpawnPoint ( entity this,
bool anypoint )

Definition at line 359 of file spawnpoints.qc.

360{
361 float teamcheck;
362 entity spot = NULL;
363
365 {
366 testspawn_point = find(NULL, classname, "testplayerstart");
367 testspawn_checked = true;
368 }
369
371 return testspawn_point;
372
373 if(this.spawnpoint_targ)
374 return this.spawnpoint_targ;
375
376 if(anypoint || autocvar_g_spawn_useallspawns)
377 teamcheck = -1;
378 else if(have_team_spawns > 0)
379 {
380 if(!(have_team_spawns_forteams & BIT(this.team)))
381 {
382 // we request a spawn for a team, and we have team
383 // spawns, but that team has no spawns?
385 // try noteam spawns
386 teamcheck = 0;
387 else
388 // if not, any spawn has to do
389 teamcheck = -1;
390 }
391 else
392 teamcheck = this.team; // MUST be team
393 }
394 else if(have_team_spawns == 0 && (have_team_spawns_forteams & BIT(0)))
395 teamcheck = 0; // MUST be noteam
396 else
397 teamcheck = -1;
398 // if we get here, we either require team spawns but have none, or we require non-team spawns and have none; use any spawn then
399
400
401 // get the entire list of spots
402 //entity firstspot = findchain(classname, "info_player_deathmatch");
403 entity firstspot = IL_FIRST(g_spawnpoints);
404 entity prev = NULL;
406 {
407 if(prev)
408 prev.chain = it;
409 it.chain = NULL;
410 prev = it;
411 });
412 // filter out the bad ones
413 // (note this returns the original list if none survived)
414 if(anypoint)
415 {
416 spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
417 }
418 else
419 {
420 firstspot = Spawn_FilterOutBadSpots(this, firstspot, 100, teamcheck, true);
421
422 // emergency fallback! double check without targets
423 // fixes some crashes with improperly repacked maps
424 if(!firstspot)
425 {
426 firstspot = IL_FIRST(g_spawnpoints);
427 prev = NULL;
429 {
430 if(prev)
431 prev.chain = it;
432 it.chain = NULL;
433 prev = it;
434 });
435 firstspot = Spawn_FilterOutBadSpots(this, firstspot, 100, teamcheck, false);
436 }
437
438 // there is 50/50 chance of choosing a random spot or the furthest spot
439 // (this means that roughly every other spawn will be furthest, so you
440 // usually won't get fragged at spawn twice in a row)
442 spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
443 else
444 spot = Spawn_WeightedPoint(firstspot, 1, 5000, 5); // chooses a far far away spawnpoint
445 }
446
447 if (!spot)
448 {
450 GotoNextMap(0);
451 else
452 {
454 return NULL; // team can't spawn any more, because of actions of other team
455 else
456 error("Cannot find a spawn point - please fix the map!");
457 }
458 }
459
460 return spot;
461}
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
int team
Definition main.qh:188
string classname
prev
Definition all.qh:71
void GotoNextMap(float reinit)
#define IL_FIRST(this)
#define IL_EACH(this, cond, body)
entity find(entity start,.string field, string match)
float random(void)
#define NULL
Definition post.qh:14
#define error
Definition pre.qh:6
int autocvar_spawn_debug
Definition client.qh:51
bool testspawn_checked
entity Spawn_WeightedPoint(entity firstspot, float lower, float upper, float exponent)
entity testspawn_point
entity Spawn_FilterOutBadSpots(entity this, entity firstspot, float mindist, float teamcheck, bool targetcheck)
bool autocvar_g_spawn_useallspawns
Definition spawnpoints.qh:5
int have_team_spawns
int have_team_spawns_forteams
bool some_spawn_has_been_used
IntrusiveList g_spawnpoints
float autocvar_g_spawn_furthest
Definition spawnpoints.qh:4
entity spawnpoint_targ
Definition spawnpoint.qh:4

References autocvar_g_spawn_furthest, autocvar_g_spawn_useallspawns, autocvar_spawn_debug, BIT, classname, entity(), error, find(), g_spawnpoints, GotoNextMap(), have_team_spawns, have_team_spawns_forteams, IL_EACH, IL_FIRST, NULL, prev, random(), some_spawn_has_been_used, Spawn_FilterOutBadSpots(), Spawn_WeightedPoint(), spawnpoint_targ, team, testspawn_checked, and testspawn_point.

Referenced by buff_Respawn(), ka_RespawnBall(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), PutObserverInServer(), PutPlayerInServer(), and tka_RespawnBall().

◆ Spawn_FilterOutBadSpots()

entity Spawn_FilterOutBadSpots ( entity this,
entity firstspot,
float mindist,
float teamcheck,
bool targetcheck )

Definition at line 311 of file spawnpoints.qc.

312{
313 entity spot, spotlist, spotlistend;
314
315 spotlist = NULL;
316 spotlistend = NULL;
317
318 Spawn_ScoreAll(this, firstspot, mindist, teamcheck, targetcheck);
319
320 for(spot = firstspot; spot; spot = spot.chain)
321 {
322 if(spot.spawnpoint_score.x >= 0) // spawning allowed here
323 {
324 if(spotlistend)
325 spotlistend.chain = spot;
326 spotlistend = spot;
327 if(!spotlist)
328 spotlist = spot;
329 }
330 }
331 if(spotlistend)
332 spotlistend.chain = NULL;
333
334 return spotlist;
335}
void Spawn_ScoreAll(entity this, entity firstspot, float mindist, float teamcheck, bool targetcheck)

References entity(), NULL, and Spawn_ScoreAll().

Referenced by SelectSpawnPoint(), and trigger_race_checkpoint_verify().

◆ SpawnEvent_Send()

bool SpawnEvent_Send ( entity this,
entity to,
int sf )

Definition at line 32 of file spawnpoints.qc.

33{
34 float send;
35
36 WriteHeader(MSG_ENTITY, ENT_CLIENT_SPAWNEVENT);
37
39 {
41 WriteVector(MSG_ENTITY, this.owner.origin);
42 WriteByte(MSG_ENTITY, this.owner.team);
44 send = true;
45 }
46 else if((to == this.owner) || (IS_SPEC(to) && (to.enemy == this.owner)) )
47 {
49 send = true;
50 }
51 else { send = false; }
52
53 return send;
54}
entity owner
Definition main.qh:87
const int MSG_ENTITY
Definition net.qh:115
#define WriteHeader(to, id)
Definition net.qh:221
void WriteByte(float data, float dest, float desto)
#define etof(e)
Definition misc.qh:25
int autocvar_g_spawn_alloweffects
Definition spawnpoints.qh:3
#define IS_SPEC(v)
Definition utils.qh:10

References autocvar_g_spawn_alloweffects, entity(), etof, IS_SPEC, MSG_ENTITY, owner, WriteByte(), and WriteHeader.

Referenced by PutPlayerInServer().

◆ spawnfunc()

spawnfunc ( info_player_deathmatch )

Definition at line 193 of file spawnpoints.qc.

194{
195 IL_PUSH(g_spawnpoints, this);
197}
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
void relocate_spawnpoint(entity this)

References g_spawnpoints, IL_PUSH(), and relocate_spawnpoint().

◆ spawnpoint_use()

void spawnpoint_use ( entity this,
entity actor,
entity trigger )

Definition at line 67 of file spawnpoints.qc.

68{
69 if(teamplay)
70 if(have_team_spawns > 0)
71 {
72 this.team = actor.team;
74 this.SendFlags |= 1; // update team on the client side
75 }
76 //LOG_INFO("spawnpoint was used!\n");
77}
int SendFlags
Definition net.qh:118
bool teamplay
Definition teams.qh:59

References entity(), have_team_spawns, SendFlags, some_spawn_has_been_used, team, and teamplay.

Referenced by relocate_spawnpoint().

◆ STATIC_INIT()

STATIC_INIT ( g_spawnpoints )

Definition at line 33 of file spawnpoints.qh.

33{ g_spawnpoints = IL_NEW(); }
#define IL_NEW()

References g_spawnpoints, and IL_NEW.

Variable Documentation

◆ autocvar_g_spawn_alloweffects

int autocvar_g_spawn_alloweffects

Definition at line 3 of file spawnpoints.qh.

Referenced by SpawnEvent_Send().

◆ autocvar_g_spawn_furthest

float autocvar_g_spawn_furthest

Definition at line 4 of file spawnpoints.qh.

Referenced by SelectSpawnPoint().

◆ autocvar_g_spawn_useallspawns

bool autocvar_g_spawn_useallspawns

◆ autocvar_g_spawnpoints_auto_move_out_of_solid

bool autocvar_g_spawnpoints_auto_move_out_of_solid

Definition at line 6 of file spawnpoints.qh.

Referenced by relocate_spawnpoint().

◆ autocvar_r_showbboxes

float autocvar_r_showbboxes

Definition at line 7 of file spawnpoints.qh.

Referenced by relocate_spawnpoint().

◆ g_spawnpoints

◆ have_team_spawns

◆ have_team_spawns_forteams

int have_team_spawns_forteams

Definition at line 17 of file spawnpoints.qh.

Referenced by relocate_spawnpoint(), and SelectSpawnPoint().

◆ restriction

int restriction

Definition at line 30 of file spawnpoints.qh.

◆ some_spawn_has_been_used

bool some_spawn_has_been_used

◆ spawn_evalfunc

spawn_evalfunc_t spawn_evalfunc

Definition at line 28 of file spawnpoints.qh.

Referenced by spawnfunc(), and spawnfunc().

◆ SPAWN_PRIO_GOOD_DISTANCE

const int SPAWN_PRIO_GOOD_DISTANCE = 10

Definition at line 13 of file spawnpoints.qh.

Referenced by Spawn_Score().

◆ SPAWN_PRIO_NEAR_TEAMMATE_FOUND

const int SPAWN_PRIO_NEAR_TEAMMATE_FOUND = 200

Definition at line 10 of file spawnpoints.qh.

Referenced by MUTATOR_HOOKFUNCTION().

◆ SPAWN_PRIO_NEAR_TEAMMATE_SAMETEAM

const int SPAWN_PRIO_NEAR_TEAMMATE_SAMETEAM = 100

Definition at line 11 of file spawnpoints.qh.

Referenced by MUTATOR_HOOKFUNCTION().

◆ SPAWN_PRIO_RACE_PREVIOUS_SPAWN

const int SPAWN_PRIO_RACE_PREVIOUS_SPAWN = 50

Definition at line 12 of file spawnpoints.qh.

Referenced by trigger_race_checkpoint_spawn_evalfunc().

◆ spawnpoint_nag

float spawnpoint_nag

Definition at line 20 of file spawnpoints.qh.

Referenced by relocate_spawnpoint().

◆ spawnpoint_score

vector spawnpoint_score

Definition at line 19 of file spawnpoints.qh.