Renamed hideout config property isPveInsurance to simulateItemsBeingTaken and updated code accordingly

This commit is contained in:
Dev 2024-09-15 10:50:57 +01:00
parent 3bf00a6f27
commit ea0c37b179
3 changed files with 11 additions and 8 deletions

View File

@ -9,5 +9,5 @@
"runIntervalSeconds": 600, "runIntervalSeconds": 600,
"minAttachmentRoublePriceToBeTaken": 2000, "minAttachmentRoublePriceToBeTaken": 2000,
"chanceNoAttachmentsTakenPercent": 10, "chanceNoAttachmentsTakenPercent": 10,
"isPveInsurance": false "simulateItemsBeingTaken": true
} }

View File

@ -128,15 +128,15 @@ export class InsuranceController {
// Iterate over each of the insurance packages. // Iterate over each of the insurance packages.
for (const insured of insuranceDetails) { for (const insured of insuranceDetails) {
const isPveInsurance = this.insuranceConfig.isPveInsurance; const simulateItemsBeingTaken = this.insuranceConfig.simulateItemsBeingTaken;
if (!isPveInsurance) { if (simulateItemsBeingTaken) {
// Find items that should be deleted from the insured items. // Find items that could be taken by another player off the players body
const itemsToDelete = this.findItemsToDelete(rootItemParentID, insured); const itemsToDelete = this.findItemsToDelete(rootItemParentID, insured);
// Actually remove them. // Actually remove them.
this.removeItemsFromInsurance(insured, itemsToDelete); this.removeItemsFromInsurance(insured, itemsToDelete);
} }
// Ensure that all items have a valid parent. // Ensure that all items have a valid parent.
insured.items = this.itemHelper.adoptOrphanedItems(rootItemParentID, insured.items); insured.items = this.itemHelper.adoptOrphanedItems(rootItemParentID, insured.items);
@ -659,14 +659,17 @@ export class InsuranceController {
/** /**
* Insure softinserts of Armor that has softinsert slots * Insure softinserts of Armor that has softinsert slots
* Allows armors to come back after being lost correctly
* @param item Armor item to be insured * @param item Armor item to be insured
* @param pmcData Player profile * @param pmcData Player profile
* @param body Insurance request data * @param body Insurance request data
*/ */
public insureSoftInserts(item: Item, pmcData: IPmcData, body: IInsureRequestData): void { public insureSoftInserts(item: Item, pmcData: IPmcData, body: IInsureRequestData): void {
const softInsertIds = this.itemHelper.getSoftInsertSlotIds(); const softInsertIds = this.itemHelper.getSoftInsertSlotIds();
const softInsertSlots = pmcData.Inventory.items.filter((x) => x.parentId === item._id && softInsertIds.includes(x.slotId.toLowerCase())); const softInsertSlots = pmcData.Inventory.items.filter(
(item) => item.parentId === item._id && softInsertIds.includes(item.slotId.toLowerCase()),
);
for (const softInsertSlot of softInsertSlots) { for (const softInsertSlot of softInsertSlots) {
this.logger.debug(`SoftInsertSlots: ${softInsertSlot.slotId}`); this.logger.debug(`SoftInsertSlots: ${softInsertSlot.slotId}`);
pmcData.InsuredItems.push({ tid: body.tid, itemId: softInsertSlot._id }); pmcData.InsuredItems.push({ tid: body.tid, itemId: softInsertSlot._id });

View File

@ -16,5 +16,5 @@ export interface IInsuranceConfig extends IBaseConfig {
minAttachmentRoublePriceToBeTaken: number; minAttachmentRoublePriceToBeTaken: number;
// Chance out of 100% no attachments from a parent are taken // Chance out of 100% no attachments from a parent are taken
chanceNoAttachmentsTakenPercent: number; chanceNoAttachmentsTakenPercent: number;
isPveInsurance: boolean; simulateItemsBeingTaken: boolean;
} }