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

359{
360 float teamcheck;
361 entity spot = NULL;
362
364 {
365 testspawn_point = find(NULL, classname, "testplayerstart");
366 testspawn_checked = true;
367 }
368
370 return testspawn_point;
371
372 if(this.spawnpoint_targ)
373 return this.spawnpoint_targ;
374
375 if(anypoint || autocvar_g_spawn_useallspawns)
376 teamcheck = -1;
377 else if(have_team_spawns > 0)
378 {
379 if(!(have_team_spawns_forteams & BIT(this.team)))
380 {
381 // we request a spawn for a team, and we have team
382 // spawns, but that team has no spawns?
384 // try noteam spawns
385 teamcheck = 0;
386 else
387 // if not, any spawn has to do
388 teamcheck = -1;
389 }
390 else
391 teamcheck = this.team; // MUST be team
392 }
393 else if(have_team_spawns == 0 && (have_team_spawns_forteams & BIT(0)))
394 teamcheck = 0; // MUST be noteam
395 else
396 teamcheck = -1;
397 // 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
398
399
400 // get the entire list of spots
401 //entity firstspot = findchain(classname, "info_player_deathmatch");
402 entity firstspot = IL_FIRST(g_spawnpoints);
403 entity prev = NULL;
405 {
406 if(prev)
407 prev.chain = it;
408 it.chain = NULL;
409 prev = it;
410 });
411 // filter out the bad ones
412 // (note this returns the original list if none survived)
413 if(anypoint)
414 {
415 spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
416 }
417 else
418 {
419 firstspot = Spawn_FilterOutBadSpots(this, firstspot, 100, teamcheck, true);
420
421 // emergency fallback! double check without targets
422 // fixes some crashes with improperly repacked maps
423 if(!firstspot)
424 {
425 firstspot = IL_FIRST(g_spawnpoints);
426 prev = NULL;
428 {
429 if(prev)
430 prev.chain = it;
431 it.chain = NULL;
432 prev = it;
433 });
434 firstspot = Spawn_FilterOutBadSpots(this, firstspot, 100, teamcheck, false);
435 }
436
437 // there is 50/50 chance of choosing a random spot or the furthest spot
438 // (this means that roughly every other spawn will be furthest, so you
439 // usually won't get fragged at spawn twice in a row)
441 spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
442 else
443 spot = Spawn_WeightedPoint(firstspot, 1, 5000, 5); // chooses a far far away spawnpoint
444 }
445
446 if (!spot)
447 {
449 GotoNextMap(0);
450 else
451 {
453 return NULL; // team can't spawn any more, because of actions of other team
454 else
455 error("Cannot find a spawn point - please fix the map!");
456 }
457 }
458
459 return spot;
460}
#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:73
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 310 of file spawnpoints.qc.

311{
312 entity spot, spotlist, spotlistend;
313
314 spotlist = NULL;
315 spotlistend = NULL;
316
317 Spawn_ScoreAll(this, firstspot, mindist, teamcheck, targetcheck);
318
319 for(spot = firstspot; spot; spot = spot.chain)
320 {
321 if(spot.spawnpoint_score.x >= 0) // spawning allowed here
322 {
323 if(spotlistend)
324 spotlistend.chain = spot;
325 spotlistend = spot;
326 if(!spotlist)
327 spotlist = spot;
328 }
329 }
330 if(spotlistend)
331 spotlistend.chain = NULL;
332
333 return spotlist;
334}
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:156
#define WriteHeader(to, id)
Definition net.qh:265
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 192 of file spawnpoints.qc.

193{
194 IL_PUSH(g_spawnpoints, this);
196}
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:159
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.