From 7c8995e3ccc4a2504891c7c52359e7817ebc25ea Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sat, 15 Oct 2011 14:37:26 +0200 Subject: [PATCH] move shotgun melee sound to CH_WEAPON_A; add bot_cmd setbots command to set bot count --- qcsrc/server/bot/bot.qc | 58 ++++++++++++++++++++++--------------- qcsrc/server/gamecommand.qc | 37 +++++++++++++++++++---- qcsrc/server/w_shotgun.qc | 2 +- 3 files changed, 66 insertions(+), 31 deletions(-) diff --git a/qcsrc/server/bot/bot.qc b/qcsrc/server/bot/bot.qc index 1b6d8eb4e..7bb507579 100644 --- a/qcsrc/server/bot/bot.qc +++ b/qcsrc/server/bot/bot.qc @@ -537,28 +537,10 @@ void bot_calculate_stepheightvec(void) // 0.75 factor is for safety to make the jumps easy } -void bot_serverframe() +float bot_fixcount() { - float realplayers, bots, activerealplayers; entity head; - - if (intermission_running) - return; - - if (time < 2) - return; - - bot_calculate_stepheightvec(); - bot_navigation_movemode = ((autocvar_bot_navigation_ignoreplayers) ? MOVE_NOMONSTERS : MOVE_NORMAL); - - if(time > autoskill_nextthink) - { - float a; - a = autocvar_skill_auto; - if(a) - autoskill(a); - autoskill_nextthink = time + 5; - } + float realplayers, bots, activerealplayers; activerealplayers = 0; realplayers = 0; @@ -597,8 +579,6 @@ void bot_serverframe() bots = 0; } - bot_ignore_bots = autocvar_bot_ignore_bots; - // only add one bot per frame to avoid utter chaos if(time > botframe_nextthink) { @@ -608,14 +588,44 @@ void bot_serverframe() if (bot_spawn() == world) { bprint("Can not add bot, server full.\n"); - botframe_nextthink = time + 10; - break; + return FALSE; } } while (currentbots > bots) bot_removenewest(); } + return TRUE; +} + +void bot_serverframe() +{ + if (intermission_running) + return; + + if (time < 2) + return; + + bot_calculate_stepheightvec(); + bot_navigation_movemode = ((autocvar_bot_navigation_ignoreplayers) ? MOVE_NOMONSTERS : MOVE_NORMAL); + + if(time > autoskill_nextthink) + { + float a; + a = autocvar_skill_auto; + if(a) + autoskill(a); + autoskill_nextthink = time + 5; + } + + if(time > botframe_nextthink) + { + if(!bot_fixcount()) + botframe_nextthink = time + 10; + } + + bot_ignore_bots = autocvar_bot_ignore_bots; + if(botframe_spawnedwaypoints) { if(autocvar_waypoint_benchmark) diff --git a/qcsrc/server/gamecommand.qc b/qcsrc/server/gamecommand.qc index d0c513a93..f5b662be3 100644 --- a/qcsrc/server/gamecommand.qc +++ b/qcsrc/server/gamecommand.qc @@ -1283,6 +1283,17 @@ void GameCommand(string command) return; } + // set bot count + if(argv(1) == "setbots") + { + if(argc >= 3 && argv(1) == "setbots") + { + cvar_settemp("minplayers", "0"); + cvar_settemp("bot_number", argv(2)); + bot_fixcount(); + } + } + // Load cmds from file if(argv(1) == "load" && argc == 3) { @@ -1301,12 +1312,26 @@ void GameCommand(string command) if(argc >= 3 && argv(0) == "sv_cmd" && argv(1) == "bot_cmd") { - // let's start at token 2 so we can skip sv_cmd bot_cmd - bot = find_bot_by_number(stof(argv(2))); - if(bot == world) - bot = find_bot_by_name(argv(2)); - if(bot) - bot_queuecommand(bot, strcat(argv(3), " ", argv(4))); + if(argv(2) == "reset") + { + bot_resetqueues(); + } + else if(argv(2) == "setbots") + { + cvar_settemp("minplayers", "0"); + cvar_settemp("bot_number", argv(3)); + if(!bot_fixcount()) + print("Sorry, could not set requested bot count\n"); + } + else + { + // let's start at token 2 so we can skip sv_cmd bot_cmd + bot = find_bot_by_number(stof(argv(2))); + if(bot == world) + bot = find_bot_by_name(argv(2)); + if(bot) + bot_queuecommand(bot, strcat(argv(3), " ", argv(4))); + } } else localcmd(strcat(s, "\n")); diff --git a/qcsrc/server/w_shotgun.qc b/qcsrc/server/w_shotgun.qc index 7130599de..2be9e44a6 100644 --- a/qcsrc/server/w_shotgun.qc +++ b/qcsrc/server/w_shotgun.qc @@ -142,7 +142,7 @@ void shotgun_meleethink (void) void W_Shotgun_Attack2 (void) { - sound (self, CH_SHOTS, "weapons/shotgun_melee.wav", VOL_BASE, ATTN_NORM); + sound (self, CH_WEAPON_A, "weapons/shotgun_melee.wav", VOL_BASE, ATTN_NORM); weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_shotgun_secondary_animtime, w_ready); entity meleetemp; -- 2.39.2