mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:50:43 -05:00
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:
parent
5217f7caed
commit
0fa22f0349
@ -255,6 +255,12 @@ export class GameController {
|
|||||||
fullProfile.characters.pmc.Inventory.favoriteItems = [];
|
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
|
// Equipment area
|
||||||
const equipmentArea = fullProfile.characters.pmc.Hideout.Areas.find(
|
const equipmentArea = fullProfile.characters.pmc.Hideout.Areas.find(
|
||||||
(area) => area.type === HideoutAreas.EQUIPMENT_PRESETS_STAND,
|
(area) => area.type === HideoutAreas.EQUIPMENT_PRESETS_STAND,
|
||||||
|
@ -227,15 +227,12 @@ export class HideoutController {
|
|||||||
profileHideoutArea.type === HideoutAreas.WATER_COLLECTOR ||
|
profileHideoutArea.type === HideoutAreas.WATER_COLLECTOR ||
|
||||||
profileHideoutArea.type === HideoutAreas.MEDSTATION
|
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) {
|
if (profileHideoutArea.type === HideoutAreas.EMERGENCY_WALL && profileHideoutArea.level === 6) {
|
||||||
// Get everything except specific fuel consumption buffs
|
this.hideoutHelper.removeHideoutWallBuffsAndDebuffs(hideoutData, pmcData);
|
||||||
pmcData.Bonuses = pmcData.Bonuses.filter(
|
|
||||||
(bonus) => bonus.type !== BonusType.FUEL_CONSUMPTION || (bonus.value >= -10 && bonus.value <= 0),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add Skill Points Per Area Upgrade
|
// 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
|
* Upgrade wall status to visible in profile if medstation/water collector are both level 1
|
||||||
* @param pmcData Player profile
|
* @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 medStation = pmcData.Hideout.Areas.find((area) => area.type === HideoutAreas.MEDSTATION);
|
||||||
const waterCollector = pmcData.Hideout.Areas.find((area) => area.type === HideoutAreas.WATER_COLLECTOR);
|
const waterCollector = pmcData.Hideout.Areas.find((area) => area.type === HideoutAreas.WATER_COLLECTOR);
|
||||||
if (medStation?.level >= 1 && waterCollector?.level >= 1) {
|
if (medStation?.level >= 1 && waterCollector?.level >= 1) {
|
||||||
|
@ -4,7 +4,7 @@ import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
|||||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||||
import { HideoutArea, IHideoutImprovement, Production, Productive } from "@spt/models/eft/common/tables/IBotBase";
|
import { HideoutArea, IHideoutImprovement, Production, Productive } from "@spt/models/eft/common/tables/IBotBase";
|
||||||
import { Item, Upd } from "@spt/models/eft/common/tables/IItem";
|
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 { IHideoutContinuousProductionStartRequestData } from "@spt/models/eft/hideout/IHideoutContinuousProductionStartRequestData";
|
||||||
import { IHideoutProduction } from "@spt/models/eft/hideout/IHideoutProduction";
|
import { IHideoutProduction } from "@spt/models/eft/hideout/IHideoutProduction";
|
||||||
import { IHideoutSingleProductionStartRequestData } from "@spt/models/eft/hideout/IHideoutSingleProductionStartRequestData";
|
import { IHideoutSingleProductionStartRequestData } from "@spt/models/eft/hideout/IHideoutSingleProductionStartRequestData";
|
||||||
@ -1284,4 +1284,26 @@ export class HideoutHelper {
|
|||||||
|
|
||||||
return result;
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user