From 091b54fc985360297f89563a3c4a5f4fd2c4734a Mon Sep 17 00:00:00 2001 From: ineed bots Date: Mon, 27 Nov 2023 19:57:59 -0600 Subject: [PATCH] fix it --- maps/mp/bots/_bot.gsc | 3 +++ maps/mp/bots/_bot_utility.gsc | 20 ++++++++++++++++++++ scripts/bots_adapter.gsc | 7 ------- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/maps/mp/bots/_bot.gsc b/maps/mp/bots/_bot.gsc index 5ef525c..fb4aca1 100644 --- a/maps/mp/bots/_bot.gsc +++ b/maps/mp/bots/_bot.gsc @@ -23,6 +23,9 @@ init() if ( !getDvarInt( "bots_main" ) ) return; + if ( !wait_for_builtins() ) + PrintLn( "FATAL: NO BUILT-INS FOR BOTS" ); + thread load_waypoints(); thread hook_callbacks(); diff --git a/maps/mp/bots/_bot_utility.gsc b/maps/mp/bots/_bot_utility.gsc index 61a80f3..a129695 100644 --- a/maps/mp/bots/_bot_utility.gsc +++ b/maps/mp/bots/_bot_utility.gsc @@ -6,6 +6,7 @@ Notes for engine obv the old bot behavior should be changed to use gsc built-ins to control bots + bots using objects needs to be fixed setSpawnWeapon and switchToWeapon should be modified to work for testclients */ @@ -13,6 +14,25 @@ #include maps\mp\_utility; #include maps\mp\gametypes\_hud_util; +/* + Waits for the built-ins to be defined +*/ +wait_for_builtins() +{ + for ( i = 0; i < 20; i++ ) + { + if ( isDefined( level.bot_builtins ) ) + return true; + + if ( i < 18 ) + waittillframeend; + else + wait 0.05; + } + + return false; +} + /* Prints to console without dev script on */ diff --git a/scripts/bots_adapter.gsc b/scripts/bots_adapter.gsc index 88c90c7..c59cda2 100644 --- a/scripts/bots_adapter.gsc +++ b/scripts/bots_adapter.gsc @@ -1,12 +1,5 @@ init() { - thread setup_builtins(); -} - -setup_builtins() -{ - waittillframeend; - level.bot_builtins["printconsole"] = ::do_printconsole; level.bot_builtins["filewrite"] = ::do_filewrite; level.bot_builtins["fileread"] = ::do_fileread;