Fix displaying secondary weapon mode stats

This commit is contained in:
Alexander Batalov 2022-08-11 14:30:06 +03:00
parent 1ca08cb97a
commit 5b2a1d13a1
1 changed files with 23 additions and 2 deletions

View File

@ -2433,6 +2433,11 @@ static void inventoryRenderSummary()
HIT_MODE_RIGHT_WEAPON_PRIMARY, HIT_MODE_RIGHT_WEAPON_PRIMARY,
}; };
const int secondaryHitModes[2] = {
HIT_MODE_LEFT_WEAPON_SECONDARY,
HIT_MODE_RIGHT_WEAPON_SECONDARY,
};
const int unarmedHitModes[2] = { const int unarmedHitModes[2] = {
HIT_MODE_PUNCH, HIT_MODE_PUNCH,
HIT_MODE_KICK, HIT_MODE_KICK,
@ -2510,13 +2515,29 @@ static void inventoryRenderSummary()
continue; continue;
} }
int range = _item_w_range(_stack[0], hitModes[index]); // SFALL: Fix displaying secondary mode weapon range.
int hitMode = hitModes[index];
if (_stack[0] == gDude) {
int actions[2];
interfaceGetItemActions(&(actions[0]), &(actions[1]));
bool isSecondary = actions[index] == INTERFACE_ITEM_ACTION_SECONDARY ||
actions[index] == INTERFACE_ITEM_ACTION_SECONDARY_AIMING;
if (isSecondary) {
hitMode = secondaryHitModes[index];
}
}
int range = _item_w_range(_stack[0], hitMode);
int damageMin; int damageMin;
int damageMax; int damageMax;
weaponGetDamageMinMax(item, &damageMin, &damageMax); weaponGetDamageMinMax(item, &damageMin, &damageMax);
int attackType = weaponGetAttackTypeForHitMode(item, hitModes[index]); // CE: Fix displaying secondary mode weapon damage (affects throwable
// melee weapons - knifes, spears, etc.).
int attackType = weaponGetAttackTypeForHitMode(item, hitMode);
formattedText[0] = '\0'; formattedText[0] = '\0';