From 5b5133a62972e5c49e98ae02a73e43a39ba47d4c Mon Sep 17 00:00:00 2001 From: ineed bots Date: Tue, 20 Jun 2023 13:57:20 -0600 Subject: [PATCH] some organization --- maps/bots/_bot.gsc | 22 +------ maps/bots/_bot_script.gsc | 53 +++------------- maps/bots/script_objectives/_obj_init.gsc | 75 +++++++++++++++++++++++ 3 files changed, 83 insertions(+), 67 deletions(-) create mode 100644 maps/bots/script_objectives/_obj_init.gsc diff --git a/maps/bots/_bot.gsc b/maps/bots/_bot.gsc index bda240e..f0ef4c3 100644 --- a/maps/bots/_bot.gsc +++ b/maps/bots/_bot.gsc @@ -120,7 +120,7 @@ init() level thread onPlayerConnect(); level thread handleBots(); - maps\bots\_bot_script::bot_script_init(); + level thread maps\bots\_bot_script::bot_script_init(); } /* @@ -161,22 +161,6 @@ onPlayerDamage( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, self [[level.prevCallbackPlayerDamage]]( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, modelIndex, psOffsetTime ); } -on_actor_spawned() -{ - if ( isDefined( level.prevCallbackActorSpawned ) ) - { - self [[ level.prevCallbackActorSpawned ]](); - } -} - -on_actor_killed( eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, iTimeOffset ) -{ - if ( isDefined( level.prevCallbackActorKilled ) ) - { - self [[ level.prevCallbackActorKilled ]]( eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, iTimeOffset ); - } -} - /* Starts the callbacks. */ @@ -185,10 +169,6 @@ hook_callbacks() wait 0.05; level.prevCallbackPlayerDamage = level.callbackPlayerDamage; level.callbackPlayerDamage = ::onPlayerDamage; - level.prevCallbackActorSpawned = level.callbackActorSpawned; - level.callbackActorSpawned = ::on_actor_spawned; - level.prevCallbackActorKilled = level.callbackActorKilled; - level.callbackActorKilled = ::on_actor_killed; } /* diff --git a/maps/bots/_bot_script.gsc b/maps/bots/_bot_script.gsc index 59b2518..a2cec3c 100644 --- a/maps/bots/_bot_script.gsc +++ b/maps/bots/_bot_script.gsc @@ -1,42 +1,13 @@ #include common_scripts\utility; #include maps\_utility; #include maps\bots\_bot_utility; -#include maps\bots\script_objectives\_obj_actions; -#include maps\bots\script_objectives\_obj_common; -#include maps\bots\script_objectives\_obj_trackers; /* Initialize bot script level functions */ bot_script_init() { - //maps\bots\script_objectives\_obj_common; - //maps\bots\script_objectives\_obj_actions; - register_bot_action( "objective", "powerup", ::bot_grab_powerup, - ::bot_powerup_process_order, - ::bot_powerup_init, - ::bot_powerup_post_think, - ::bot_should_grab_powerup, - ::bot_check_complete_grab_powerup, - ::bot_powerup_should_cancel, - ::bot_powerup_should_postpone, - ::bot_powerup_priority ); - - register_bot_action( "objective", "revive", ::bot_revive_player, - ::bot_revive_process_order, - ::bot_revive_player_init, - ::bot_revive_player_post_think, - ::bot_should_revive_player, - ::bot_check_complete_revive_player, - ::bot_revive_player_should_cancel, - ::bot_revive_player_should_postpone, - ::bot_revive_player_priority ); - register_bot_objective( "powerup" ); - register_bot_objective( "revive" ); - - //maps\bots\script_objectives\_obj_trackers; - level thread store_powerups_dropped(); - level thread watch_for_downed_players(); + level thread maps\bots\script_objectives\_obj_init::init(); } /* @@ -59,15 +30,8 @@ connected() self thread difficulty(); self thread onBotSpawned(); self thread onSpawned(); - self thread initialize_bot_actions_queue(); - self thread bot_valid_pump(); - //self thread bot_objective_inaccessible_pump(); - self.on_powerup_grab_func = ::bot_on_powerup_grab; - self.on_revive_success_func = ::bot_on_revive_success; - - self.obj_postponed_reason = ""; - self.obj_cancel_reason = ""; + self thread maps\bots\script_objectives\_obj_init::connected(); } /* @@ -402,9 +366,11 @@ onSpawned() for ( ;; ) { self waittill( "spawned_player" ); - self thread bot_action_think(); + self.bot_lock_goal = false; self.bot_was_follow_script_update = undefined; + + self thread maps\bots\script_objectives::spawned(); } } @@ -416,11 +382,6 @@ start_bot_threads() self endon( "disconnect" ); level endon( "intermission" ); self endon( "zombified" ); -} -//TODO: Add ability to pause an action so the bot won't be doing it while its paused but when its unpaused they can resume the action with the same settings -//Similar to postpone except instead of selecting a new action the current action is preserved -action_should_be_paused_global( primary_group_name, action_name ) -{ - return false; -} \ No newline at end of file + self thread maps\bots\script_objectives::start_bot_threads(); +} diff --git a/maps/bots/script_objectives/_obj_init.gsc b/maps/bots/script_objectives/_obj_init.gsc new file mode 100644 index 0000000..358b1e4 --- /dev/null +++ b/maps/bots/script_objectives/_obj_init.gsc @@ -0,0 +1,75 @@ +#include common_scripts\utility; +#include maps\_utility; +#include maps\bots\_bot_utility; +#include maps\bots\script_objectives\_obj_common; +#include maps\bots\script_objectives\_obj_actions; +#include maps\bots\script_objectives\_obj_trackers; + +init() +{ + //maps\bots\script_objectives\_obj_common; + //maps\bots\script_objectives\_obj_actions; + register_bot_action( "objective", "powerup", ::bot_grab_powerup, + ::bot_powerup_process_order, + ::bot_powerup_init, + ::bot_powerup_post_think, + ::bot_should_grab_powerup, + ::bot_check_complete_grab_powerup, + ::bot_powerup_should_cancel, + ::bot_powerup_should_postpone, + ::bot_powerup_priority ); + + register_bot_action( "objective", "revive", ::bot_revive_player, + ::bot_revive_process_order, + ::bot_revive_player_init, + ::bot_revive_player_post_think, + ::bot_should_revive_player, + ::bot_check_complete_revive_player, + ::bot_revive_player_should_cancel, + ::bot_revive_player_should_postpone, + ::bot_revive_player_priority ); + register_bot_objective( "powerup" ); + register_bot_objective( "revive" ); + + //maps\bots\script_objectives\_obj_trackers; + level thread store_powerups_dropped(); + level thread watch_for_downed_players(); +} + +connected() +{ + self endon( "disconnect" ); + + self thread initialize_bot_actions_queue(); + self thread bot_valid_pump(); + //self thread bot_objective_inaccessible_pump(); + + self.on_powerup_grab_func = ::bot_on_powerup_grab; + self.on_revive_success_func = ::bot_on_revive_success; + + self.obj_postponed_reason = ""; + self.obj_cancel_reason = ""; +} + +spawned() +{ + self endon( "disconnect" ); + level endon( "intermission" ); + self endon( "zombified" ); + + self thread bot_action_think(); +} + +start_bot_threads() +{ + self endon( "disconnect" ); + level endon( "intermission" ); + self endon( "zombified" ); +} + +//TODO: Add ability to pause an action so the bot won't be doing it while its paused but when its unpaused they can resume the action with the same settings +//Similar to postpone except instead of selecting a new action the current action is preserved +action_should_be_paused_global( primary_group_name, action_name ) +{ + return false; +}