Bots can switch weapons underwater (#631)

* Bots can switch weapons underwater
This commit is contained in:
Vaqtincha 2021-06-06 17:13:55 +05:00 committed by GitHub
parent d80d87366a
commit 3ff0f0cbf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 0 deletions

View File

@ -516,6 +516,14 @@ void CCSBot::Update()
m_isWaitingToTossGrenade = false;
}
#ifdef REGAMEDLL_FIXES
// bots with low skill cannot switch weapons underwater
if (GetProfile()->GetSkill() > 0.4f && pev->waterlevel == 3 && !IsActiveWeaponCanShootUnderwater())
{
EquipBestWeapon(MUST_EQUIP);
}
#endif
if (IsHunting() && IsWellPastSafe() && IsUsingGrenade())
{
EquipBestWeapon(MUST_EQUIP);

View File

@ -414,6 +414,11 @@ bool CCSBot::DoEquip(CBasePlayerWeapon *pWeapon)
if (!pWeapon)
return false;
#ifdef REGAMEDLL_FIXES
if (GetProfile()->GetSkill() > 0.4f && pev->waterlevel == 3 && (pWeapon->iFlags() & ITEM_FLAG_NOFIREUNDERWATER))
return false;
#endif
// check if weapon has any ammo left
if (!HasAnyAmmo(pWeapon))
return false;

View File

@ -196,6 +196,8 @@ public:
// is the weapon in the middle of a reload
bool IsActiveWeaponReloading() const;
bool IsActiveWeaponCanShootUnderwater() const;
// return true if active weapon's bullet spray has become large and inaccurate
bool IsActiveWeaponRecoilHigh() const;
@ -327,6 +329,15 @@ inline CBasePlayerWeapon *CBot::GetActiveWeapon() const
return static_cast<CBasePlayerWeapon *>(m_pActiveItem);
}
inline bool CBot::IsActiveWeaponCanShootUnderwater() const
{
CBasePlayerWeapon *pCurrentWeapon = GetActiveWeapon();
if (pCurrentWeapon && !(pCurrentWeapon->iFlags() & ITEM_FLAG_NOFIREUNDERWATER))
return true;
return false;
}
inline bool CBot::IsActiveWeaponReloading() const
{
CBasePlayerWeapon *pCurrentWeapon = GetActiveWeapon();