From ef584d88d30cdebaa5ea31be23e3e3f572cae021 Mon Sep 17 00:00:00 2001 From: chomp Date: Mon, 6 Mar 2023 10:08:36 +0000 Subject: [PATCH] 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 Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/27 --- project/src/generators/LocationGenerator.ts | 7 +------ project/src/helpers/ItemHelper.ts | 6 ++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/project/src/generators/LocationGenerator.ts b/project/src/generators/LocationGenerator.ts index 1bfeac9d..9bb2db79 100644 --- a/project/src/generators/LocationGenerator.ts +++ b/project/src/generators/LocationGenerator.ts @@ -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); diff --git a/project/src/helpers/ItemHelper.ts b/project/src/helpers/ItemHelper.ts index 8239724f..2c1d71c9 100644 --- a/project/src/helpers/ItemHelper.ts +++ b/project/src/helpers/ItemHelper.ts @@ -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);