Reworked hideout code to remove all buffs/debuffs from profile after completing hideout wall

Added code to be run when 39x profiles are migrated

Renamed `checkAndUpgradeWall` to `SetWallVisibleIfPrereqsMet`
This commit is contained in:
Dev 2024-09-21 10:34:45 +01:00
parent 5217f7caed
commit 0fa22f0349
3 changed files with 33 additions and 8 deletions

View File

@ -255,6 +255,12 @@ export class GameController {
fullProfile.characters.pmc.Inventory.favoriteItems = [];
}
// Remove wall debuffs
const wallAreaDb = this.databaseService
.getHideout()
.areas.find((area) => area.type === HideoutAreas.EMERGENCY_WALL);
this.hideoutHelper.removeHideoutWallBuffsAndDebuffs(wallAreaDb, fullProfile.characters.pmc);
// Equipment area
const equipmentArea = fullProfile.characters.pmc.Hideout.Areas.find(
(area) => area.type === HideoutAreas.EQUIPMENT_PRESETS_STAND,

View File

@ -227,15 +227,12 @@ export class HideoutController {
profileHideoutArea.type === HideoutAreas.WATER_COLLECTOR ||
profileHideoutArea.type === HideoutAreas.MEDSTATION
) {
this.checkAndUpgradeWall(pmcData);
this.SetWallVisibleIfPrereqsMet(pmcData);
}
// Cleanup temporary fuel usage buffs from mopping floor if wall is complete as it would result in too many bonuses
// Cleanup temporary buffs/debuffs from wall if complete
if (profileHideoutArea.type === HideoutAreas.EMERGENCY_WALL && profileHideoutArea.level === 6) {
// Get everything except specific fuel consumption buffs
pmcData.Bonuses = pmcData.Bonuses.filter(
(bonus) => bonus.type !== BonusType.FUEL_CONSUMPTION || (bonus.value >= -10 && bonus.value <= 0),
);
this.hideoutHelper.removeHideoutWallBuffsAndDebuffs(hideoutData, pmcData);
}
// Add Skill Points Per Area Upgrade
@ -250,7 +247,7 @@ export class HideoutController {
* Upgrade wall status to visible in profile if medstation/water collector are both level 1
* @param pmcData Player profile
*/
protected checkAndUpgradeWall(pmcData: IPmcData): void {
protected SetWallVisibleIfPrereqsMet(pmcData: IPmcData): void {
const medStation = pmcData.Hideout.Areas.find((area) => area.type === HideoutAreas.MEDSTATION);
const waterCollector = pmcData.Hideout.Areas.find((area) => area.type === HideoutAreas.WATER_COLLECTOR);
if (medStation?.level >= 1 && waterCollector?.level >= 1) {

View File

@ -4,7 +4,7 @@ import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { IPmcData } from "@spt/models/eft/common/IPmcData";
import { HideoutArea, IHideoutImprovement, Production, Productive } from "@spt/models/eft/common/tables/IBotBase";
import { Item, Upd } from "@spt/models/eft/common/tables/IItem";
import { StageBonus } from "@spt/models/eft/hideout/IHideoutArea";
import { IHideoutArea, StageBonus } from "@spt/models/eft/hideout/IHideoutArea";
import { IHideoutContinuousProductionStartRequestData } from "@spt/models/eft/hideout/IHideoutContinuousProductionStartRequestData";
import { IHideoutProduction } from "@spt/models/eft/hideout/IHideoutProduction";
import { IHideoutSingleProductionStartRequestData } from "@spt/models/eft/hideout/IHideoutSingleProductionStartRequestData";
@ -1284,4 +1284,26 @@ export class HideoutHelper {
return result;
}
/**
* The wall pollutes a profile with various temp buffs/debuffs,
* Remove them all
* @param wallAreaDb Hideout area data
* @param pmcData Player profile
*/
public removeHideoutWallBuffsAndDebuffs(wallAreaDb: IHideoutArea, pmcData: IPmcData) {
// Smush all stage bonuses into one array for easy iteration
const wallBonuses = Object.values(wallAreaDb.stages).flatMap((stage) => stage.bonuses);
// Get all bonus Ids that the wall adds
const bonusIdsToRemove: string[] = [];
for (const bonus of wallBonuses) {
bonusIdsToRemove.push(bonus.id);
}
this.logger.debug(`Removing: ${bonusIdsToRemove.length} bonuses from profile`);
// Remove the wall bonuses from profile by id
pmcData.Bonuses = pmcData.Bonuses.filter((bonus) => !bonusIdsToRemove.includes(bonus.id));
}
}