From bb20bbeaf6ced164cb1a33b4181fc2c9113dabc7 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 2 May 2021 14:17:55 +0200 Subject: [PATCH] Fix Instant Action mode not always applying the correct (random) number of bots if started while playing the campaign: * example where cvar_set doesn't work: start Xonotic, set bot_number to 0, start a campaign level, start an Instant Action game: bot_number is set to 0 * example where cvar_set works: start an Instant Action game twice, start a campaign level, start an Instant Action game: bot_number is correctly set --- qcsrc/menu/xonotic/dialog_singleplayer.qc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qcsrc/menu/xonotic/dialog_singleplayer.qc b/qcsrc/menu/xonotic/dialog_singleplayer.qc index c490b699c2..509a620623 100644 --- a/qcsrc/menu/xonotic/dialog_singleplayer.qc +++ b/qcsrc/menu/xonotic/dialog_singleplayer.qc @@ -100,7 +100,10 @@ void InstantAction_LoadMap(entity btn, entity dummy) pmin = pstep * ceil(pmin / pstep); pmax = pstep * floor(pmax / pstep); p = pmin + pstep * floor(random() * ((pmax - pmin) / pstep + 1)); - cvar_set("bot_number", ftos(p - 1)); + + // cvar_set doesn't always work starting an InstantAction game while playing the campaign + //cvar_set("bot_number", ftos(p - 1)); + localcmd(strcat("bot_number ", ftos(p - 1), "\n")); // make sure we go back to menu cvar_set("lastlevel", "1"); -- 2.39.2