Fix: Move pp-9 ammo typo check into fillMagazineWithRandomCartridge() so it can be used by more than just static container weapon ammo code (!27)

Co-authored-by: Dev <dev@noreply.dev.sp-tarkov.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/27
This commit is contained in:
chomp 2023-03-06 10:08:36 +00:00
parent bf061774d0
commit ef584d88d3
2 changed files with 7 additions and 6 deletions

View File

@ -483,14 +483,9 @@ export class LocationGenerator
const magTemplate = this.itemHelper.getItem(magazine._tpl)[1];
const weaponTemplate = this.itemHelper.getItem(tpl)[1];
// Edge case for the Klin pp-9, it has a typo in its ammo caliber
const ammoCaliber = (weaponTemplate._props.ammoCaliber === "Caliber9x18PMM")
? "Caliber9x18PM"
: weaponTemplate._props.ammoCaliber;
// Create array with just magazine
const magazineWithCartridges = [magazine];
this.itemHelper.fillMagazineWithRandomCartridge(magazineWithCartridges, magTemplate, staticAmmoDist, ammoCaliber);
this.itemHelper.fillMagazineWithRandomCartridge(magazineWithCartridges, magTemplate, staticAmmoDist, weaponTemplate._props.ammoCaliber);
// Replace existing magazine with above array
items.splice(items.indexOf(magazine), 1, ...magazineWithCartridges);

View File

@ -838,6 +838,12 @@ class ItemHelper
caliber = this.getRandomValidCaliber(magTemplate);
}
// Edge case for the Klin pp-9, it has a typo in its ammo caliber
if (caliber === "Caliber9x18PMM")
{
caliber = "Caliber9x18PM";
}
// Chose a randomly weighted cartridge that fits
const cartridgeTpl = this.drawAmmoTpl(caliber, staticAmmoDist);
this.fillMagazineWithCartridge(magazine, magTemplate, cartridgeTpl, minSizePercent);