Add system to ignore armor plate slots when removing plates not suitable for flea
This commit is contained in:
parent
7d97bc4945
commit
c097914e45
@ -292,7 +292,10 @@
|
|||||||
"enableBsgList": true,
|
"enableBsgList": true,
|
||||||
"enableQuestList": true,
|
"enableQuestList": true,
|
||||||
"traderItems": false,
|
"traderItems": false,
|
||||||
"armorPlateMaxProtectionLevel": 4
|
"armorPlate": {
|
||||||
|
"maxProtectionLevel": 4,
|
||||||
|
"ignoreSlots": ["right_side_plate", "left_side_plate"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"unreasonableModPrices": {
|
"unreasonableModPrices": {
|
||||||
"5448fe124bdc2da5018b4567": {
|
"5448fe124bdc2da5018b4567": {
|
||||||
|
@ -14,7 +14,12 @@ import { BaseClasses } from "@spt-aki/models/enums/BaseClasses";
|
|||||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||||
import { MemberCategory } from "@spt-aki/models/enums/MemberCategory";
|
import { MemberCategory } from "@spt-aki/models/enums/MemberCategory";
|
||||||
import { Money } from "@spt-aki/models/enums/Money";
|
import { Money } from "@spt-aki/models/enums/Money";
|
||||||
import { Condition, Dynamic, IRagfairConfig } from "@spt-aki/models/spt/config/IRagfairConfig";
|
import {
|
||||||
|
Condition,
|
||||||
|
Dynamic,
|
||||||
|
IArmorPlateBlacklistSettings,
|
||||||
|
IRagfairConfig,
|
||||||
|
} from "@spt-aki/models/spt/config/IRagfairConfig";
|
||||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||||
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
||||||
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
||||||
@ -358,10 +363,7 @@ export class RagfairOfferGenerator
|
|||||||
// Armor presets can hold plates above the allowed flea level, remove if necessary
|
// Armor presets can hold plates above the allowed flea level, remove if necessary
|
||||||
if (isPreset && this.ragfairConfig.dynamic.blacklist.enableBsgList)
|
if (isPreset && this.ragfairConfig.dynamic.blacklist.enableBsgList)
|
||||||
{
|
{
|
||||||
this.removeBannedPlatesFromPreset(
|
this.removeBannedPlatesFromPreset(assortItemWithChildren, this.ragfairConfig.dynamic.blacklist.armorPlate);
|
||||||
assortItemWithChildren,
|
|
||||||
this.ragfairConfig.dynamic.blacklist.armorPlateMaxProtectionLevel,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get number of offers to create
|
// Get number of offers to create
|
||||||
@ -394,10 +396,13 @@ export class RagfairOfferGenerator
|
|||||||
/**
|
/**
|
||||||
* iterate over an items chidren and look for plates above desired level and remove them
|
* iterate over an items chidren and look for plates above desired level and remove them
|
||||||
* @param presetWithChildren preset to check for plates
|
* @param presetWithChildren preset to check for plates
|
||||||
* @param plateProtectionLimit Max level of plates an armor can have without being removed
|
* @param plateSettings Settings
|
||||||
* @returns True if plate removed
|
* @returns True if plate removed
|
||||||
*/
|
*/
|
||||||
protected removeBannedPlatesFromPreset(presetWithChildren: Item[], plateProtectionLimit: number): boolean
|
protected removeBannedPlatesFromPreset(
|
||||||
|
presetWithChildren: Item[],
|
||||||
|
plateSettings: IArmorPlateBlacklistSettings,
|
||||||
|
): boolean
|
||||||
{
|
{
|
||||||
if (!this.itemHelper.armorItemCanHoldMods(presetWithChildren[0]._tpl))
|
if (!this.itemHelper.armorItemCanHoldMods(presetWithChildren[0]._tpl))
|
||||||
{
|
{
|
||||||
@ -410,16 +415,21 @@ export class RagfairOfferGenerator
|
|||||||
);
|
);
|
||||||
if (plateSlots.length === 0)
|
if (plateSlots.length === 0)
|
||||||
{
|
{
|
||||||
// Has no plate slots e.g. "left_side_plate", exit
|
// Has no plate slots e.g. "front_plate", exit
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let removedPlate = false;
|
let removedPlate = false;
|
||||||
for (const plateSlot of plateSlots)
|
for (const plateSlot of plateSlots)
|
||||||
{
|
{
|
||||||
const plateArmorLevel =
|
const plateDetails = this.itemHelper.getItem(plateSlot._tpl)[1];
|
||||||
Number.parseInt(<string>this.itemHelper.getItem(plateSlot._tpl)[1]._props.armorClass) ?? 0;
|
if (plateSettings.ignoreSlots.includes(plateSlot.slotId.toLowerCase()))
|
||||||
if (plateArmorLevel > plateProtectionLimit)
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const plateArmorLevel = Number.parseInt(<string>plateDetails._props.armorClass) ?? 0;
|
||||||
|
if (plateArmorLevel > plateSettings.maxProtectionLevel)
|
||||||
{
|
{
|
||||||
presetWithChildren.splice(presetWithChildren.indexOf(plateSlot), 1);
|
presetWithChildren.splice(presetWithChildren.indexOf(plateSlot), 1);
|
||||||
removedPlate = true;
|
removedPlate = true;
|
||||||
|
@ -1426,7 +1426,7 @@ export class ItemHelper
|
|||||||
*/
|
*/
|
||||||
public getRemovablePlateSlotIds(): string[]
|
public getRemovablePlateSlotIds(): string[]
|
||||||
{
|
{
|
||||||
return ["front_plate", "back_plate", "side_plate", "left_side_plate", "right_side_plate"];
|
return ["front_plate", "back_plate", "left_side_plate", "right_side_plate"];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -162,7 +162,15 @@ export interface Blacklist
|
|||||||
/** Should trader items that are blacklisted by bsg be listed on flea */
|
/** Should trader items that are blacklisted by bsg be listed on flea */
|
||||||
traderItems: boolean;
|
traderItems: boolean;
|
||||||
/** Maximum level an armor plate can be found in a flea-listed armor item */
|
/** Maximum level an armor plate can be found in a flea-listed armor item */
|
||||||
armorPlateMaxProtectionLevel: number;
|
armorPlate: IArmorPlateBlacklistSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IArmorPlateBlacklistSettings
|
||||||
|
{
|
||||||
|
/** Max level of plates an armor can have without being removed */
|
||||||
|
maxProtectionLevel: number;
|
||||||
|
/** Item slots to NOT remove from items on flea */
|
||||||
|
ignoreSlots: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IUnreasonableModPrices
|
export interface IUnreasonableModPrices
|
||||||
|
Loading…
x
Reference in New Issue
Block a user