diff --git a/project/src/controllers/InsuranceController.ts b/project/src/controllers/InsuranceController.ts index 8b85e3da..169009fc 100644 --- a/project/src/controllers/InsuranceController.ts +++ b/project/src/controllers/InsuranceController.ts @@ -97,15 +97,12 @@ export class InsuranceController protected filterInsuredItems(sessionID: string, time?: number): Insurance[] { // Use the current time by default. - if (!time) - { - time = this.timeUtil.getTimestamp(); - } + const insuranceTime = time || this.timeUtil.getTimestamp(); const profileInsuranceDetails = this.saveServer.getProfile(sessionID).insurance; this.logger.debug(`Found ${profileInsuranceDetails.length} insurance packages in profile ${sessionID}`); - return profileInsuranceDetails.filter((insured) => time >= insured.scheduledTime); + return profileInsuranceDetails.filter((insured) => insuranceTime >= insured.scheduledTime); } /** diff --git a/project/src/controllers/InventoryController.ts b/project/src/controllers/InventoryController.ts index cdae344a..8c6471a7 100644 --- a/project/src/controllers/InventoryController.ts +++ b/project/src/controllers/InventoryController.ts @@ -468,13 +468,15 @@ export class InventoryController */ public foldItem(pmcData: IPmcData, body: IInventoryFoldRequestData, sessionID: string): IItemEventRouterResponse { + let playerData = pmcData; + // Fix for folding weapons while on they're in the Scav inventory - if (body.fromOwner && body.fromOwner.type === "Profile" && body.fromOwner.id !== pmcData._id) + if (body.fromOwner && body.fromOwner.type === "Profile" && body.fromOwner.id !== playerData._id) { - pmcData = this.profileHelper.getScavProfile(sessionID); + playerData = this.profileHelper.getScavProfile(sessionID); } - for (const item of pmcData.Inventory.items) + for (const item of playerData.Inventory.items) { if (item._id && item._id === body.item) { @@ -495,13 +497,15 @@ export class InventoryController */ public toggleItem(pmcData: IPmcData, body: IInventoryToggleRequestData, sessionID: string): IItemEventRouterResponse { + let playerData = pmcData; + // Fix for toggling items while on they're in the Scav inventory - if (body.fromOwner && body.fromOwner.type === "Profile" && body.fromOwner.id !== pmcData._id) + if (body.fromOwner && body.fromOwner.type === "Profile" && body.fromOwner.id !== playerData._id) { - pmcData = this.profileHelper.getScavProfile(sessionID); + playerData = this.profileHelper.getScavProfile(sessionID); } - const itemToToggle = pmcData.Inventory.items.find((x) => x._id === body.item); + const itemToToggle = playerData.Inventory.items.find((x) => x._id === body.item); if (itemToToggle) { if (!itemToToggle.upd) diff --git a/project/src/controllers/RepeatableQuestController.ts b/project/src/controllers/RepeatableQuestController.ts index d2d98eb0..f2276255 100644 --- a/project/src/controllers/RepeatableQuestController.ts +++ b/project/src/controllers/RepeatableQuestController.ts @@ -263,14 +263,16 @@ export class RepeatableQuestController public generateDebugDailies(dailiesPool: any, factory: any, number: number): any { let randomQuests = []; + let numberOfQuests = number; + if (factory) { // First is factory extract always add for debugging randomQuests.push(dailiesPool[0]); - number -= 1; + numberOfQuests -= 1; } - randomQuests = randomQuests.concat(this.randomUtil.drawRandomFromList(dailiesPool, number, false)); + randomQuests = randomQuests.concat(this.randomUtil.drawRandomFromList(dailiesPool, numberOfQuests, false)); for (const element of randomQuests) { diff --git a/project/src/generators/BotEquipmentModGenerator.ts b/project/src/generators/BotEquipmentModGenerator.ts index c07c2ce6..d5c0c6ef 100644 --- a/project/src/generators/BotEquipmentModGenerator.ts +++ b/project/src/generators/BotEquipmentModGenerator.ts @@ -75,9 +75,11 @@ export class BotEquipmentModGenerator parentId: string, parentTemplate: ITemplateItem, settings: IGenerateEquipmentProperties, - forceSpawn = false, + shouldForceSpawn = false, ): Item[] { + let forceSpawn = shouldForceSpawn; + const compatibleModsPool = settings.modPool[parentTemplate._id]; if (!compatibleModsPool) { diff --git a/project/src/generators/BotLootGenerator.ts b/project/src/generators/BotLootGenerator.ts index 453e05a6..a6c6e154 100644 --- a/project/src/generators/BotLootGenerator.ts +++ b/project/src/generators/BotLootGenerator.ts @@ -429,7 +429,7 @@ export class BotLootGenerator // Must add soft inserts/plates else if (this.itemHelper.itemRequiresSoftInserts(itemToAddTemplate._id)) { - itemToAddChildrenTo = this.itemHelper.addChildSlotItems(itemToAddChildrenTo, itemToAddTemplate, null, true); + this.itemHelper.addChildSlotItems(itemToAddChildrenTo, itemToAddTemplate, null, true); } } diff --git a/project/src/helpers/ProfileHelper.ts b/project/src/helpers/ProfileHelper.ts index dd2d0f19..3e1b6ac3 100644 --- a/project/src/helpers/ProfileHelper.ts +++ b/project/src/helpers/ProfileHelper.ts @@ -193,13 +193,14 @@ export class ProfileHelper public getExperience(level: number): number { + let playerLevel = level; const expTable = this.databaseServer.getTables().globals.config.exp.level.exp_table; let exp = 0; - if (level >= expTable.length) + if (playerLevel >= expTable.length) { // make sure to not go out of bounds - level = expTable.length - 1; + playerLevel = expTable.length - 1; } for (let i = 0; i < level; i++) @@ -400,7 +401,9 @@ export class ProfileHelper useSkillProgressRateMultipler = false, ): void { - if (!pointsToAdd || pointsToAdd < 0) + let pointsToAddToSkill = pointsToAdd; + + if (!pointsToAddToSkill || pointsToAddToSkill < 0) { this.logger.warning( this.localisationService.getText("player-attempt_to_increment_skill_with_negative_value", skill), @@ -411,7 +414,7 @@ export class ProfileHelper const profileSkills = pmcProfile?.Skills?.Common; if (!profileSkills) { - this.logger.warning(`Unable to add ${pointsToAdd} points to ${skill}, profile has no skills`); + this.logger.warning(`Unable to add ${pointsToAddToSkill} points to ${skill}, profile has no skills`); return; } @@ -426,10 +429,10 @@ export class ProfileHelper { const globals = this.databaseServer.getTables().globals; const skillProgressRate = globals.config.SkillsSettings.SkillProgressRate; - pointsToAdd *= skillProgressRate; + pointsToAddToSkill *= skillProgressRate; } - profileSkill.Progress += pointsToAdd; + profileSkill.Progress += pointsToAddToSkill; profileSkill.Progress = Math.min(profileSkill.Progress, 5100); // Prevent skill from ever going above level 51 (5100) profileSkill.LastAccess = this.timeUtil.getTimestamp(); }