From 2fd21a3e18b9815ccd263334ff75a51ba4e50686 Mon Sep 17 00:00:00 2001 From: ineedbots Date: Tue, 7 Sep 2021 14:44:49 -0600 Subject: [PATCH] bot threads --- mods/bots/maps/mp/bots/_bot_script.gsc | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/mods/bots/maps/mp/bots/_bot_script.gsc b/mods/bots/maps/mp/bots/_bot_script.gsc index e33b43e..aaf9100 100644 --- a/mods/bots/maps/mp/bots/_bot_script.gsc +++ b/mods/bots/maps/mp/bots/_bot_script.gsc @@ -25,6 +25,8 @@ connected() self thread difficulty(); self thread teamWatch(); self thread classWatch(); + self thread onBotSpawned(); + self thread onSpawned(); } /* @@ -528,3 +530,49 @@ classWatch() wait .05; } } + +/* + When the bot spawns. +*/ +onSpawned() +{ + self endon( "disconnect" ); + + for ( ;; ) + { + self waittill( "spawned_player" ); + + if ( randomInt( 100 ) <= self.pers["bots"]["behavior"]["class"] ) + self.bot_change_class = undefined; + + self.bot_lock_goal = false; + self.help_time = undefined; + self.bot_was_follow_script_update = undefined; + } +} + +/* + When the bot spawned, after the difficulty wait. Start the logic for the bot. +*/ +onBotSpawned() +{ + self endon( "disconnect" ); + level endon( "game_ended" ); + + for ( ;; ) + { + self waittill( "bot_spawned" ); + + self thread start_bot_threads(); + } +} + +/* + Starts all the bot thinking +*/ +start_bot_threads() +{ + self endon( "disconnect" ); + level endon( "game_ended" ); + self endon( "death" ); +}