]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Prevent bots from picking up items on single player
authorMattia Basaglia <mattia.basaglia@gmail.com>
Sun, 19 Mar 2017 17:32:24 +0000 (17:32 +0000)
committerMattia Basaglia <mattia.basaglia@gmail.com>
Sun, 19 Mar 2017 17:32:24 +0000 (17:32 +0000)
gamemodes.cfg
qcsrc/server/mutators/mutator/gamemode_singleplayer.qc

index 2610321109b1f14109a559393e92d7e1527366ae..e0f66ffa188931a56e13734808f912afc3032c2e 100644 (file)
@@ -563,3 +563,8 @@ set g_invasion_spawn_delay 0.25
 set g_invasion_spawnpoint_spawn_delay 0.5
 set g_invasion_teams 0 "number of teams in invasion (note: use mapinfo to set this)"
 set g_invasion_team_spawns 1 "use team spawns in teamplay invasion mode"
+
+// ==============
+// Single Player
+// ==============
+set g_sp_allow_bot_pickup 0 "Whether bots should be allowed to pick up items"
index e75b5e3169c163a9be5b0b465c2071e03f661767..8e71aaa23d2873d286bae834becc9f8994cbccce 100644 (file)
@@ -9,6 +9,8 @@ const int SP_TEAM_ENEMY = NUM_TEAM_2;
 .entity sp_spawn_spot;
 .bool can_respawn;
 
+bool autocvar_g_sp_allow_bot_pickup;
+
 int sp_bot_number;
 
 /*QUAKED spawnfunc_tdm_team (0 .5 .8) (-16 -16 -24) (16 16 32)
@@ -33,7 +35,6 @@ void sp_spawn_team_entity(string teamname, int teamcolor)
     this.cnt = teamcolor - 1;
     this.team = teamcolor;
     this.spawnfunc_checked = true;
-    //spawnfunc_sp_team(this);
 }
 
 // spawnfuncs
@@ -222,3 +223,21 @@ MUTATOR_HOOKFUNCTION(sp, PlayerPreThink)
     if ( IS_BOT_CLIENT(player) && !player.sp_spawn_spot )
         bot_remove(player);
 }
+
+MUTATOR_HOOKFUNCTION(sp, ItemTouch)
+{
+    entity toucher = M_ARGV(1, entity);
+    if ( IS_BOT_CLIENT(toucher) && !autocvar_g_sp_allow_bot_pickup )
+        return MUT_ITEMTOUCH_RETURN;
+    return MUT_ITEMTOUCH_CONTINUE;
+}
+
+MUTATOR_HOOKFUNCTION(sp, Item_Spawn)
+{
+    entity item = M_ARGV(0, entity);
+    if ( !autocvar_g_sp_allow_bot_pickup )
+    {
+        item.bot_pickup = false;
+    }
+    return false;
+}