if(!MoveToRandomMapLocation(this, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY,
((autocvar_g_buffs_random_location_attempts > 0) ? autocvar_g_buffs_random_location_attempts : 10), 1024, 256))
{
- entity spot = SelectSpawnPoint(true);
+ entity spot = SelectSpawnPoint(this, true);
setorigin(this, spot.origin);
this.velocity = ((randomvec() * 100) + '0 0 200');
this.angles = spot.angles;
}
{
- entity spot = SelectSpawnPoint(true);
+ entity spot = SelectSpawnPoint(this, true);
if (!spot) LOG_FATAL("No spawnpoints for observers?!?");
this.angles = spot.angles;
this.angles_z = 0;
if (this.team < 0)
JoinBestTeam(this, false, true);
- entity spot = SelectSpawnPoint(false);
+ entity spot = SelectSpawnPoint(this, false);
if (!spot) {
Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_JOIN_NOSPAWNS);
return; // spawn failed
void PlayerUseKey();
-USING(spawn_evalfunc_t, vector(entity player, entity spot, vector current));
+USING(spawn_evalfunc_t, vector(entity this, entity player, entity spot, vector current));
.spawn_evalfunc_t spawn_evalfunc;
string modname;
{
Send_Effect(EFFECT_TELEPORT, targ.origin, '0 0 0', 1);
- setself(targ);
- entity spot = SelectSpawnPoint (false);
+ entity spot = SelectSpawnPoint (targ, false);
if(spot)
{
damage = 0;
- self.deadflag = DEAD_NO;
+ targ.deadflag = DEAD_NO;
- self.angles = spot.angles;
+ targ.angles = spot.angles;
- self.effects = 0;
- self.effects |= EF_TELEPORT_BIT;
+ targ.effects = 0;
+ targ.effects |= EF_TELEPORT_BIT;
- self.angles_z = 0; // never spawn tilted even if the spot says to
- self.fixangle = true; // turn this way immediately
- self.velocity = '0 0 0';
- self.avelocity = '0 0 0';
- self.punchangle = '0 0 0';
- self.punchvector = '0 0 0';
- self.oldvelocity = self.velocity;
+ targ.angles_z = 0; // never spawn tilted even if the spot says to
+ targ.fixangle = true; // turn this way immediately
+ targ.velocity = '0 0 0';
+ targ.avelocity = '0 0 0';
+ targ.punchangle = '0 0 0';
+ targ.punchvector = '0 0 0';
+ targ.oldvelocity = targ.velocity;
- self.spawnorigin = spot.origin;
- setorigin (self, spot.origin + '0 0 1' * (1 - self.mins.z - 24));
+ targ.spawnorigin = spot.origin;
+ setorigin (targ, spot.origin + '0 0 1' * (1 - targ.mins.z - 24));
// don't reset back to last position, even if new position is stuck in solid
- self.oldorigin = self.origin;
- self.prevorigin = self.origin;
+ targ.oldorigin = targ.origin;
+ targ.prevorigin = targ.origin;
- Send_Effect(EFFECT_TELEPORT, self.origin, '0 0 0', 1);
+ Send_Effect(EFFECT_TELEPORT, targ.origin, '0 0 0', 1);
}
-
- setself(this);
}
if(!g_instagib)
}
}
-vector target_objective_spawn_evalfunc(entity player, entity spot, vector current)
-{SELFPARAM();
- if(self.health < 0 || self.health >= ASSAULT_VALUE_INACTIVE)
+vector target_objective_spawn_evalfunc(entity this, entity player, entity spot, vector current)
+{
+ if(this.health < 0 || this.health >= ASSAULT_VALUE_INACTIVE)
return '-1 0 0';
return current;
}
if(!MoveToRandomMapLocation(self, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 10, 1024, 256))
{
- entity spot = SelectSpawnPoint(true);
+ entity spot = SelectSpawnPoint(this, true);
setorigin(self, spot.origin);
self.angles = spot.angles;
}
Portal_Remove(this, 1);
}
-void Portal_Think_TryTeleportPlayer(entity e, vector g)
-{SELFPARAM();
- if(!Portal_WillHitPlane(e.origin, e.mins, e.maxs, e.velocity + g, self.origin, v_forward, self.maxs.x))
+void Portal_Think_TryTeleportPlayer(entity this, entity e, vector g)
+{
+ if(!Portal_WillHitPlane(e.origin, e.mins, e.maxs, e.velocity + g, this.origin, v_forward, this.maxs.x))
return;
// if e would hit the portal in a frame...
// already teleport him
tracebox(e.origin, e.mins, e.maxs, e.origin + e.velocity * 2 * frametime, MOVE_NORMAL, e);
- if(trace_ent == self)
- Portal_TeleportPlayer(self, e);
+ if(trace_ent == this)
+ Portal_TeleportPlayer(this, e);
}
void Portal_Think()
continue; // cannot go through someone else's portal
if(it != o || time >= self.portal_activatetime)
- Portal_Think_TryTeleportPlayer(it, g);
+ Portal_Think_TryTeleportPlayer(self, it, g);
if(it.hook)
- Portal_Think_TryTeleportPlayer(it.hook, g);
+ Portal_Think_TryTeleportPlayer(self, it.hook, g);
));
self.solid = SOLID_TRIGGER;
self.aiment = o;
// race only (middle of the race)
g_race_qualifying = false;
pl_race_place = 0;
- if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+ if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) {
error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for respawning in race) - bailing out"));
}
// qualifying only
g_race_qualifying = 1;
pl_race_place = race_lowest_place_spawn;
- if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+ if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) {
error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for qualifying) - bailing out"));
}
g_race_qualifying = 0;
for (int p = 1; p <= race_highest_place_spawn; ++p) {
pl_race_place = p;
- if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+ if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) {
error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for initially spawning in race) - bailing out"));
}
}
pl_race_checkpoint = race_NextCheckpoint(0);
g_race_qualifying = 1;
pl_race_place = race_lowest_place_spawn;
- if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+ if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) {
error(strcat("Checkpoint 0 misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for qualifying) - bailing out"));
}
} else {
}
}
-vector trigger_race_checkpoint_spawn_evalfunc(entity player, entity spot, vector current)
-{SELFPARAM();
+vector trigger_race_checkpoint_spawn_evalfunc(entity this, entity player, entity spot, vector current)
+{
if(g_race_qualifying)
{
// spawn at first
- if(self.race_checkpoint != 0)
+ if(this.race_checkpoint != 0)
return '-1 0 0';
if(spot.race_place != race_lowest_place_spawn)
return '-1 0 0';
}
else
{
- if(self.race_checkpoint != player.race_respawn_checkpoint)
+ if(this.race_checkpoint != player.race_respawn_checkpoint)
return '-1 0 0';
// try reusing the previous spawn
- if(self == player.race_respawn_spotref || spot == player.race_respawn_spotref)
+ if(this == player.race_respawn_spotref || spot == player.race_respawn_spotref)
current.x += SPAWN_PRIO_RACE_PREVIOUS_SPAWN;
- if(self.race_checkpoint == 0)
+ if(this.race_checkpoint == 0)
{
- float pl;
- pl = player.race_place;
+ int pl = player.race_place;
if(pl > race_highest_place_spawn)
pl = 0;
if(pl == 0 && !player.race_started)
{
WriteHeader(MSG_ENTITY, ENT_CLIENT_SPAWNPOINT);
- WriteByte(MSG_ENTITY, self.team);
- WriteCoord(MSG_ENTITY, self.origin.x);
- WriteCoord(MSG_ENTITY, self.origin.y);
- WriteCoord(MSG_ENTITY, self.origin.z);
+ WriteByte(MSG_ENTITY, this.team);
+ WriteCoord(MSG_ENTITY, this.origin.x);
+ WriteCoord(MSG_ENTITY, this.origin.y);
+ WriteCoord(MSG_ENTITY, this.origin.z);
return true;
}
//LOG_INFO("spawnpoint was used!\n");
}
-void relocate_spawnpoint()
-{SELFPARAM();
+void relocate_spawnpoint(entity this)
+{
// nudge off the floor
- setorigin(self, self.origin + '0 0 1');
+ setorigin(this, this.origin + '0 0 1');
- tracebox(self.origin, PL_MIN_CONST, PL_MAX_CONST, self.origin, true, self);
+ tracebox(this.origin, PL_MIN_CONST, PL_MAX_CONST, this.origin, true, this);
if (trace_startsolid)
{
vector o;
- o = self.origin;
- self.mins = PL_MIN_CONST;
- self.maxs = PL_MAX_CONST;
- if (!move_out_of_solid(self))
+ o = this.origin;
+ this.mins = PL_MIN_CONST;
+ this.maxs = PL_MAX_CONST;
+ if (!move_out_of_solid(this))
objerror("could not get out of solid at all!");
LOG_INFO("^1NOTE: this map needs FIXING. Spawnpoint at ", vtos(o - '0 0 1'));
- LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(self.origin.x - o.x));
- LOG_INFO(" ", ftos(self.origin.y - o.y));
- LOG_INFO(" ", ftos(self.origin.z - o.z), "'\n");
+ LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(this.origin.x - o.x));
+ LOG_INFO(" ", ftos(this.origin.y - o.y));
+ LOG_INFO(" ", ftos(this.origin.z - o.z), "'\n");
if (autocvar_g_spawnpoints_auto_move_out_of_solid)
{
if (!spawnpoint_nag)
}
else
{
- setorigin(self, o);
- self.mins = self.maxs = '0 0 0';
+ setorigin(this, o);
+ this.mins = this.maxs = '0 0 0';
objerror("player spawn point in solid, mapper sucks!\n");
return;
}
}
- self.use = spawnpoint_use;
- self.think = spawnpoint_think;
- self.nextthink = time + 0.5 + random() * 2; // shouldn't need it for a little second
- self.team_saved = self.team;
- if (!self.cnt)
- self.cnt = 1;
+ this.use = spawnpoint_use;
+ this.think = spawnpoint_think;
+ this.nextthink = time + 0.5 + random() * 2; // shouldn't need it for a little second
+ this.team_saved = this.team;
+ if (!this.cnt)
+ this.cnt = 1;
if (have_team_spawns != 0)
- if (self.team)
+ if (this.team)
have_team_spawns = 1;
- have_team_spawns_forteam[self.team] = 1;
+ have_team_spawns_forteam[this.team] = 1;
if (autocvar_r_showbboxes)
{
// show where spawnpoints point at too
- makevectors(self.angles);
+ makevectors(this.angles);
entity e = new(info_player_foo);
- setorigin(e, self.origin + v_forward * 24);
+ setorigin(e, this.origin + v_forward * 24);
setsize(e, '-8 -8 -8', '8 8 8');
e.solid = SOLID_TRIGGER;
}
!(
( // if this passes, there is a DM spawn on a team match
teamplay
- && (self.team != NUM_TEAM_1)
- && (self.team != NUM_TEAM_2)
- && (self.team != NUM_TEAM_3)
- && (self.team != NUM_TEAM_4)
+ && (this.team != NUM_TEAM_1)
+ && (this.team != NUM_TEAM_2)
+ && (this.team != NUM_TEAM_3)
+ && (this.team != NUM_TEAM_4)
)
||
( // if this passes, there is a team spawn on a DM match
!teamplay
&&
(
- (self.team == NUM_TEAM_1)
- || (self.team == NUM_TEAM_2)
- || (self.team == NUM_TEAM_3)
- || (self.team == NUM_TEAM_4)
+ (this.team == NUM_TEAM_1)
+ || (this.team == NUM_TEAM_2)
+ || (this.team == NUM_TEAM_3)
+ || (this.team == NUM_TEAM_4)
)
)
)
||
autocvar_g_spawn_useallspawns
)
- { Net_LinkEntity(self, false, 0, SpawnPoint_Send); }
+ { Net_LinkEntity(this, false, 0, SpawnPoint_Send); }
}
spawnfunc(info_player_survivor)
spawnfunc(info_player_deathmatch)
{
- self.classname = "info_player_deathmatch";
- relocate_spawnpoint();
+ this.classname = "info_player_deathmatch";
+ relocate_spawnpoint(this);
}
/*QUAKED spawnfunc_info_player_team1 (1 0 0) (-16 -16 -24) (16 16 24)
// Returns:
// _x: prio (-1 if unusable)
// _y: weight
-vector Spawn_Score(entity spot, float mindist, float teamcheck)
-{SELFPARAM();
+vector Spawn_Score(entity this, entity spot, float mindist, float teamcheck)
+{
float shortest, thisdist;
float prio;
if(spot.target == "")
return '-1 0 0';
- if(IS_REAL_CLIENT(self))
+ if(IS_REAL_CLIENT(this))
{
if(spot.restriction == 1)
return '-1 0 0';
}
shortest = vlen(world.maxs - world.mins);
- FOREACH_CLIENT(IS_PLAYER(it) && it != self, LAMBDA(
+ FOREACH_CLIENT(IS_PLAYER(it) && it != this, LAMBDA(
thisdist = vlen(it.origin - spot.origin);
if (thisdist < shortest)
shortest = thisdist;
++found;
if(ent.spawn_evalfunc)
{
- WITHSELF(ent, spawn_score = ent.spawn_evalfunc(this, spot, spawn_score));
+ spawn_score = ent.spawn_evalfunc(ent, this, spot, spawn_score);
if(spawn_score.x < 0)
return spawn_score;
}
}
}
- MUTATOR_CALLHOOK(Spawn_Score, self, spawn_spot, spawn_score);
+ MUTATOR_CALLHOOK(Spawn_Score, this, spawn_spot, spawn_score);
return spawn_score;
}
-void Spawn_ScoreAll(entity firstspot, float mindist, float teamcheck)
+void Spawn_ScoreAll(entity this, entity firstspot, float mindist, float teamcheck)
{
entity spot;
for(spot = firstspot; spot; spot = spot.chain)
- spot.spawnpoint_score = Spawn_Score(spot, mindist, teamcheck);
+ spot.spawnpoint_score = Spawn_Score(this, spot, mindist, teamcheck);
}
-entity Spawn_FilterOutBadSpots(entity firstspot, float mindist, float teamcheck)
+entity Spawn_FilterOutBadSpots(entity this, entity firstspot, float mindist, float teamcheck)
{
entity spot, spotlist, spotlistend;
spotlist = world;
spotlistend = world;
- Spawn_ScoreAll(firstspot, mindist, teamcheck);
+ Spawn_ScoreAll(this, firstspot, mindist, teamcheck);
for(spot = firstspot; spot; spot = spot.chain)
{
Finds a point to respawn
=============
*/
-entity SelectSpawnPoint (float anypoint)
-{SELFPARAM();
+entity SelectSpawnPoint(entity this, bool anypoint)
+{
float teamcheck;
entity spot, firstspot;
teamcheck = -1;
else if(have_team_spawns > 0)
{
- if(have_team_spawns_forteam[self.team] == 0)
+ if(have_team_spawns_forteam[this.team] == 0)
{
// we request a spawn for a team, and we have team
// spawns, but that team has no spawns?
teamcheck = -1;
}
else
- teamcheck = self.team; // MUST be team
+ teamcheck = this.team; // MUST be team
}
else if(have_team_spawns == 0 && have_team_spawns_forteam[0])
teamcheck = 0; // MUST be noteam
}
else
{
- firstspot = Spawn_FilterOutBadSpots(firstspot, 100, teamcheck);
+ firstspot = Spawn_FilterOutBadSpots(this, firstspot, 100, teamcheck);
// there is 50/50 chance of choosing a random spot or the furthest spot
// (this means that roughly every other spawn will be furthest, so you
.vector spawnpoint_score;
float spawnpoint_nag;
bool SpawnEvent_Send(entity this, entity to, int sf);
-entity Spawn_FilterOutBadSpots(entity firstspot, float mindist, float teamcheck);
-entity SelectSpawnPoint (float anypoint);
+entity Spawn_FilterOutBadSpots(entity this, entity firstspot, float mindist, float teamcheck);
+entity SelectSpawnPoint(entity this, bool anypoint);
spawnfunc(info_player_deathmatch);
void spawnpoint_use(entity this, entity actor, entity trigger);