summaryrefslogtreecommitdiff
path: root/game/server/cstrike/bot/states/cs_bot_fetch_bomb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'game/server/cstrike/bot/states/cs_bot_fetch_bomb.cpp')
-rw-r--r--game/server/cstrike/bot/states/cs_bot_fetch_bomb.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/game/server/cstrike/bot/states/cs_bot_fetch_bomb.cpp b/game/server/cstrike/bot/states/cs_bot_fetch_bomb.cpp
new file mode 100644
index 0000000..6e78019
--- /dev/null
+++ b/game/server/cstrike/bot/states/cs_bot_fetch_bomb.cpp
@@ -0,0 +1,69 @@
+//========= 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"
+
+
+//--------------------------------------------------------------------------------------------------------------
+/**
+ * Move to the bomb on the floor and pick it up
+ */
+void FetchBombState::OnEnter( CCSBot *me )
+{
+ me->DestroyPath();
+}
+
+//--------------------------------------------------------------------------------------------------------------
+/**
+ * Move to the bomb on the floor and pick it up
+ */
+void FetchBombState::OnUpdate( CCSBot *me )
+{
+ if (me->HasC4())
+ {
+ me->PrintIfWatched( "I picked up the bomb\n" );
+ me->Idle();
+ return;
+ }
+
+
+ CBaseEntity *bomb = TheCSBots()->GetLooseBomb();
+ if (bomb)
+ {
+ if (!me->HasPath())
+ {
+ // build a path to the bomb
+ if (me->ComputePath( bomb->GetAbsOrigin() ) == false)
+ {
+ me->PrintIfWatched( "Fetch bomb pathfind failed\n" );
+
+ // go Hunt instead of Idle to prevent continuous re-pathing to inaccessible bomb
+ me->Hunt();
+ return;
+ }
+ }
+ }
+ else
+ {
+ // someone picked up the bomb
+ me->PrintIfWatched( "Someone else picked up the bomb.\n" );
+ me->Idle();
+ return;
+ }
+
+ // look around
+ me->UpdateLookAround();
+
+ if (me->UpdatePathMovement() != CCSBot::PROGRESSING)
+ me->Idle();
+}