diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/server/cstrike/bot/states/cs_bot_fetch_bomb.cpp | |
| download | archived-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_fetch_bomb.cpp')
| -rw-r--r-- | game/server/cstrike/bot/states/cs_bot_fetch_bomb.cpp | 69 |
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(); +} |