1.0.1 Update. Seperated Normal Keys and Keycards
This commit is contained in:
parent
73eca5c27b
commit
d7f2acefc0
@ -1,7 +1,9 @@
|
|||||||
{
|
{
|
||||||
"relativeProbabilityThreshold": 3,
|
"relativeProbabilityThreshold": 3,
|
||||||
"relativeProbabilitymultiplier": 20,
|
"relativeProbabilitymultiplier": 20,
|
||||||
"lootPileProbability": 0.10
|
"LooseKeyPileProbability": 0.10,
|
||||||
|
"AlterKeyCardProbability": true,
|
||||||
|
"LooseKeycardProbability": 0.02
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "LooseKeyModifier",
|
"name": "LooseKeyModifier",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"main": "src/mod.js",
|
"main": "src/mod.js",
|
||||||
"license": "See License file",
|
"license": "See License file",
|
||||||
"author": "Kaeno",
|
"author": "Kaeno",
|
||||||
"akiVersion": "3.5.*",
|
"akiVersion": "^3.5.1",
|
||||||
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "16.18.10",
|
"@types/node": "16.18.10",
|
||||||
|
50
src/mod.ts
50
src/mod.ts
@ -8,49 +8,44 @@ import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
|||||||
import { DependencyContainer } from "tsyringe";
|
import { DependencyContainer } from "tsyringe";
|
||||||
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
||||||
const Config = require("../config/config.json");
|
const Config = require("../config/config.json");
|
||||||
|
|
||||||
class Lkm implements IPostDBLoadMod
|
class Lkm implements IPostDBLoadMod {
|
||||||
{
|
public postDBLoad(container: DependencyContainer): void {
|
||||||
// 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 DatabaseServer: DatabaseServer = container.resolve<DatabaseServer>("DatabaseServer");
|
||||||
const logger = container.resolve<ILogger>("WinstonLogger");
|
const logger = container.resolve<ILogger>("WinstonLogger");
|
||||||
const itemHelper = container.resolve<ItemHelper>("ItemHelper");
|
const itemHelper = container.resolve<ItemHelper>("ItemHelper");
|
||||||
const database = DatabaseServer.getTables();
|
const database = DatabaseServer.getTables();
|
||||||
const locations = database.locations;
|
const locations = database.locations;
|
||||||
|
|
||||||
for (const mapId in locations)
|
for (const mapId in locations) {
|
||||||
{
|
|
||||||
const spawnPoints: Spawnpoint[] = locations[mapId]?.looseLoot?.spawnpoints;
|
const spawnPoints: Spawnpoint[] = locations[mapId]?.looseLoot?.spawnpoints;
|
||||||
if (!spawnPoints)
|
if (!spawnPoints) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (const spawnPoint of spawnPoints)
|
for (const spawnPoint of spawnPoints) {
|
||||||
{
|
for (const item of spawnPoint.template.Items) {
|
||||||
for (const item of spawnPoint.template.Items)
|
if (itemHelper.isOfBaseclass(item._tpl, BaseClasses.KEY_MECHANICAL)) {
|
||||||
{
|
|
||||||
if (itemHelper.isOfBaseclass(item._tpl, BaseClasses.KEY))
|
|
||||||
{
|
|
||||||
const matchingItem = spawnPoint.itemDistribution.find(x => x.composedKey.key === item._id);
|
const matchingItem = spawnPoint.itemDistribution.find(x => x.composedKey.key === item._id);
|
||||||
if (matchingItem)
|
if (matchingItem) {
|
||||||
{
|
if (spawnPoint.probability < Config.LooseKeyPileProbability) {
|
||||||
if (spawnPoint.probability < Config.lootPileProbability)
|
spawnPoint.probability = Config.LooseKeyPileProbability;
|
||||||
{
|
logger.debug(`Updated Spawnpoint Probability having new probability of ${spawnPoint.probability} on loot pile ${spawnPoint.template.Id} on map ${mapId}`);
|
||||||
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)
|
if (matchingItem.relativeProbability < Config.relativeProbabilityThreshold) {
|
||||||
{
|
|
||||||
matchingItem.relativeProbability *= Config.relativeProbabilitymultiplier;
|
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");
|
logger.debug("Altering Probabilities Complete. Lkm");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { mod: new Lkm() };
|
module.exports = { mod: new Lkm() };
|
@ -12,7 +12,7 @@
|
|||||||
"outDir": "tmp",
|
"outDir": "tmp",
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@spt-aki/*": ["./types/*"]
|
"@spt-aki/*": ["../../../src/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lib": [
|
"lib": [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user