From 5aec8aac7ec8af2d4390c835240c9859b62e6a9d Mon Sep 17 00:00:00 2001 From: Vaqtincha <51029683+Vaqtincha@users.noreply.github.com> Date: Wed, 1 Sep 2021 01:17:28 +0500 Subject: [PATCH] Bot fixes (#659) * Bots only attack breakable objects * Fix reversing-engineering mistake --- regamedll/dlls/bot/cs_bot.cpp | 9 +++++++++ regamedll/dlls/bot/cs_bot_event.cpp | 8 +++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/regamedll/dlls/bot/cs_bot.cpp b/regamedll/dlls/bot/cs_bot.cpp index 660dc71bf..b0a484724 100644 --- a/regamedll/dlls/bot/cs_bot.cpp +++ b/regamedll/dlls/bot/cs_bot.cpp @@ -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(pOther); + + // Material is "UnbreakableGlass" + if (!pBreak->IsBreakable()) + return; +#endif + Vector center = (pOther->pev->absmax + pOther->pev->absmin) / 2.0f; bool breakIt = true; diff --git a/regamedll/dlls/bot/cs_bot_event.cpp b/regamedll/dlls/bot/cs_bot_event.cpp index 0c3fb6e69..199616659 100644 --- a/regamedll/dlls/bot/cs_bot_event.cpp +++ b/regamedll/dlls/bot/cs_bot_event.cpp @@ -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(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));