Skip to content

Commit

Permalink
Bot fixes (#659)
Browse files Browse the repository at this point in the history
* Bots only attack breakable objects

* Fix reversing-engineering mistake
  • Loading branch information
Vaqtincha authored Aug 31, 2021
1 parent 7e2279f commit 5aec8aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 9 additions & 0 deletions regamedll/dlls/bot/cs_bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 5 additions & 3 deletions regamedll/dlls/bot/cs_bot_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 5aec8aa

Please sign in to comment.