mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-12 15:50:42 -05:00
Migrate loot generation code to use per-map static data - ONLY WORKS WITH CUSTOMS (other maps to follow later)
This commit is contained in:
parent
a4bb5a2f60
commit
57557d6063
4
.gitattributes
vendored
4
.gitattributes
vendored
@ -66,5 +66,7 @@ project/assets/database/locations/factory4_day/looseLoot.json filter=lfs diff=lf
|
||||
project/assets/database/locations/factory4_night/looseLoot.json filter=lfs diff=lfs merge=lfs -text
|
||||
project/assets/database/locations/rezervbase/looseLoot.json filter=lfs diff=lfs merge=lfs -text
|
||||
project/assets/database/locations/bigmap/looseLoot.json filter=lfs diff=lfs merge=lfs -text
|
||||
project/assets/database/locations/bigmap/staticLoot.json filter=lfs diff=lfs merge=lfs -text
|
||||
project/assets/database/locations/bigmap/staticContainers.json filter=lfs diff=lfs merge=lfs -text
|
||||
project/assets/database/locations/bigmap/staticAmmo.json filter=lfs diff=lfs merge=lfs -text
|
||||
project/assets/database/locations/laboratory/looseLoot.json filter=lfs diff=lfs merge=lfs -text
|
||||
project/assets/database/loot/* filter=lfs diff=lfs merge=lfs -text
|
||||
|
BIN
project/assets/database/locations/bigmap/looseLoot.json
(Stored with Git LFS)
BIN
project/assets/database/locations/bigmap/looseLoot.json
(Stored with Git LFS)
Binary file not shown.
1
project/assets/database/locations/bigmap/staticAmmo.json
Normal file
1
project/assets/database/locations/bigmap/staticAmmo.json
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
project/assets/database/locations/bigmap/staticLoot.json
Normal file
1
project/assets/database/locations/bigmap/staticLoot.json
Normal file
File diff suppressed because one or more lines are too long
BIN
project/assets/database/loot/staticAmmo.json
(Stored with Git LFS)
BIN
project/assets/database/loot/staticAmmo.json
(Stored with Git LFS)
Binary file not shown.
BIN
project/assets/database/loot/staticContainers.json
(Stored with Git LFS)
BIN
project/assets/database/loot/staticContainers.json
(Stored with Git LFS)
Binary file not shown.
BIN
project/assets/database/loot/staticLoot.json
(Stored with Git LFS)
BIN
project/assets/database/loot/staticLoot.json
(Stored with Git LFS)
Binary file not shown.
@ -102,7 +102,7 @@ export class LocationController
|
||||
this.raidTimeAdjustmentService.makeAdjustmentsToMap(raidAdjustments, locationBaseClone);
|
||||
}
|
||||
|
||||
const staticAmmoDist = this.jsonUtil.clone(db.loot.staticAmmo);
|
||||
const staticAmmoDist = this.jsonUtil.clone(location.staticAmmo);
|
||||
|
||||
// Create containers and add loot to them
|
||||
const staticLoot = this.locationGenerator.generateStaticContainers(locationBaseClone, staticAmmoDist);
|
||||
|
@ -3,16 +3,18 @@ import { inject, injectable } from "tsyringe";
|
||||
import { ContainerHelper } from "@spt-aki/helpers/ContainerHelper";
|
||||
import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
|
||||
import { PresetHelper } from "@spt-aki/helpers/PresetHelper";
|
||||
import { IContainerMinMax, IStaticContainer } from "@spt-aki/models/eft/common/ILocation";
|
||||
import { ILocationBase } from "@spt-aki/models/eft/common/ILocationBase";
|
||||
import { ILooseLoot, Spawnpoint, SpawnpointTemplate, SpawnpointsForced } from "@spt-aki/models/eft/common/ILooseLoot";
|
||||
import { Item } from "@spt-aki/models/eft/common/tables/IItem";
|
||||
import {
|
||||
IContainerMinMax,
|
||||
ILocation,
|
||||
IStaticAmmoDetails,
|
||||
IStaticContainer,
|
||||
IStaticContainerData,
|
||||
IStaticForcedProps,
|
||||
IStaticLootDetails,
|
||||
} from "@spt-aki/models/eft/common/tables/ILootBase";
|
||||
} from "@spt-aki/models/eft/common/ILocation";
|
||||
import { ILocationBase } from "@spt-aki/models/eft/common/ILocationBase";
|
||||
import { ILooseLoot, Spawnpoint, SpawnpointTemplate, SpawnpointsForced } from "@spt-aki/models/eft/common/ILooseLoot";
|
||||
import { Item } from "@spt-aki/models/eft/common/tables/IItem";
|
||||
import { BaseClasses } from "@spt-aki/models/enums/BaseClasses";
|
||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||
import { Money } from "@spt-aki/models/enums/Money";
|
||||
@ -81,8 +83,9 @@ export class LocationGenerator
|
||||
const locationId = locationBase.Id.toLowerCase();
|
||||
|
||||
const db = this.databaseServer.getTables();
|
||||
const mapData: ILocation = db.locations[locationId];
|
||||
|
||||
const staticWeaponsOnMapClone = this.jsonUtil.clone(db.loot.staticContainers[locationBase.Name]?.staticWeapons);
|
||||
const staticWeaponsOnMapClone = this.jsonUtil.clone(mapData.staticContainers.staticWeapons);
|
||||
if (!staticWeaponsOnMapClone)
|
||||
{
|
||||
this.logger.error(`Unable to find static weapon data for map: ${locationBase.Name}`);
|
||||
@ -91,9 +94,7 @@ export class LocationGenerator
|
||||
// Add mounted weapons to output loot
|
||||
result.push(...staticWeaponsOnMapClone ?? []);
|
||||
|
||||
const allStaticContainersOnMapClone = this.jsonUtil.clone(
|
||||
db.loot.staticContainers[locationBase.Name]?.staticContainers,
|
||||
);
|
||||
const allStaticContainersOnMapClone = this.jsonUtil.clone(mapData.staticContainers.staticContainers);
|
||||
if (!allStaticContainersOnMapClone)
|
||||
{
|
||||
this.logger.error(`Unable to find static container data for map: ${locationBase.Name}`);
|
||||
@ -101,7 +102,7 @@ export class LocationGenerator
|
||||
const staticRandomisableContainersOnMap = this.getRandomisableContainersOnMap(allStaticContainersOnMapClone);
|
||||
|
||||
// Containers that MUST be added to map (quest containers etc)
|
||||
const staticForcedOnMapClone = this.jsonUtil.clone(db.loot.staticContainers[locationBase.Name]?.staticForced);
|
||||
const staticForcedOnMapClone = this.jsonUtil.clone(mapData.staticContainers.staticForced);
|
||||
if (!staticForcedOnMapClone)
|
||||
{
|
||||
this.logger.error(`Unable to find forced static data for map: ${locationBase.Name}`);
|
||||
@ -111,7 +112,7 @@ export class LocationGenerator
|
||||
let staticContainerCount = 0;
|
||||
|
||||
// Find all 100% spawn containers
|
||||
const staticLootDist = db.loot.staticLoot;
|
||||
const staticLootDist = mapData.staticLoot;
|
||||
const guaranteedContainers = this.getGuaranteedContainers(allStaticContainersOnMapClone);
|
||||
staticContainerCount += guaranteedContainers.length;
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { inject, injectable } from "tsyringe";
|
||||
|
||||
import { HandbookHelper } from "@spt-aki/helpers/HandbookHelper";
|
||||
import { IStaticAmmoDetails } from "@spt-aki/models/eft/common/ILocation";
|
||||
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
|
||||
import { InsuredItem } from "@spt-aki/models/eft/common/tables/IBotBase";
|
||||
import { Item, Location, Repairable } from "@spt-aki/models/eft/common/tables/IItem";
|
||||
import { IStaticAmmoDetails } from "@spt-aki/models/eft/common/tables/ILootBase";
|
||||
import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem";
|
||||
import { BaseClasses } from "@spt-aki/models/enums/BaseClasses";
|
||||
import { EquipmentSlots } from "@spt-aki/models/enums/EquipmentSlots";
|
||||
|
@ -1,11 +1,22 @@
|
||||
import { Exit, ILocationBase } from "@spt-aki/models/eft/common/ILocationBase";
|
||||
import { ILooseLoot } from "@spt-aki/models/eft/common/ILooseLoot";
|
||||
import { Ixyz } from "./Ixyz";
|
||||
import { Item } from "./tables/IItem";
|
||||
|
||||
export interface ILocation
|
||||
{
|
||||
/** Map meta-data */
|
||||
base: ILocationBase;
|
||||
/** Loose loot postions and item weights */
|
||||
looseLoot: ILooseLoot;
|
||||
/** Static loot item weights */
|
||||
staticLoot: Record<string, IStaticLootDetails>;
|
||||
/** Static container postions and item weights */
|
||||
staticContainers: IStaticContainerDetails;
|
||||
staticAmmo: Record<string, IStaticAmmoDetails[]>;
|
||||
/** All possible static containers on map + their assign groupings */
|
||||
statics: IStaticContainer;
|
||||
/** All possible map extracts */
|
||||
allExtracts: Exit[];
|
||||
}
|
||||
|
||||
@ -27,3 +38,77 @@ export interface IContainerData
|
||||
{
|
||||
groupId: string;
|
||||
}
|
||||
|
||||
export interface IStaticLootDetails
|
||||
{
|
||||
itemcountDistribution: ItemCountDistribution[];
|
||||
itemDistribution: ItemDistribution[];
|
||||
}
|
||||
|
||||
export interface ItemCountDistribution
|
||||
{
|
||||
count: number;
|
||||
relativeProbability: number;
|
||||
}
|
||||
|
||||
export interface ItemDistribution
|
||||
{
|
||||
tpl: string;
|
||||
relativeProbability: number;
|
||||
}
|
||||
|
||||
export interface IStaticPropsBase
|
||||
{
|
||||
Id: string;
|
||||
IsContainer: boolean;
|
||||
useGravity: boolean;
|
||||
randomRotation: boolean;
|
||||
Position: Ixyz;
|
||||
Rotation: Ixyz;
|
||||
IsGroupPosition: boolean;
|
||||
IsAlwaysSpawn: boolean;
|
||||
GroupPositions: any[];
|
||||
Root: string;
|
||||
Items: any[];
|
||||
}
|
||||
|
||||
export interface IStaticWeaponProps extends IStaticPropsBase
|
||||
{
|
||||
Items: Item[];
|
||||
}
|
||||
|
||||
export interface IStaticContainerDetails
|
||||
{
|
||||
staticWeapons: IStaticWeaponProps[];
|
||||
staticContainers: IStaticContainerData[];
|
||||
staticForced: IStaticForcedProps[];
|
||||
}
|
||||
|
||||
export interface IStaticContainerData
|
||||
{
|
||||
probability: number;
|
||||
template: IStaticContainerProps;
|
||||
}
|
||||
|
||||
export interface IStaticAmmoDetails
|
||||
{
|
||||
tpl: string;
|
||||
relativeProbability: number;
|
||||
}
|
||||
|
||||
export interface IStaticForcedProps
|
||||
{
|
||||
containerId: string;
|
||||
itemTpl: string;
|
||||
}
|
||||
|
||||
export interface IStaticContainerProps extends IStaticPropsBase
|
||||
{
|
||||
Items: StaticItem[];
|
||||
}
|
||||
|
||||
export interface StaticItem
|
||||
{
|
||||
_id: string;
|
||||
_tpl: string;
|
||||
}
|
||||
|
@ -1,83 +0,0 @@
|
||||
import { Ixyz } from "@spt-aki/models/eft/common/Ixyz";
|
||||
import { Item } from "@spt-aki/models/eft/common/tables/IItem";
|
||||
|
||||
export interface ILootBase
|
||||
{
|
||||
staticAmmo: Record<string, IStaticAmmoDetails[]>;
|
||||
staticContainers: Record<string, IStaticContainerDetails>;
|
||||
staticLoot: Record<string, IStaticLootDetails>;
|
||||
}
|
||||
|
||||
export interface IStaticAmmoDetails
|
||||
{
|
||||
tpl: string;
|
||||
relativeProbability: number;
|
||||
}
|
||||
|
||||
export interface IStaticContainerDetails
|
||||
{
|
||||
staticWeapons: IStaticWeaponProps[];
|
||||
staticContainers: IStaticContainerData[];
|
||||
staticForced: IStaticForcedProps[];
|
||||
}
|
||||
|
||||
export interface IStaticContainerData
|
||||
{
|
||||
probability: number;
|
||||
template: IStaticContainerProps;
|
||||
}
|
||||
|
||||
export interface IStaticPropsBase
|
||||
{
|
||||
Id: string;
|
||||
IsContainer: boolean;
|
||||
useGravity: boolean;
|
||||
randomRotation: boolean;
|
||||
Position: Ixyz;
|
||||
Rotation: Ixyz;
|
||||
IsGroupPosition: boolean;
|
||||
IsAlwaysSpawn: boolean;
|
||||
GroupPositions: any[];
|
||||
Root: string;
|
||||
Items: any[];
|
||||
}
|
||||
|
||||
export interface IStaticWeaponProps extends IStaticPropsBase
|
||||
{
|
||||
Items: Item[];
|
||||
}
|
||||
|
||||
export interface IStaticContainerProps extends IStaticPropsBase
|
||||
{
|
||||
Items: StaticItem[];
|
||||
}
|
||||
|
||||
export interface StaticItem
|
||||
{
|
||||
_id: string;
|
||||
_tpl: string;
|
||||
}
|
||||
|
||||
export interface IStaticForcedProps
|
||||
{
|
||||
containerId: string;
|
||||
itemTpl: string;
|
||||
}
|
||||
|
||||
export interface IStaticLootDetails
|
||||
{
|
||||
itemcountDistribution: ItemCountDistribution[];
|
||||
itemDistribution: ItemDistribution[];
|
||||
}
|
||||
|
||||
export interface ItemCountDistribution
|
||||
{
|
||||
count: number;
|
||||
relativeProbability: number;
|
||||
}
|
||||
|
||||
export interface ItemDistribution
|
||||
{
|
||||
tpl: string;
|
||||
relativeProbability: number;
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
import { ILooseLoot, SpawnpointTemplate } from "@spt-aki/models/eft/common/ILooseLoot";
|
||||
import {
|
||||
IStaticAmmoDetails,
|
||||
IStaticContainerProps,
|
||||
IStaticForcedProps,
|
||||
IStaticLootDetails,
|
||||
} from "@spt-aki/models/eft/common/tables/ILootBase";
|
||||
} from "@spt-aki/models/eft/common/ILocation";
|
||||
import { ILooseLoot, SpawnpointTemplate } from "@spt-aki/models/eft/common/ILooseLoot";
|
||||
|
||||
export interface ILocationGenerator
|
||||
{
|
||||
|
@ -5,7 +5,6 @@ import { IBotCore } from "@spt-aki/models/eft/common/tables/IBotCore";
|
||||
import { IBotType } from "@spt-aki/models/eft/common/tables/IBotType";
|
||||
import { ICustomizationItem } from "@spt-aki/models/eft/common/tables/ICustomizationItem";
|
||||
import { IHandbookBase } from "@spt-aki/models/eft/common/tables/IHandbookBase";
|
||||
import { ILootBase } from "@spt-aki/models/eft/common/tables/ILootBase";
|
||||
import { IMatch } from "@spt-aki/models/eft/common/tables/IMatch";
|
||||
import { IProfileTemplates } from "@spt-aki/models/eft/common/tables/IProfileTemplate";
|
||||
import { IQuest } from "@spt-aki/models/eft/common/tables/IQuest";
|
||||
@ -35,7 +34,6 @@ export interface IDatabaseTables
|
||||
};
|
||||
locales?: ILocaleBase;
|
||||
locations?: ILocations;
|
||||
loot?: ILootBase;
|
||||
match?: IMatch;
|
||||
templates?: {
|
||||
character: string[];
|
||||
|
@ -10,7 +10,6 @@ export class DatabaseServer
|
||||
hideout: undefined,
|
||||
locales: undefined,
|
||||
locations: undefined,
|
||||
loot: undefined,
|
||||
match: undefined,
|
||||
templates: undefined,
|
||||
traders: undefined,
|
||||
|
Loading…
x
Reference in New Issue
Block a user