ReGameDLL_CS/regamedll/dlls/bot/states/cs_bot_plant_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

56 lines
1.4 KiB
C++

#include "precompiled.h"
// Plant the bomb.
void PlantBombState::__MAKE_VHOOK(OnEnter)(CCSBot *me)
{
me->Crouch();
me->SetDisposition(CCSBot::SELF_DEFENSE);
float yaw = me->pev->v_angle.y;
Vector2D dir(BotCOS(yaw), BotSIN(yaw));
Vector down(me->pev->origin.x + 10.0f * dir.x, me->pev->origin.y + 10.0f * dir.y, me->GetFeetZ());
me->SetLookAt("Plant bomb on floor", &down, PRIORITY_HIGH);
}
// Plant the bomb.
void PlantBombState::__MAKE_VHOOK(OnUpdate)(CCSBot *me)
{
CBasePlayerWeapon *gun = me->GetActiveWeapon();
bool holdingC4 = false;
if (gun != NULL)
{
if (FStrEq(STRING(gun->pev->classname), "weapon_c4"))
holdingC4 = true;
}
// if we aren't holding the C4, grab it, otherwise plant it
if (holdingC4)
me->PrimaryAttack();
else
me->SelectItem("weapon_c4");
// if we no longer have the C4, we've successfully planted
if (!me->IsCarryingBomb())
{
// move to a hiding spot and watch the bomb
me->SetTask(CCSBot::GUARD_TICKING_BOMB);
me->Hide();
}
// if we time out, it's because we slipped into a non-plantable area
const float timeout = 5.0f;
if (gpGlobals->time - me->GetStateTimestamp() > timeout)
me->Idle();
}
void PlantBombState::__MAKE_VHOOK(OnExit)(CCSBot *me)
{
// equip our rifle (in case we were interrupted while holding C4)
me->EquipBestWeapon();
me->StandUp();
me->ResetStuckMonitor();
me->SetDisposition(CCSBot::ENGAGE_AND_INVESTIGATE);
me->ClearLookAt();
}