Initial add of LoosekeyModifier
This commit is contained in:
commit
73eca5c27b
7
config/config.json
Normal file
7
config/config.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"relativeProbabilityThreshold": 3,
|
||||
"relativeProbabilitymultiplier": 20,
|
||||
"lootPileProbability": 0.10
|
||||
}
|
||||
|
||||
|
12
mod.code-workspace
Normal file
12
mod.code-workspace
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
}
|
||||
],
|
||||
"extensions": {
|
||||
"recommendations": [
|
||||
"dbaeumer.vscode-eslint"
|
||||
]
|
||||
}
|
||||
}
|
20
package.json
Normal file
20
package.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "LooseKeyModifier",
|
||||
"version": "1.0.0",
|
||||
"main": "src/mod.js",
|
||||
"license": "See License file",
|
||||
"author": "Kaeno",
|
||||
"akiVersion": "3.5.*",
|
||||
|
||||
"devDependencies": {
|
||||
"@types/node": "16.18.10",
|
||||
"@typescript-eslint/eslint-plugin": "5.46.1",
|
||||
"@typescript-eslint/parser": "5.46.1",
|
||||
"bestzip": "2.2.1",
|
||||
"eslint": "8.30.0",
|
||||
"fs-extra": "11.1.0",
|
||||
"glob": "8.0.3",
|
||||
"tsyringe": "4.7.0",
|
||||
"typescript": "4.9.4"
|
||||
}
|
||||
}
|
63
src/mod.ts
Normal file
63
src/mod.ts
Normal file
@ -0,0 +1,63 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
|
||||
import { Spawnpoint } from "@spt-aki/models/eft/common/ILooseLoot";
|
||||
import { BaseClasses } from "@spt-aki/models/enums/BaseClasses";
|
||||
import type { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod";
|
||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
||||
import { DependencyContainer } from "tsyringe";
|
||||
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const Config = require("../config/config.json");
|
||||
|
||||
class Lkm implements IPostDBLoadMod
|
||||
{
|
||||
// Code added here will load BEFORE the server has started loading
|
||||
public postDBLoad(container: DependencyContainer): void
|
||||
{
|
||||
// get the logger from the server container
|
||||
const DatabaseServer: DatabaseServer = container.resolve<DatabaseServer>("DatabaseServer");
|
||||
const logger = container.resolve<ILogger>("WinstonLogger");
|
||||
const itemHelper = container.resolve<ItemHelper>("ItemHelper");
|
||||
const database = DatabaseServer.getTables();
|
||||
const locations = database.locations;
|
||||
|
||||
for (const mapId in locations)
|
||||
{
|
||||
const spawnPoints: Spawnpoint[] = locations[mapId]?.looseLoot?.spawnpoints;
|
||||
if (!spawnPoints)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (const spawnPoint of spawnPoints)
|
||||
{
|
||||
for (const item of spawnPoint.template.Items)
|
||||
{
|
||||
if (itemHelper.isOfBaseclass(item._tpl, BaseClasses.KEY))
|
||||
{
|
||||
const matchingItem = spawnPoint.itemDistribution.find(x => x.composedKey.key === item._id);
|
||||
if (matchingItem)
|
||||
{
|
||||
if (spawnPoint.probability < Config.lootPileProbability)
|
||||
{
|
||||
spawnPoint.probability = Config.lootPileProbability;
|
||||
//logger.debug(`Updated Spawnpoint Probability having new probability of ${spawnPoint.probability} on loot pile ${spawnPoint.template.Id} on map ${mapId}`);
|
||||
|
||||
}
|
||||
if (matchingItem.relativeProbability < Config.relativeProbabilityThreshold)
|
||||
{
|
||||
matchingItem.relativeProbability *= Config.relativeProbabilitymultiplier;
|
||||
//logger.debug(`Updated ${item._tpl} having new relativeProbability of ${matchingItem.relativeProbability} on loot pile ${spawnPoint.template.Id} on map ${mapId}`);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.debug("Altering Probabilities Complete. Lkm");
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { mod: new Lkm() };
|
25
tsconfig.json
Normal file
25
tsconfig.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"module": "CommonJS",
|
||||
"target": "es2020",
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"downlevelIteration": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"resolveJsonModule": true,
|
||||
"outDir": "tmp",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@spt-aki/*": ["./types/*"]
|
||||
}
|
||||
},
|
||||
"lib": [
|
||||
"es2020"
|
||||
],
|
||||
"include": [
|
||||
"src/*",
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user