Fix best weapon calculations

This commit is contained in:
Alexander Batalov 2022-08-14 17:48:59 +03:00
parent 330edde003
commit 7096116296
1 changed files with 10 additions and 7 deletions

View File

@ -1714,17 +1714,18 @@ static Object* _ai_best_weapon(Object* attacker, Object* weapon1, Object* weapon
return NULL;
}
avgDamage1 = (maxDamage - minDamage) / 2;
// SFALL: Fix avg damage calculation.
avgDamage1 = (maxDamage + minDamage) / 2;
if (_item_w_area_damage_radius(weapon1, HIT_MODE_RIGHT_WEAPON_PRIMARY) > 0 && defender != NULL) {
attack.weapon = weapon1;
_compute_explosion_on_extras(&attack, 0, weaponIsGrenade(weapon1), 1);
avgDamage1 *= attack.extrasLength + 1;
}
// TODO: Probably an error, why it takes [weapon2], should likely use
// [weapon1].
if (weaponGetPerk(weapon2) != -1) {
avgDamage1 *= 5;
// SFALL: Fix for the incorrect item being checked.
if (weaponGetPerk(weapon1) != -1) {
// SFALL: Lower weapon score multiplier for having perk.
avgDamage1 *= 2;
}
if (defender != NULL) {
@ -1758,7 +1759,8 @@ static Object* _ai_best_weapon(Object* attacker, Object* weapon1, Object* weapon
return NULL;
}
avgDamage2 = (maxDamage - minDamage) / 2;
// SFALL: Fix avg damage calculation.
avgDamage2 = (maxDamage + minDamage) / 2;
if (_item_w_area_damage_radius(weapon2, HIT_MODE_RIGHT_WEAPON_PRIMARY) > 0 && defender != NULL) {
attack.weapon = weapon2;
_compute_explosion_on_extras(&attack, 0, weaponIsGrenade(weapon2), 1);
@ -1766,7 +1768,8 @@ static Object* _ai_best_weapon(Object* attacker, Object* weapon1, Object* weapon
}
if (weaponGetPerk(weapon2) != -1) {
avgDamage2 *= 5;
// SFALL: Lower weapon score multiplier for having perk.
avgDamage2 *= 2;
}
if (defender != NULL) {