Xonotic
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

bool 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 329 of file spawnpoints.qc.

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(), team, testspawn_checked, and testspawn_point.

Referenced by buff_Respawn(), Damage(), ka_RespawnBall(), PutObserverInServer(), and PutPlayerInServer().

330 {
331  float teamcheck;
332  entity spot = NULL;
333 
334  if(!testspawn_checked)
335  {
336  testspawn_point = find(NULL, classname, "testplayerstart");
337  testspawn_checked = true;
338  }
339 
340  if(testspawn_point)
341  return testspawn_point;
342 
343  if(this.spawnpoint_targ)
344  return this.spawnpoint_targ;
345 
346  if(anypoint || autocvar_g_spawn_useallspawns)
347  teamcheck = -1;
348  else if(have_team_spawns > 0)
349  {
350  if(!(have_team_spawns_forteams & BIT(this.team)))
351  {
352  // we request a spawn for a team, and we have team
353  // spawns, but that team has no spawns?
355  // try noteam spawns
356  teamcheck = 0;
357  else
358  // if not, any spawn has to do
359  teamcheck = -1;
360  }
361  else
362  teamcheck = this.team; // MUST be team
363  }
364  else if(have_team_spawns == 0 && (have_team_spawns_forteams & BIT(0)))
365  teamcheck = 0; // MUST be noteam
366  else
367  teamcheck = -1;
368  // 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
369 
370 
371  // get the entire list of spots
372  //entity firstspot = findchain(classname, "info_player_deathmatch");
373  entity firstspot = IL_FIRST(g_spawnpoints);
374  entity prev = NULL;
375  IL_EACH(g_spawnpoints, true,
376  {
377  if(prev)
378  prev.chain = it;
379  it.chain = NULL;
380  prev = it;
381  });
382  // filter out the bad ones
383  // (note this returns the original list if none survived)
384  if(anypoint)
385  {
386  spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
387  }
388  else
389  {
390  firstspot = Spawn_FilterOutBadSpots(this, firstspot, 100, teamcheck, true);
391 
392  // emergency fallback! double check without targets
393  // fixes some crashes with improperly repacked maps
394  if(!firstspot)
395  {
396  firstspot = IL_FIRST(g_spawnpoints);
397  prev = NULL;
398  IL_EACH(g_spawnpoints, true,
399  {
400  if(prev)
401  prev.chain = it;
402  it.chain = NULL;
403  prev = it;
404  });
405  firstspot = Spawn_FilterOutBadSpots(this, firstspot, 100, teamcheck, false);
406  }
407 
408  // there is 50/50 chance of choosing a random spot or the furthest spot
409  // (this means that roughly every other spawn will be furthest, so you
410  // usually won't get fragged at spawn twice in a row)
412  spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
413  else
414  spot = Spawn_WeightedPoint(firstspot, 1, 5000, 5); // chooses a far far away spawnpoint
415  }
416 
417  if (!spot)
418  {
420  GotoNextMap(0);
421  else
422  {
424  return NULL; // team can't spawn any more, because of actions of other team
425  else
426  error("Cannot find a spawn point - please fix the map!");
427  }
428  }
429 
430  return spot;
431 }
#define IL_EACH(this, cond, body)
int have_team_spawns_forteams
Definition: spawnpoints.qh:17
void GotoNextMap(float reinit)
int team
Definition: main.qh:157
int have_team_spawns
Definition: spawnpoints.qh:16
entity() spawn
prev
Definition: all.qh:66
int autocvar_spawn_debug
Definition: client.qh:50
#define IL_FIRST(this)
string classname
Definition: csprogsdefs.qc:107
float autocvar_g_spawn_furthest
Definition: spawnpoints.qh:4
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition: bits.qh:8
entity Spawn_WeightedPoint(entity firstspot, float lower, float upper, float exponent)
Definition: spawnpoints.qc:307
#define NULL
Definition: post.qh:17
bool some_spawn_has_been_used
Definition: spawnpoints.qh:15
entity Spawn_FilterOutBadSpots(entity this, entity firstspot, float mindist, float teamcheck, bool targetcheck)
Definition: spawnpoints.qc:281
bool autocvar_g_spawn_useallspawns
Definition: spawnpoints.qh:5
bool testspawn_checked
Definition: spawnpoints.qc:327
entity testspawn_point
Definition: spawnpoints.qc:328
IntrusiveList g_spawnpoints
Definition: spawnpoints.qh:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Spawn_FilterOutBadSpots()

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

Definition at line 281 of file spawnpoints.qc.

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

Referenced by SelectSpawnPoint(), and trigger_race_checkpoint_verify().

282 {
283  entity spot, spotlist, spotlistend;
284 
285  spotlist = NULL;
286  spotlistend = NULL;
287 
288  Spawn_ScoreAll(this, firstspot, mindist, teamcheck, targetcheck);
289 
290  for(spot = firstspot; spot; spot = spot.chain)
291  {
292  if(spot.spawnpoint_score.x >= 0) // spawning allowed here
293  {
294  if(spotlistend)
295  spotlistend.chain = spot;
296  spotlistend = spot;
297  if(!spotlist)
298  spotlist = spot;
299  }
300  }
301  if(spotlistend)
302  spotlistend.chain = NULL;
303 
304  return spotlist;
305 }
entity() spawn
void Spawn_ScoreAll(entity this, entity firstspot, float mindist, float teamcheck, bool targetcheck)
Definition: spawnpoints.qc:274
#define NULL
Definition: post.qh:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SpawnEvent_Send()

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

Definition at line 32 of file spawnpoints.qc.

References autocvar_g_spawn_alloweffects, etof(), IS_SPEC, owner, and WriteByte().

Referenced by PutPlayerInServer().

33 {
34  float send;
35 
36  WriteHeader(MSG_ENTITY, ENT_CLIENT_SPAWNEVENT);
37 
39  {
40  WriteByte(MSG_ENTITY, etof(this.owner));
41  WriteVector(MSG_ENTITY, this.owner.origin);
42  send = true;
43  }
44  else if((to == this.owner) || (IS_SPEC(to) && (to.enemy == this.owner)) )
45  {
46  WriteByte(MSG_ENTITY, 0);
47  send = true;
48  }
49  else { send = false; }
50 
51  return send;
52 }
entity to
Definition: self.qh:96
entity owner
Definition: main.qh:73
#define IS_SPEC(v)
Definition: utils.qh:10
bool autocvar_g_spawn_alloweffects
Definition: spawnpoints.qh:3
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ spawnfunc()

spawnfunc ( info_player_deathmatch  )

Definition at line 166 of file spawnpoints.qc.

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

167 {
168  IL_PUSH(g_spawnpoints, this);
169  relocate_spawnpoint(this);
170 }
void relocate_spawnpoint(entity this)
Definition: spawnpoints.qc:93
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
IntrusiveList g_spawnpoints
Definition: spawnpoints.qh:32
+ Here is the call graph for this function:

◆ spawnpoint_use()

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

Definition at line 65 of file spawnpoints.qc.

References have_team_spawns, some_spawn_has_been_used, team, and teamplay.

Referenced by relocate_spawnpoint().

66 {
67  if(teamplay)
68  if(have_team_spawns > 0)
69  {
70  this.team = actor.team;
72  this.SendFlags |= 1; // update team on the client side
73  }
74  //LOG_INFO("spawnpoint was used!\n");
75 }
int team
Definition: main.qh:157
int have_team_spawns
Definition: spawnpoints.qh:16
bool some_spawn_has_been_used
Definition: spawnpoints.qh:15
float teamplay
Definition: progsdefs.qc:31
+ Here is the caller graph for this function:

◆ STATIC_INIT()

STATIC_INIT ( g_spawnpoints  )

Definition at line 33 of file spawnpoints.qh.

References IL_NEW.

33 { g_spawnpoints = IL_NEW(); }
#define IL_NEW()
IntrusiveList g_spawnpoints
Definition: spawnpoints.qh:32

Variable Documentation

◆ autocvar_g_spawn_alloweffects

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

◆ 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.