From b7653094d3a0d0eb22d96fcbe96832b98ff7e59e Mon Sep 17 00:00:00 2001 From: ineedbots Date: Sun, 25 Jul 2021 23:15:42 -0600 Subject: [PATCH] revive --- raw/maps/mp/bots/_bot_script.gsc | 70 +++++++++++++++++++++++++++++++ raw/maps/mp/bots/_bot_utility.gsc | 8 ++++ 2 files changed, 78 insertions(+) diff --git a/raw/maps/mp/bots/_bot_script.gsc b/raw/maps/mp/bots/_bot_script.gsc index 0463d63..14a4a27 100644 --- a/raw/maps/mp/bots/_bot_script.gsc +++ b/raw/maps/mp/bots/_bot_script.gsc @@ -6892,11 +6892,81 @@ bot_dem_defend_spawnkill() self notify( "bad_path" ); } +/* + Bots think to revive +*/ +bot_think_revive_loop() +{ + needsRevives = []; + + for ( i = 0; i < level.players.size; i++ ) + { + player = level.players[i]; + + if ( player.team != self.team ) + continue; + + if ( distanceSquared( self.origin, player.origin ) >= 2048 * 2048 ) + continue; + + if ( player inLastStand() ) + needsRevives[needsRevives.size] = player; + } + + if ( !needsRevives.size ) + return; + + revive = random( needsRevives ); + self.bot_lock_goal = true; + + self SetScriptGoal( revive.origin, 64 ); + self thread stop_go_target_on_death( revive ); + + ret = self waittill_any_return( "new_goal", "goal", "bad_path" ); + + if ( ret != "new_goal" ) + self ClearScriptGoal(); + + self.bot_lock_goal = false; + + if ( ret != "goal" || !isDefined(revive) || distanceSquared(self.origin, revive.origin) >= 100 * 100 || !revive inLastStand() || revive isBeingRevived() || !isAlive(revive) ) + return; + + waitTime = 3.25; + self thread BotPressUse( waitTime ); + wait waitTime; +} + /* Bots think to revive */ bot_think_revive() { + self endon( "death" ); + self endon( "disconnect" ); + level endon( "game_ended" ); + + if ( !level.dieHardMode || !level.teamBased ) + return; + + for ( ;; ) + { + wait( randomintrange( 1, 3 ) ); + + if ( self HasScriptGoal() || self.bot_lock_goal ) + continue; + + if ( self isDefusing() || self isPlanting() ) + continue; + + if ( self IsUsingRemote() || self BotIsFrozen() ) + continue; + + if ( self inLastStand() ) + continue; + + self bot_think_revive_loop(); + } } /* diff --git a/raw/maps/mp/bots/_bot_utility.gsc b/raw/maps/mp/bots/_bot_utility.gsc index 3cb2573..b20095c 100644 --- a/raw/maps/mp/bots/_bot_utility.gsc +++ b/raw/maps/mp/bots/_bot_utility.gsc @@ -398,6 +398,14 @@ inLastStand() return ( isDefined( self.lastStand ) && self.lastStand ); } +/* + Is being revived +*/ +isBeingRevived() +{ + return ( isDefined( self.beingRevived ) && self.beingRevived ); +} + /* If the player is in final stand */