ReGameDLL_CS/regamedll/dlls/bot/states/cs_bot_defuse_bomb.cpp
s1lentq 3d252fe527 Refactoring and cleanup.
Fixed some critical bugs and typos (carrer_task, tutor, zbot and other)
Added command line option `-bots` to run bots in CS 1.6
Removed the tests demo record/player from myself the project and also dependency of the steam library.
Fixed the progress bar when generating a nav file.
2016-02-23 05:23:45 +06:00

63 lines
1.4 KiB
C++

#include "precompiled.h"
// Begin defusing the bomb
void DefuseBombState::__MAKE_VHOOK(OnEnter)(CCSBot *me)
{
me->Crouch();
me->SetDisposition(CCSBot::SELF_DEFENSE);
me->GetChatter()->Say("DefusingBomb");
}
// Defuse the bomb
void DefuseBombState::__MAKE_VHOOK(OnUpdate)(CCSBot *me)
{
const Vector *bombPos = me->GetGameState()->GetBombPosition();
if (bombPos == NULL)
{
me->PrintIfWatched("In Defuse state, but don't know where the bomb is!\n");
me->Idle();
return;
}
// look at the bomb
me->SetLookAt("Defuse bomb", bombPos, PRIORITY_HIGH);
// defuse...
me->UseEnvironment();
if (gpGlobals->time - me->GetStateTimestamp() > 1.0f)
{
// if we missed starting the defuse, give up
if (TheCSBots()->GetBombDefuser() == NULL)
{
me->PrintIfWatched("Failed to start defuse, giving up\n");
me->Idle();
return;
}
else if (TheCSBots()->GetBombDefuser() != me)
{
// if someone else got the defuse, give up
me->PrintIfWatched("Someone else started defusing, giving up\n");
me->Idle();
return;
}
}
// if bomb has been defused, give up
if (!TheCSBots()->IsBombPlanted())
{
me->Idle();
return;
}
}
void DefuseBombState::__MAKE_VHOOK(OnExit)(CCSBot *me)
{
me->StandUp();
me->ResetStuckMonitor();
me->SetTask(CCSBot::SEEK_AND_DESTROY);
me->SetDisposition(CCSBot::ENGAGE_AND_INVESTIGATE);
me->ClearLookAt();
}