]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/spawnpoints.qc
Merge remote-tracking branch 'origin/Mario/arena_nuke'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / spawnpoints.qc
index c0846b74279f8042d4c745b0b36afcab8b2f2e7a..3f4e72c3b3f584b67c0cc4de06f9f033d568f6db 100644 (file)
@@ -1,13 +1,39 @@
-float Spawn_Send(entity to, float sf)
+float SpawnPoint_Send(entity to, float sf)
 {
        WriteByte(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);
+
        return TRUE;
 }
 
+float SpawnEvent_Send(entity to, float sf)
+{
+       float send;
+
+       WriteByte(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);
+               send = TRUE;
+       }
+       else if((to == self.owner) || (IS_SPEC(to) && (to.enemy == self.owner)) )
+       {
+               WriteByte(MSG_ENTITY, 0);
+               send = TRUE;
+       }
+       else { send = FALSE; }
+
+       return send;
+}
+
 void spawnpoint_use()
 {
        if(teamplay)
@@ -16,6 +42,7 @@ void spawnpoint_use()
                self.team = activator.team;
                some_spawn_has_been_used = 1;
        }
+       print("spawnpoint was used!\n");
 }
 
 void relocate_spawnpoint()
@@ -73,10 +100,34 @@ void relocate_spawnpoint()
         e.solid = SOLID_TRIGGER;
     }
 
-       //self.think = Spawn_Send_Think;
-       //self.nextthink = time;
-
-    Net_LinkEntity(self, FALSE, 0, Spawn_Send);
+       // Don't show team spawns in non-team matches,
+       // and don't show non-team spawns in team matches.
+       // (Unless useallspawns is activated)
+       if(
+               !(
+                       ( // 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)
+                       )
+                       ||
+                       ( // 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)
+                               )
+                       )
+               )
+               ||
+               autocvar_g_spawn_useallspawns
+       )
+       { Net_LinkEntity(self, FALSE, 0, SpawnPoint_Send); }
 }
 
 void spawnfunc_info_player_survivor (void)
@@ -115,7 +166,7 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
                if(spot.target == "")
                        return '-1 0 0';
 
-       if(clienttype(self) == CLIENTTYPE_REAL)
+       if(IS_REAL_CLIENT(self))
        {
                if(spot.restriction == 1)
                        return '-1 0 0';
@@ -267,12 +318,7 @@ entity SelectSpawnPoint (float anypoint)
        }
        else
        {
-               float mindist;
-               if (arena_roundbased && !g_ca)
-                       mindist = 800;
-               else
-                       mindist = 100;
-               firstspot = Spawn_FilterOutBadSpots(firstspot, mindist, teamcheck);
+               firstspot = Spawn_FilterOutBadSpots(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