@@ -1573,40 +1573,76 @@ void CNEOBot::EquipBestWeaponForThreat(const CKnownEntity* threat, const bool bN
15731573
15741574// -----------------------------------------------------------------------------------------------------
15751575// Reload the active weapon if it makes sense for the situation
1576- void CNEOBot::ReloadIfLowClip (void )
1576+ void CNEOBot::ReloadIfLowClip (bool bForceReload )
15771577{
15781578 CNEOBaseCombatWeapon* myWeapon = static_cast <CNEOBaseCombatWeapon*>(GetActiveWeapon ());
1579- if (myWeapon && myWeapon->GetPrimaryAmmoCount () > 0 )
1579+
1580+ if (!myWeapon)
1581+ {
1582+ return ;
1583+ }
1584+
1585+ if (myWeapon->GetPrimaryAmmoCount () <= 0 )
1586+ {
1587+ return ;
1588+ }
1589+
1590+ if (myWeapon->Clip1 () >= myWeapon->GetMaxClip1 ())
15801591 {
1581- bool shouldReload = false ;
1582- // SUPA7 reload doesn't discard ammo
1583- if ((myWeapon->GetNeoWepBits () & NEO_WEP_SUPA7) && (myWeapon->Clip1 () < myWeapon->GetMaxClip1 ()))
1592+ return ;
1593+ }
1594+
1595+ if (!(myWeapon->GetNeoWepBits () & NEO_WEP_FIREARM))
1596+ {
1597+ return ;
1598+ }
1599+
1600+ if (myWeapon->GetNeoWepBits () & NEO_WEP_BALC)
1601+ {
1602+ return ;
1603+ }
1604+
1605+ if (myWeapon->GetNeoWepBits () & NEO_WEP_SMAC)
1606+ {
1607+ return ;
1608+ }
1609+
1610+ if (myWeapon->GetNeoWepBits () & NEO_WEP_SUPA7)
1611+ {
1612+ // Consider loading slug
1613+ if ( (myWeapon->m_iSecondaryAmmoCount > 0 ) && (myWeapon->Clip1 () == myWeapon->GetMaxClip1 () - 1 ))
15841614 {
1585- shouldReload = true ;
1615+ ReleaseFireButton ();
1616+ PressAltFireButton ();
1617+ return ; // attempt to load slug
15861618 }
1587- else
1619+ // SUPA7 reload doesn't discard ammo, continue
1620+ }
1621+ else if (myWeapon->Clip1 () > 0 )
1622+ {
1623+ auto * pPlayer = ToNEOPlayer (this );
1624+ if ( pPlayer->GetTimeSinceWeaponFired () < 3 .0f )
15881625 {
1589- int maxClip = myWeapon-> GetMaxClip1 ();
1590- bool isBarrage = IsBarrageAndReloadWeapon (myWeapon);
1626+ return ; // still in the middle of a fight
1627+ }
15911628
1592- int baseThreshold = isBarrage ? (maxClip / 3 ) : (maxClip / 2 );
1629+ int maxClip = myWeapon->GetMaxClip1 ();
1630+ bool isBarrage = IsBarrageAndReloadWeapon (myWeapon);
15931631
1594- float aggressionFactor = 1 . 0f - HealthFraction ( );
1632+ int baseThreshold = isBarrage ? (maxClip / 3 ) : (maxClip / 2 );
15951633
1596- float dynamicThreshold = baseThreshold + aggressionFactor * (maxClip - baseThreshold );
1634+ float aggressionFactor = 1 . 0f - HealthFraction ( );
15971635
1598- if (myWeapon->Clip1 () < static_cast <int >(dynamicThreshold))
1599- {
1600- shouldReload = true ;
1601- }
1602- }
1636+ float dynamicThreshold = baseThreshold + aggressionFactor * (maxClip - baseThreshold);
16031637
1604- if (shouldReload )
1638+ if (!bForceReload && myWeapon-> Clip1 () > static_cast < int >(dynamicThreshold) )
16051639 {
1606- ReleaseFireButton ();
1607- PressReloadButton ();
1640+ return ; // reloads drop ammo, still have enough in clip
16081641 }
16091642 }
1643+
1644+ ReleaseFireButton ();
1645+ PressReloadButton ();
16101646}
16111647
16121648
@@ -1757,7 +1793,7 @@ bool CNEOBot::IsLineOfFirePenetrationClear(const trace_t &tr, const Vector &from
17571793
17581794 // Only bother with fire penetration in short distance
17591795 auto *neoWeapon = static_cast <CNEOBaseCombatWeapon *>(GetActiveWeapon ());
1760- if (!neoWeapon)
1796+ if (!neoWeapon || !(neoWeapon-> GetNeoWepBits () & NEO_WEP_FIREARM) )
17611797 {
17621798 return false ;
17631799 }
0 commit comments