Skip to content

Commit

Permalink
refactoring code
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaqtincha committed Jun 9, 2021
1 parent 64df2f9 commit 3f0ca82
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions regamedll/dlls/bot/cs_bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,32 +296,33 @@ void CCSBot::BotTouch(CBaseEntity *pOther)
if (FClassnameIs(pOther->pev, "func_breakable"))
{
#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))
CBreakable *pBreak = static_cast<CBreakable *>(pOther);

if (!pBreak->IsBreakable())
return;
#endif
{
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);
}
Vector center = (pOther->pev->absmax + pOther->pev->absmin) / 2.0f;
bool breakIt = true;

if (breakIt)
{
// it's breakable - try to shoot it.
SetLookAt("Breakable", &center, PRIORITY_HIGH, 0.2, 0, 5.0);
if (m_pathLength)
{
Vector goal = m_goalPosition + Vector(0, 0, HalfHumanHeight);
breakIt = IsIntersectingBox(pev->origin, goal, pOther->pev->absmin, pOther->pev->absmax);
}

if (IsUsingGrenade())
{
EquipBestWeapon();
return;
}
if (breakIt)
{
// it's breakable - try to shoot it.
SetLookAt("Breakable", &center, PRIORITY_HIGH, 0.2, 0, 5.0);

PrimaryAttack();
if (IsUsingGrenade())
{
EquipBestWeapon();
return;
}

PrimaryAttack();
}
}
}
Expand Down

0 comments on commit 3f0ca82

Please sign in to comment.