X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fspawnpoints.qc;h=344f05846f742cdb4d59b2c98ac053be715d1b8d;hp=3a574b28b2bfead37bf5a6eb73380f6f5af382ca;hb=37cf62041a76248472ef6a78feaaed33e35a2260;hpb=18302817d7f0cb0ba74398200da5e400ffc1b9a4 diff --git a/qcsrc/server/spawnpoints.qc b/qcsrc/server/spawnpoints.qc index 3a574b28b..344f05846 100644 --- a/qcsrc/server/spawnpoints.qc +++ b/qcsrc/server/spawnpoints.qc @@ -1,41 +1,42 @@ #include "spawnpoints.qh" -#include "_all.qh" -#include "mutators/mutators_include.qh" +#include "mutators/all.qh" #include "g_world.qh" #include "race.qh" #include "../common/constants.qh" #include "../common/teams.qh" +#include "../common/triggers/subs.qh" #include "../common/util.qh" -#include "../warpzonelib/util_server.qh" +#include "../lib/warpzone/common.qh" +#include "../lib/warpzone/util_server.qh" -float SpawnPoint_Send(entity to, int sf) -{SELFPARAM(); - WriteByte(MSG_ENTITY, ENT_CLIENT_SPAWNPOINT); +bool SpawnPoint_Send(entity this, entity to, int sf) +{ + WriteHeader(MSG_ENTITY, ENT_CLIENT_SPAWNPOINT); WriteByte(MSG_ENTITY, self.team); - WriteShort(MSG_ENTITY, self.origin.x); - WriteShort(MSG_ENTITY, self.origin.y); - WriteShort(MSG_ENTITY, self.origin.z); + WriteCoord(MSG_ENTITY, self.origin.x); + WriteCoord(MSG_ENTITY, self.origin.y); + WriteCoord(MSG_ENTITY, self.origin.z); return true; } -float SpawnEvent_Send(entity to, int sf) -{SELFPARAM(); +bool SpawnEvent_Send(entity this, entity to, int sf) +{ float send; - WriteByte(MSG_ENTITY, ENT_CLIENT_SPAWNEVENT); + WriteHeader(MSG_ENTITY, ENT_CLIENT_SPAWNEVENT); if(autocvar_g_spawn_alloweffects) { - WriteByte(MSG_ENTITY, num_for_edict(self.owner)); - WriteShort(MSG_ENTITY, self.owner.origin.x); - WriteShort(MSG_ENTITY, self.owner.origin.y); - WriteShort(MSG_ENTITY, self.owner.origin.z); + WriteByte(MSG_ENTITY, etof(this.owner)); + WriteCoord(MSG_ENTITY, this.owner.origin.x); + WriteCoord(MSG_ENTITY, this.owner.origin.y); + WriteCoord(MSG_ENTITY, this.owner.origin.z); send = true; } - else if((to == self.owner) || (IS_SPEC(to) && (to.enemy == self.owner)) ) + else if((to == this.owner) || (IS_SPEC(to) && (to.enemy == this.owner)) ) { WriteByte(MSG_ENTITY, 0); send = true; @@ -45,6 +46,18 @@ float SpawnEvent_Send(entity to, int sf) return send; } +.vector spawnpoint_prevorigin; +void spawnpoint_think() +{ + SELFPARAM(); + self.nextthink = time + 0.1; + if(self.origin != self.spawnpoint_prevorigin) + { + self.spawnpoint_prevorigin = self.origin; + self.SendFlags |= 1; + } +} + void spawnpoint_use() {SELFPARAM(); if(teamplay) @@ -90,6 +103,8 @@ void relocate_spawnpoint() } 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; @@ -103,9 +118,7 @@ void relocate_spawnpoint() { // show where spawnpoints point at too makevectors(self.angles); - entity e; - e = spawn(); - e.classname = "info_player_foo"; + entity e = new(info_player_foo); setorigin(e, self.origin + v_forward * 24); setsize(e, '-8 -8 -8', '8 8 8'); e.solid = SOLID_TRIGGER; @@ -141,18 +154,18 @@ void relocate_spawnpoint() { Net_LinkEntity(self, false, 0, SpawnPoint_Send); } } -void spawnfunc_info_player_survivor (void) +spawnfunc(info_player_survivor) { - spawnfunc_info_player_deathmatch(); + spawnfunc_info_player_deathmatch(this); } -void spawnfunc_info_player_start (void) +spawnfunc(info_player_start) { - spawnfunc_info_player_deathmatch(); + spawnfunc_info_player_deathmatch(this); } -void spawnfunc_info_player_deathmatch (void) -{SELFPARAM(); +spawnfunc(info_player_deathmatch) +{ self.classname = "info_player_deathmatch"; relocate_spawnpoint(); } @@ -160,47 +173,39 @@ void spawnfunc_info_player_deathmatch (void) /*QUAKED spawnfunc_info_player_team1 (1 0 0) (-16 -16 -24) (16 16 24) Starting point for a player in team one (Red). Keys: "angle" viewing angle when spawning. */ -void spawnfunc_info_player_team1() -{SELFPARAM(); - if(g_assault) { remove(self); return; } - - self.team = NUM_TEAM_1; // red - spawnfunc_info_player_deathmatch(); +spawnfunc(info_player_team1) +{ + this.team = NUM_TEAM_1; // red + spawnfunc_info_player_deathmatch(this); } /*QUAKED spawnfunc_info_player_team2 (1 0 0) (-16 -16 -24) (16 16 24) Starting point for a player in team two (Blue). Keys: "angle" viewing angle when spawning. */ -void spawnfunc_info_player_team2() -{SELFPARAM(); - if(g_assault) { remove(self); return; } - - self.team = NUM_TEAM_2; // blue - spawnfunc_info_player_deathmatch(); +spawnfunc(info_player_team2) +{ + this.team = NUM_TEAM_2; // blue + spawnfunc_info_player_deathmatch(this); } /*QUAKED spawnfunc_info_player_team3 (1 0 0) (-16 -16 -24) (16 16 24) Starting point for a player in team three (Yellow). Keys: "angle" viewing angle when spawning. */ -void spawnfunc_info_player_team3() -{SELFPARAM(); - if(g_assault) { remove(self); return; } - - self.team = NUM_TEAM_3; // yellow - spawnfunc_info_player_deathmatch(); +spawnfunc(info_player_team3) +{ + this.team = NUM_TEAM_3; // yellow + spawnfunc_info_player_deathmatch(this); } /*QUAKED spawnfunc_info_player_team4 (1 0 0) (-16 -16 -24) (16 16 24) Starting point for a player in team four (Purple). Keys: "angle" viewing angle when spawning. */ -void spawnfunc_info_player_team4() -{SELFPARAM(); - if(g_assault) { remove(self); return; } - - self.team = NUM_TEAM_4; // purple - spawnfunc_info_player_deathmatch(); +spawnfunc(info_player_team4) +{ + this.team = NUM_TEAM_4; // purple + spawnfunc_info_player_deathmatch(this); } // Returns: @@ -210,7 +215,6 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck) {SELFPARAM(); float shortest, thisdist; float prio; - entity player; prio = 0; @@ -235,12 +239,11 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck) } shortest = vlen(world.maxs - world.mins); - FOR_EACH_PLAYER(player) if (player != self) - { - thisdist = vlen(player.origin - spot.origin); + FOREACH_CLIENT(IS_PLAYER(it) && it != self, LAMBDA( + thisdist = vlen(it.origin - spot.origin); if (thisdist < shortest) shortest = thisdist; - } + )); if(shortest > mindist) prio += SPAWN_PRIO_GOOD_DISTANCE;