summaryrefslogtreecommitdiff
path: root/game/server/cstrike/bot/states/cs_bot_escape_from_bomb.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/server/cstrike/bot/states/cs_bot_escape_from_bomb.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/server/cstrike/bot/states/cs_bot_escape_from_bomb.cpp')
-rw-r--r--game/server/cstrike/bot/states/cs_bot_escape_from_bomb.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/game/server/cstrike/bot/states/cs_bot_escape_from_bomb.cpp b/game/server/cstrike/bot/states/cs_bot_escape_from_bomb.cpp
new file mode 100644
index 0000000..9abeb2b
--- /dev/null
+++ b/game/server/cstrike/bot/states/cs_bot_escape_from_bomb.cpp
@@ -0,0 +1,67 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+// Author: Michael S. Booth ([email protected]), 2003
+
+#include "cbase.h"
+#include "cs_bot.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+//--------------------------------------------------------------------------------------------------------------
+/**
+ * Escape from the bomb.
+ */
+void EscapeFromBombState::OnEnter( CCSBot *me )
+{
+ me->StandUp();
+ me->Run();
+ me->DestroyPath();
+ me->EquipKnife();
+}
+
+//--------------------------------------------------------------------------------------------------------------
+/**
+ * Escape from the bomb.
+ */
+void EscapeFromBombState::OnUpdate( CCSBot *me )
+{
+ const Vector *bombPos = me->GetGameState()->GetBombPosition();
+
+ // if we don't know where the bomb is, we shouldn't be in this state
+ if (bombPos == NULL)
+ {
+ me->Idle();
+ return;
+ }
+
+ // grab our knife to move quickly
+ me->EquipKnife();
+
+ // look around
+ me->UpdateLookAround();
+
+ if (me->UpdatePathMovement() != CCSBot::PROGRESSING)
+ {
+ // we have no path, or reached the end of one - create a new path far away from the bomb
+ FarAwayFromPositionFunctor func( *bombPos );
+ CNavArea *goalArea = FindMinimumCostArea( me->GetLastKnownArea(), func );
+
+ // if this fails, we'll try again next time
+ me->ComputePath( goalArea->GetCenter(), FASTEST_ROUTE );
+ }
+}
+
+//--------------------------------------------------------------------------------------------------------------
+/**
+ * Escape from the bomb.
+ */
+void EscapeFromBombState::OnExit( CCSBot *me )
+{
+ me->EquipBestWeapon();
+}