fix: allow to pickup ammo and kits regardless of weapon

This commit is contained in:
jeefo 2024-02-17 00:09:32 +03:00
commit 475d290767
No known key found for this signature in database
GPG key ID: 927BCA0779BEA8ED
2 changed files with 19 additions and 5 deletions

View file

@ -518,6 +518,20 @@ void Bot::updatePickups () {
} }
else if (!rateGroundWeapon (ent)) { else if (!rateGroundWeapon (ent)) {
allowPickup = false; allowPickup = false;
// double check if it's ammo/kits
if (pickupType == Pickup::AmmoAndKits) {
const auto &rawWeapons = conf.getWeapons ();
// verify that the model is not weapon
for (const auto &rw : rawWeapons) {
if (rw.model == model) {
allowPickup = false;
break;
}
allowPickup = true;
}
}
} }
else if ((pev->weapons & cr::bit (Weapon::Flashbang)) && model == kFlashbangModelName) { else if ((pev->weapons & cr::bit (Weapon::Flashbang)) && model == kFlashbangModelName) {
allowPickup = false; allowPickup = false;

View file

@ -1458,12 +1458,12 @@ bool Bot::isEnemyBehindShield (edict_t *enemy) {
int Bot::bestPrimaryCarried () { int Bot::bestPrimaryCarried () {
// this function returns the best weapon of this bot (based on personality prefs) // this function returns the best weapon of this bot (based on personality prefs)
const int *pref = conf.getWeaponPrefs (m_personality); auto pref = conf.getWeaponPrefs (m_personality);
int weaponIndex = 0; int weaponIndex = 0;
int weapons = pev->weapons; int weapons = pev->weapons;
const auto &tab = conf.getWeapons (); const auto &tab = conf.getRawWeapons ();
// take the shield in account // take the shield in account
if (hasShield ()) { if (hasShield ()) {
@ -1482,7 +1482,7 @@ int Bot::bestPrimaryCarried () {
int Bot::bestSecondaryCarried () { int Bot::bestSecondaryCarried () {
// this function returns the best secondary weapon of this bot (based on personality prefs) // this function returns the best secondary weapon of this bot (based on personality prefs)
const int *pref = conf.getWeaponPrefs (m_personality); auto pref = conf.getWeaponPrefs (m_personality);
int weaponIndex = 0; int weaponIndex = 0;
int weapons = pev->weapons; int weapons = pev->weapons;
@ -1494,9 +1494,9 @@ int Bot::bestSecondaryCarried () {
const auto tab = conf.getRawWeapons (); const auto tab = conf.getRawWeapons ();
for (int i = 0; i < kNumWeapons; ++i) { for (int i = 0; i < kNumWeapons; ++i) {
int id = tab[*pref].id; const int id = tab[*pref].id;
if ((weapons & cr::bit (tab[*pref].id)) && conf.getWeaponType (id) == WeaponType::Pistol) { if ((weapons & cr::bit (id)) && conf.getWeaponType (id) == WeaponType::Pistol) {
weaponIndex = i; weaponIndex = i;
break; break;
} }