]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Refine spawn point selection
authorMattia Basaglia <mattia.basaglia@gmail.com>
Sun, 19 Mar 2017 00:45:46 +0000 (00:45 +0000)
committerMattia Basaglia <mattia.basaglia@gmail.com>
Sun, 19 Mar 2017 00:45:46 +0000 (00:45 +0000)
qcsrc/common/mutators/mutator/spawn_near_teammate/sv_spawn_near_teammate.qc
qcsrc/server/mutators/mutator/gamemode_singleplayer.qc
qcsrc/server/spawnpoints.qc

index ee75728630e2e5623f988e1d7efaf7b31d9f37d7..c395f3e34c3570f1435b039282876415e7977062 100644 (file)
@@ -24,7 +24,10 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, Spawn_Score)
        entity spawn_spot = M_ARGV(1, entity);
        vector spawn_score = M_ARGV(2, vector);
 
-       if(autocvar_g_spawn_near_teammate_ignore_spawnpoint == 1 || (autocvar_g_spawn_near_teammate_ignore_spawnpoint == 2 && player.cvar_cl_spawn_near_teammate))
+       if(autocvar_g_spawn_near_teammate_ignore_spawnpoint == 1 ||
+               (autocvar_g_spawn_near_teammate_ignore_spawnpoint == 2 && player.cvar_cl_spawn_near_teammate) ||
+               IS_OBSERVER(player)
+       )
                return;
 
        spawn_spot.msnt_lookat = NULL;
index e2dd8ab5b794d88b12dd0bcf4804a95ecfdfaa22..7eb55aeb3edb2674bd43bd03e01831a46ccb7208 100644 (file)
@@ -1,5 +1,12 @@
 #include "gamemode_singleplayer.qh"
 
+const int SP_TEAM_PLAYER = NUM_TEAM_1;
+const int SP_TEAM_ENEMY = NUM_TEAM_2;
+
+.bool can_drop_weapon;
+.string weapon_name;
+.int sp_spawn_team;
+
 /*QUAKED spawnfunc_tdm_team (0 .5 .8) (-16 -16 -24) (16 16 32)
 Team declaration for TDM gameplay, this allows you to decide what team names and control point models are used in your map.
 Note: If you use spawnfunc_tdm_team entities you must define at least 2!  However, unlike domination, you don't need to make a blank one too.
@@ -25,13 +32,13 @@ void sp_SpawnTeam (string teamname, int teamcolor)
     //spawnfunc_sp_team(this);
 }
 
-
 // spawnfuncs
 spawnfunc(info_player_singleplayer)
 {
     if (!g_singleplayer) { delete(this); return; }
 
-    this.team = NUM_TEAM_1;
+    this.team = SP_TEAM_PLAYER;
+    this.sp_spawn_team = SP_TEAM_PLAYER;
     spawnfunc_info_player_deathmatch(this);
 }
 
@@ -39,7 +46,8 @@ spawnfunc(info_player_singleplayer_enemy)
 {
        if (!g_singleplayer) { delete(this); return; }
 
-       this.team = NUM_TEAM_2;
+       this.team = SP_TEAM_ENEMY;
+    this.sp_spawn_team = SP_TEAM_ENEMY;
        spawnfunc_info_player_deathmatch(this);
 }
 
@@ -50,14 +58,13 @@ void sp_DelayedInit(entity this)
     {
         LOG_TRACE("No \"sp_team\" entities found on this map, creating them anyway.");
 
-        sp_SpawnTeam("Player", NUM_TEAM_1);
-        sp_SpawnTeam("Enemy", NUM_TEAM_2);
+        sp_SpawnTeam("Player", SP_TEAM_PLAYER);
+        sp_SpawnTeam("Enemy", SP_TEAM_ENEMY);
     }
 }
 
 MUTATOR_HOOKFUNCTION(sp, CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
 {
-    LOG_TRACEF("\n==== here ====\n");
        M_ARGV(1, string) = "sp_team";
     entity ent = M_ARGV(2, entity);
     if ( IS_BOT_CLIENT(ent) )
@@ -68,8 +75,6 @@ MUTATOR_HOOKFUNCTION(sp, CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
     {
         ent.team_forced = NUM_TEAM_1;
     }
-    LOG_TRACEF("\n==== After processing ====\nent: %s\nteam: %d\n\n",
-               etos(ent), ent.team_forced);
     return true;
 }
 
@@ -78,10 +83,6 @@ MUTATOR_HOOKFUNCTION(sp, Scores_CountFragsRemaining)
     return false;
 }
 
-
-.bool can_drop_weapon;
-.string weapon_name;
-
 MUTATOR_HOOKFUNCTION(sp, PlayerSpawn)
 {
        entity player = M_ARGV(0, entity);
@@ -108,3 +109,28 @@ MUTATOR_HOOKFUNCTION(sp, ForbidDropCurrentWeapon)
     entity player = M_ARGV(0, entity);
     return !player.can_drop_weapon;
 }
+
+MUTATOR_HOOKFUNCTION(sp, CheckRules_World)
+{
+    M_ARGV(0, float) = WINNING_NO;
+    // TODO: conditions for WINNING_YES
+    return true;
+}
+
+MUTATOR_HOOKFUNCTION(sp, Spawn_Score)
+{
+    entity player = M_ARGV(0, entity);
+    entity spawn_spot = M_ARGV(1, entity);
+    vector spawn_score = M_ARGV(2, vector);
+    if ( IS_BOT_CLIENT(player) )
+    {
+        if ( spawn_spot.sp_spawn_team != SP_TEAM_ENEMY )
+            spawn_score.x = -1;
+    }
+    else if ( spawn_spot.sp_spawn_team != SP_TEAM_PLAYER )
+    {
+        spawn_score.x = -1;
+    }
+
+    M_ARGV(2, vector) = spawn_score;
+}
index 84819efbe1c6b51f407c9e9e9b509dcd82aab441..9e2ff1902c5aa48a61ddb649d735561df1e35bd3 100644 (file)
@@ -370,6 +370,7 @@ entity SelectSpawnPoint(entity this, bool anypoint)
        // (note this returns the original list if none survived)
        if(anypoint)
        {
+               firstspot = Spawn_FilterOutBadSpots(this, firstspot, 0, teamcheck);
                spot = Spawn_WeightedPoint(firstspot, 1, 1, 1);
        }
        else