From 64df2f96585d0ca9a728a9b3adc122e0f31507c9 Mon Sep 17 00:00:00 2001 From: Vaqtincha Date: Tue, 8 Jun 2021 22:58:12 +0500 Subject: [PATCH] Bots only attack breakable objects --- regamedll/dlls/bot/cs_bot.cpp | 38 ++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/regamedll/dlls/bot/cs_bot.cpp b/regamedll/dlls/bot/cs_bot.cpp index 660dc71bf..42fc79433 100644 --- a/regamedll/dlls/bot/cs_bot.cpp +++ b/regamedll/dlls/bot/cs_bot.cpp @@ -295,27 +295,33 @@ void CCSBot::BotTouch(CBaseEntity *pOther) // See if it's breakable if (FClassnameIs(pOther->pev, "func_breakable")) { - Vector center = (pOther->pev->absmax + pOther->pev->absmin) / 2.0f; - bool breakIt = true; - - if (m_pathLength) - { - Vector goal = m_goalPosition + Vector(0, 0, HalfHumanHeight); - breakIt = IsIntersectingBox(pev->origin, goal, pOther->pev->absmin, pOther->pev->absmax); - } - - if (breakIt) +#ifdef REGAMEDLL_FIXES + // Is breakable ? spawnflags has SF_BREAK_TRIGGER_ONLY or material type matUnbreakableGlass + if (pOther->pev->takedamage != DAMAGE_NO || !(pOther->pev->flags |= FL_WORLDBRUSH)) +#endif { - // it's breakable - try to shoot it. - SetLookAt("Breakable", ¢er, PRIORITY_HIGH, 0.2, 0, 5.0); + Vector center = (pOther->pev->absmax + pOther->pev->absmin) / 2.0f; + bool breakIt = true; - if (IsUsingGrenade()) + if (m_pathLength) { - EquipBestWeapon(); - return; + Vector goal = m_goalPosition + Vector(0, 0, HalfHumanHeight); + breakIt = IsIntersectingBox(pev->origin, goal, pOther->pev->absmin, pOther->pev->absmax); } - PrimaryAttack(); + if (breakIt) + { + // it's breakable - try to shoot it. + SetLookAt("Breakable", ¢er, PRIORITY_HIGH, 0.2, 0, 5.0); + + if (IsUsingGrenade()) + { + EquipBestWeapon(); + return; + } + + PrimaryAttack(); + } } } }