From 90eec289a16ffa1020474da61f4a838ccc55afcc Mon Sep 17 00:00:00 2001 From: ineed bots Date: Thu, 30 Nov 2023 03:19:54 -0600 Subject: [PATCH] add goal prio --- maps/mp/bots/_bot_internal.gsc | 6 ++++-- maps/mp/bots/_bot_utility.gsc | 26 ++++++++++++++++++++++++++ scripts/bots_adapter.gsc | 2 +- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/maps/mp/bots/_bot_internal.gsc b/maps/mp/bots/_bot_internal.gsc index 107e813..26ec2fb 100644 --- a/maps/mp/bots/_bot_internal.gsc +++ b/maps/mp/bots/_bot_internal.gsc @@ -159,6 +159,8 @@ resetBotVars() self.bot.cur_weap_dist_multi = 1; self.bot.is_cur_sniper = false; + self.bot.prio_objective = false; + self.bot.rand = randomInt( 100 ); self BotBuiltinBotStop(); @@ -1294,7 +1296,7 @@ aim_loop() aimspeed *= 1 + adsAimSpeedFact * adsAmount; } - if ( isDefined( self.bot.target ) && isDefined( self.bot.target.entity ) ) + if ( isDefined( self.bot.target ) && isDefined( self.bot.target.entity ) && !( self.bot.prio_objective && isDefined( self.bot.script_aimpos ) ) ) { no_trace_time = self.bot.target.no_trace_time; no_trace_look_time = self.pers["bots"]["skill"]["no_trace_look_time"]; @@ -1672,7 +1674,7 @@ killWalkCauseNoWaypoints() */ walk_loop() { - hasTarget = isDefined( self.bot.target ) && isDefined( self.bot.target.entity ); + hasTarget = isDefined( self.bot.target ) && isDefined( self.bot.target.entity ) && !self.bot.prio_objective; if ( hasTarget ) { diff --git a/maps/mp/bots/_bot_utility.gsc b/maps/mp/bots/_bot_utility.gsc index 80b58dd..0d2eee5 100644 --- a/maps/mp/bots/_bot_utility.gsc +++ b/maps/mp/bots/_bot_utility.gsc @@ -468,6 +468,32 @@ HasThreat() return ( isDefined( self GetThreat() ) ); } +/* + Returns whether the bot has a priority objective +*/ +HasPriorityObjective() +{ + return self.bot.prio_objective; +} + +/* + Sets the bot to prioritize the objective over targeting enemies +*/ +SetPriorityObjective() +{ + self.bot.prio_objective = true; + self notify( "kill_goal" ); +} + +/* + Clears the bot's priority objective to allow the bot to target enemies automatically again +*/ +ClearPriorityObjective() +{ + self.bot.prio_objective = false; + self notify( "kill_goal" ); +} + /* If the player is defusing */ diff --git a/scripts/bots_adapter.gsc b/scripts/bots_adapter.gsc index bfac81b..da8bb65 100644 --- a/scripts/bots_adapter.gsc +++ b/scripts/bots_adapter.gsc @@ -12,7 +12,7 @@ init() do_printconsole( s ) { - PrintConsole( s + "\n" ); + PrintConsole( s ); } do_filewrite( file, contents, mode )