0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 05:50:44 -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 { ConfigTypes } from "@spt/models/enums/ConfigTypes";
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 { DatabaseService } from "@spt/services/DatabaseService";
import { ItemFilterService } from "@spt/services/ItemFilterService";
@ -24,7 +25,7 @@ import { SeasonalEventService } from "@spt/services/SeasonalEventService";
import { MathUtil } from "@spt/utils/MathUtil";
import { ObjectId } from "@spt/utils/ObjectId";
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";
export interface IContainerItem {
@ -43,6 +44,7 @@ export interface IContainerGroupCount {
@injectable()
export class LocationLootGenerator {
protected locationConfig: ILocationConfig;
protected seasonalEventConfig: ISeasonalEventConfig;
constructor(
@inject("PrimaryLogger") protected logger: ILogger,
@ -60,6 +62,7 @@ export class LocationLootGenerator {
@inject("PrimaryCloner") protected cloner: ICloner,
) {
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
result.push(...(staticWeaponsOnMapClone ?? []));
const allStaticContainersOnMapClone = this.cloner.clone(mapData.staticContainers.staticContainers);
let allStaticContainersOnMapClone = this.cloner.clone(mapData.staticContainers.staticContainers);
if (!allStaticContainersOnMapClone) {
this.logger.error(
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);
if (!staticForcedOnMapClone) {
this.logger.error(
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
let staticContainerCount = 0;
@ -579,6 +588,16 @@ export class LocationLootGenerator {
const loot: ISpawnpointTemplate[] = [];
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`
dynamicForcedSpawnPoints.push(...dynamicLootDist.spawnpointsForced);
dynamicForcedSpawnPoints.push(...dynamicLootDist.spawnpoints.filter((point) => point.template.IsAlwaysSpawn));

View File

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

View File

@ -273,12 +273,12 @@ export class LocationLifecycleService {
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) {
locationBaseClone.waves = [];
}
// We only need the base data
// Only requested base data, not loot
if (!generateLoot) {
return locationBaseClone;
}
@ -307,6 +307,7 @@ export class LocationLifecycleService {
name.toLowerCase(),
);
// Push chosen spawn points into returned object
for (const spawnPoint of dynamicSpawnPoints) {
locationBaseClone.Loot.push(spawnPoint);
}