1.0.1 Update. Seperated Normal Keys and Keycards
This commit is contained in:
parent
73eca5c27b
commit
d7f2acefc0
@ -1,7 +1,9 @@
|
||||
{
|
||||
"relativeProbabilityThreshold": 3,
|
||||
"relativeProbabilitymultiplier": 20,
|
||||
"lootPileProbability": 0.10
|
||||
"LooseKeyPileProbability": 0.10,
|
||||
"AlterKeyCardProbability": true,
|
||||
"LooseKeycardProbability": 0.02
|
||||
}
|
||||
|
||||
|
||||
|
@ -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",
|
||||
|
50
src/mod.ts
50
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>("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)
|
||||
{
|
||||
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() };
|
@ -12,7 +12,7 @@
|
||||
"outDir": "tmp",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@spt-aki/*": ["./types/*"]
|
||||
"@spt-aki/*": ["../../../src/*"]
|
||||
}
|
||||
},
|
||||
"lib": [
|
||||
|
Loading…
x
Reference in New Issue
Block a user