0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 08:50:43 -05:00

Implemented system that purges Christmas containers when outside of relevant event

This commit is contained in:
Chomp 2024-12-31 17:56:23 +00:00
parent 90c6b62814
commit 545707d0bb
4 changed files with 39 additions and 10 deletions

View File

@ -12270,5 +12270,12 @@
} }
] ]
} }
} },
"christmasContainerIds": [
"container_custom_DesignStuff_00427",
"container_Shopping_Mall_DesignStuff_00808",
"container_Lighthouse_DesignStuff_00001",
"container_shoreline_DesignStuff_00418",
"container_woods_design_stuff_00328"
]
} }

View File

@ -15,7 +15,8 @@ import { IItem } from "@spt/models/eft/common/tables/IItem";
import { BaseClasses } from "@spt/models/enums/BaseClasses"; import { BaseClasses } from "@spt/models/enums/BaseClasses";
import { ConfigTypes } from "@spt/models/enums/ConfigTypes"; import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
import { ILocationConfig } from "@spt/models/spt/config/ILocationConfig"; import { ILocationConfig } from "@spt/models/spt/config/ILocationConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ISeasonalEvent, ISeasonalEventConfig } from "@spt/models/spt/config/ISeasonalEventConfig";
import type { ILogger } from "@spt/models/spt/utils/ILogger";
import { ConfigServer } from "@spt/servers/ConfigServer"; import { ConfigServer } from "@spt/servers/ConfigServer";
import { DatabaseService } from "@spt/services/DatabaseService"; import { DatabaseService } from "@spt/services/DatabaseService";
import { ItemFilterService } from "@spt/services/ItemFilterService"; import { ItemFilterService } from "@spt/services/ItemFilterService";
@ -24,7 +25,7 @@ import { SeasonalEventService } from "@spt/services/SeasonalEventService";
import { MathUtil } from "@spt/utils/MathUtil"; import { MathUtil } from "@spt/utils/MathUtil";
import { ObjectId } from "@spt/utils/ObjectId"; import { ObjectId } from "@spt/utils/ObjectId";
import { ProbabilityObject, ProbabilityObjectArray, RandomUtil } from "@spt/utils/RandomUtil"; import { ProbabilityObject, ProbabilityObjectArray, RandomUtil } from "@spt/utils/RandomUtil";
import { ICloner } from "@spt/utils/cloners/ICloner"; import type { ICloner } from "@spt/utils/cloners/ICloner";
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
export interface IContainerItem { export interface IContainerItem {
@ -43,6 +44,7 @@ export interface IContainerGroupCount {
@injectable() @injectable()
export class LocationLootGenerator { export class LocationLootGenerator {
protected locationConfig: ILocationConfig; protected locationConfig: ILocationConfig;
protected seasonalEventConfig: ISeasonalEventConfig;
constructor( constructor(
@inject("PrimaryLogger") protected logger: ILogger, @inject("PrimaryLogger") protected logger: ILogger,
@ -60,6 +62,7 @@ export class LocationLootGenerator {
@inject("PrimaryCloner") protected cloner: ICloner, @inject("PrimaryCloner") protected cloner: ICloner,
) { ) {
this.locationConfig = this.configServer.getConfig(ConfigTypes.LOCATION); this.locationConfig = this.configServer.getConfig(ConfigTypes.LOCATION);
this.seasonalEventConfig = this.configServer.getConfig(ConfigTypes.SEASONAL_EVENT);
} }
/** /**
@ -88,18 +91,15 @@ export class LocationLootGenerator {
// Add mounted weapons to output loot // Add mounted weapons to output loot
result.push(...(staticWeaponsOnMapClone ?? [])); result.push(...(staticWeaponsOnMapClone ?? []));
const allStaticContainersOnMapClone = this.cloner.clone(mapData.staticContainers.staticContainers); let allStaticContainersOnMapClone = this.cloner.clone(mapData.staticContainers.staticContainers);
if (!allStaticContainersOnMapClone) { if (!allStaticContainersOnMapClone) {
this.logger.error( this.logger.error(
this.localisationService.getText("location-unable_to_find_static_container_for_map", locationBase.Name), this.localisationService.getText("location-unable_to_find_static_container_for_map", locationBase.Name),
); );
} }
const staticRandomisableContainersOnMap = this.getRandomisableContainersOnMap(allStaticContainersOnMapClone);
// Containers that MUST be added to map (quest containers etc) // Containers that MUST be added to map (e.g. quest containers)
const staticForcedOnMapClone = this.cloner.clone(mapData.staticContainers.staticForced); const staticForcedOnMapClone = this.cloner.clone(mapData.staticContainers.staticForced);
if (!staticForcedOnMapClone) { if (!staticForcedOnMapClone) {
this.logger.error( this.logger.error(
this.localisationService.getText( this.localisationService.getText(
@ -109,6 +109,15 @@ export class LocationLootGenerator {
); );
} }
// Remove christmas items from loot data
if (!this.seasonalEventService.christmasEventEnabled()) {
allStaticContainersOnMapClone = allStaticContainersOnMapClone.filter(
(item) => !this.seasonalEventConfig.christmasContainerIds.includes(item.template.Id),
);
}
const staticRandomisableContainersOnMap = this.getRandomisableContainersOnMap(allStaticContainersOnMapClone);
// Keep track of static loot count // Keep track of static loot count
let staticContainerCount = 0; let staticContainerCount = 0;
@ -579,6 +588,16 @@ export class LocationLootGenerator {
const loot: ISpawnpointTemplate[] = []; const loot: ISpawnpointTemplate[] = [];
const dynamicForcedSpawnPoints: ISpawnpointsForced[] = []; const dynamicForcedSpawnPoints: ISpawnpointsForced[] = [];
// Remove christmas items from loot data
if (!this.seasonalEventService.christmasEventEnabled()) {
dynamicLootDist.spawnpoints = dynamicLootDist.spawnpoints.filter(
(point) => !point.template.Id.startsWith("christmas"),
);
dynamicLootDist.spawnpointsForced = dynamicLootDist.spawnpointsForced.filter(
(point) => !point.template.Id.startsWith("christmas"),
);
}
// Build the list of forced loot from both `spawnpointsForced` and any point marked `IsAlwaysSpawn` // Build the list of forced loot from both `spawnpointsForced` and any point marked `IsAlwaysSpawn`
dynamicForcedSpawnPoints.push(...dynamicLootDist.spawnpointsForced); dynamicForcedSpawnPoints.push(...dynamicLootDist.spawnpointsForced);
dynamicForcedSpawnPoints.push(...dynamicLootDist.spawnpoints.filter((point) => point.template.IsAlwaysSpawn)); dynamicForcedSpawnPoints.push(...dynamicLootDist.spawnpoints.filter((point) => point.template.IsAlwaysSpawn));

View File

@ -16,6 +16,8 @@ export interface ISeasonalEventConfig extends IBaseConfig {
gifterSettings: IGifterSetting[]; gifterSettings: IGifterSetting[];
/** key = event, second key = map name */ /** key = event, second key = map name */
hostilitySettingsForEvent: Record<string, Record<string, IAdditionalHostilitySettings[]>>; hostilitySettingsForEvent: Record<string, Record<string, IAdditionalHostilitySettings[]>>;
/** Ids of containers on locations that only have christmas loot */
christmasContainerIds: string[];
} }
export interface ISeasonalEvent { export interface ISeasonalEvent {

View File

@ -273,12 +273,12 @@ export class LocationLifecycleService {
return locationBaseClone; return locationBaseClone;
} }
// If new spawn system is enabled, clear the spawn waves // If new spawn system is enabled, clear the spawn waves to prevent x2 spawns
if (locationBaseClone.NewSpawn) { if (locationBaseClone.NewSpawn) {
locationBaseClone.waves = []; locationBaseClone.waves = [];
} }
// We only need the base data // Only requested base data, not loot
if (!generateLoot) { if (!generateLoot) {
return locationBaseClone; return locationBaseClone;
} }
@ -307,6 +307,7 @@ export class LocationLifecycleService {
name.toLowerCase(), name.toLowerCase(),
); );
// Push chosen spawn points into returned object
for (const spawnPoint of dynamicSpawnPoints) { for (const spawnPoint of dynamicSpawnPoints) {
locationBaseClone.Loot.push(spawnPoint); locationBaseClone.Loot.push(spawnPoint);
} }