Skip to content

Commit

Permalink
Added system to strip children from containers defined in new config …
Browse files Browse the repository at this point in the history
…property `tplsToStripChildItemsFrom`

Fixes Christmas gifts causing strange behaviour when moved to stash as we generate container gift loot when player opens then
  • Loading branch information
Chomp committed Jan 8, 2025
1 parent 0eb31c4 commit 33591df
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions project/assets/configs/location.json
Original file line number Diff line number Diff line change
Expand Up @@ -539,5 +539,11 @@
"nonTriggered": 80,
"triggered": 90
},
"tplsToStripChildItemsFrom": [
"63a8970d7108f713591149f5",
"63a897c6b1ff6e29734fcc95",
"63a898a328e385334e0640a5",
"634959225289190e5e773b3b"
],
"nonMaps": ["base", "develop", "hideout", "privatearea", "suburbs", "terminal", "town"]
}
10 changes: 9 additions & 1 deletion project/src/generators/LocationLootGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,10 @@ export class LocationLootGenerator {
const tplsToAddToContainer = tplsForced.concat(chosenTpls);
for (const tplToAdd of tplsToAddToContainer) {
const chosenItemWithChildren = this.createStaticLootItem(tplToAdd, staticAmmoDist, parentId);
const items = chosenItemWithChildren.items;

const items = this.locationConfig.tplsToStripChildItemsFrom.includes(tplToAdd)
? [chosenItemWithChildren.items[0]] // Strip children from parent
: chosenItemWithChildren.items;
const width = chosenItemWithChildren.width;
const height = chosenItemWithChildren.height;

Expand Down Expand Up @@ -918,6 +921,11 @@ export class LocationLootGenerator {
// Ensure all IDs are unique
itemWithChildren = this.itemHelper.replaceIDs(itemWithChildren);

if (this.locationConfig.tplsToStripChildItemsFrom.includes(chosenItem._tpl)) {
// Strip children from parent before adding
itemWithChildren = [itemWithChildren[0]];
}

itemWithMods.push(...itemWithChildren);
}

Expand Down
2 changes: 2 additions & 0 deletions project/src/models/spt/config/ILocationConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export interface ILocationConfig extends IBaseConfig {
equipmentLootSettings: IEquipmentLootSettings;
/** min percentage to set raider spawns at, -1 makes no changes */
reserveRaiderSpawnChanceOverrides: IReserveRaiderSpawnChanceOverrides;
/** Containers to remove all children from when generating static/loose loot */
tplsToStripChildItemsFrom: string[];
/** Map ids players cannot visit */
nonMaps: string[];
}
Expand Down

0 comments on commit 33591df

Please sign in to comment.