Bot fixes (#659)

* Bots only attack breakable objects

* Fix reversing-engineering mistake
This commit is contained in:
Vaqtincha 2021-09-01 01:17:28 +05:00 committed by GitHub
parent 7e2279f8c5
commit 5aec8aac7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -295,6 +295,15 @@ void CCSBot::BotTouch(CBaseEntity *pOther)
// See if it's breakable
if (FClassnameIs(pOther->pev, "func_breakable"))
{
#ifdef REGAMEDLL_FIXES
CBreakable *pBreak = static_cast<CBreakable *>(pOther);
// Material is "UnbreakableGlass"
if (!pBreak->IsBreakable())
return;
#endif
Vector center = (pOther->pev->absmax + pOther->pev->absmin) / 2.0f;
bool breakIt = true;

View File

@ -69,16 +69,18 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOt
{
if (event == EVENT_PLAYER_DIED)
{
if (BotRelationship(pPlayer) == BOT_TEAMMATE)
CBasePlayer *pVictim = pPlayer;
if (BotRelationship(pVictim) == BOT_TEAMMATE)
{
CBasePlayer *pKiller = static_cast<CBasePlayer *>(pOther);
// check that attacker is an enemy (for friendly fire, etc)
if (pKiller && pKiller->IsPlayer())
if (pKiller && pKiller->IsPlayer() && BotRelationship(pKiller) == BOT_ENEMY)
{
// check if we saw our friend die - dont check FOV - assume we're aware of our surroundings in combat
// snipers stay put
if (!IsSniper() && IsVisible(&pPlayer->pev->origin))
if (!IsSniper() && IsVisible(&pVictim->pev->origin))
{
// people are dying - we should hurry
Hurry(RANDOM_FLOAT(10.0f, 15.0f));