From: Mattia Basaglia Date: Sun, 19 Mar 2017 17:32:24 +0000 (+0000) Subject: Prevent bots from picking up items on single player X-Git-Url: http://git.xonotic.org/?a=commitdiff_plain;h=07bacbcbca8856acd0e72e51764582802d64139a;hp=90d60e8f1469e880a99c385b218ff472fc200b10;p=xonotic%2Fxonotic-data.pk3dir.git Prevent bots from picking up items on single player --- diff --git a/gamemodes.cfg b/gamemodes.cfg index 261032110..e0f66ffa1 100644 --- a/gamemodes.cfg +++ b/gamemodes.cfg @@ -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" diff --git a/qcsrc/server/mutators/mutator/gamemode_singleplayer.qc b/qcsrc/server/mutators/mutator/gamemode_singleplayer.qc index e75b5e316..8e71aaa23 100644 --- a/qcsrc/server/mutators/mutator/gamemode_singleplayer.qc +++ b/qcsrc/server/mutators/mutator/gamemode_singleplayer.qc @@ -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; +}