From d7f2acefc0076f0e2d1bafbbcef46f370ebbc867 Mon Sep 17 00:00:00 2001 From: Kaeno <> Date: Sat, 22 Apr 2023 22:24:35 +0100 Subject: [PATCH] 1.0.1 Update. Seperated Normal Keys and Keycards --- config/config.json | 4 +++- package.json | 4 ++-- src/mod.ts | 52 ++++++++++++++++++++-------------------------- tsconfig.json | 2 +- 4 files changed, 29 insertions(+), 33 deletions(-) diff --git a/config/config.json b/config/config.json index 24bbf3f..78a7a64 100644 --- a/config/config.json +++ b/config/config.json @@ -1,7 +1,9 @@ { "relativeProbabilityThreshold": 3, "relativeProbabilitymultiplier": 20, - "lootPileProbability": 0.10 + "LooseKeyPileProbability": 0.10, + "AlterKeyCardProbability": true, + "LooseKeycardProbability": 0.02 } diff --git a/package.json b/package.json index da5aaf8..4f18914 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "LooseKeyModifier", - "version": "1.0.0", + "version": "1.0.1", "main": "src/mod.js", "license": "See License file", "author": "Kaeno", - "akiVersion": "3.5.*", + "akiVersion": "^3.5.1", "devDependencies": { "@types/node": "16.18.10", diff --git a/src/mod.ts b/src/mod.ts index 01df905..0affd46 100644 --- a/src/mod.ts +++ b/src/mod.ts @@ -8,49 +8,44 @@ 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 +class Lkm implements IPostDBLoadMod { + public postDBLoad(container: DependencyContainer): void { const DatabaseServer: DatabaseServer = container.resolve("DatabaseServer"); const logger = container.resolve("WinstonLogger"); const itemHelper = container.resolve("ItemHelper"); const database = DatabaseServer.getTables(); const locations = database.locations; - - for (const mapId in locations) - { + + for (const mapId in locations) { const spawnPoints: Spawnpoint[] = locations[mapId]?.looseLoot?.spawnpoints; - if (!spawnPoints) - { + if (!spawnPoints) { continue; } - for (const spawnPoint of spawnPoints) - { - for (const item of spawnPoint.template.Items) - { - if (itemHelper.isOfBaseclass(item._tpl, BaseClasses.KEY)) - { + for (const spawnPoint of spawnPoints) { + for (const item of spawnPoint.template.Items) { + if (itemHelper.isOfBaseclass(item._tpl, BaseClasses.KEY_MECHANICAL)) { 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) { + if (spawnPoint.probability < Config.LooseKeyPileProbability) { + spawnPoint.probability = Config.LooseKeyPileProbability; + 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) - { + 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(`Updated ${item._tpl} having new relativeProbability of ${matchingItem.relativeProbability} on loot pile ${spawnPoint.template.Id} on map ${mapId}`); + } + } + } + if (Config.AlterKeyCardProbability && itemHelper.isOfBaseclass(item._tpl, BaseClasses.KEYCARD)) { + const matchingItem = spawnPoint.itemDistribution.find(x => x.composedKey.key === item._id); + if (matchingItem) { + if (spawnPoint.probability < Config.LooseKeycardProbability) { + spawnPoint.probability = Config.LooseKeycardProbability; + logger.debug(`Updated Spawnpoint Probability having new probability of ${spawnPoint.probability} on loot pile ${spawnPoint.template.Id} on map ${mapId} KEYCARD?`); } - } } } @@ -59,5 +54,4 @@ class Lkm implements IPostDBLoadMod logger.debug("Altering Probabilities Complete. Lkm"); } } - module.exports = { mod: new Lkm() }; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 8151310..0d790c7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,7 @@ "outDir": "tmp", "baseUrl": ".", "paths": { - "@spt-aki/*": ["./types/*"] + "@spt-aki/*": ["../../../src/*"] } }, "lib": [