Compare commits
No commits in common. "master" and "1.0.0" have entirely different histories.
@ -1,9 +1,7 @@
|
||||
{
|
||||
"relativeProbabilityThreshold": 3,
|
||||
"relativeProbabilitymultiplier": 20,
|
||||
"LooseKeyPileProbability": 0.2,
|
||||
"AlterKeyCardProbability": true,
|
||||
"LooseKeycardProbability": 0.02,
|
||||
"drawerStaticRelativeProbability": 1658,
|
||||
"jacketStaticRelativeProbability": 829
|
||||
}
|
||||
"lootPileProbability": 0.10
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "LooseKeyModifier",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.0",
|
||||
"main": "src/mod.js",
|
||||
"license": "See License file",
|
||||
"author": "Kaeno",
|
||||
"akiVersion": "^3.6.1",
|
||||
"akiVersion": "3.5.*",
|
||||
|
||||
"devDependencies": {
|
||||
"@types/node": "16.18.10",
|
||||
|
118
src/mod.ts
118
src/mod.ts
@ -1,129 +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 { ItemDistribution } from "@spt-aki/models/eft/common/tables/ILootBase";
|
||||
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";
|
||||
|
||||
import config from "../config/config.json";
|
||||
|
||||
// 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
|
||||
{
|
||||
const databaseServer: DatabaseServer = container.resolve<DatabaseServer>("DatabaseServer");
|
||||
// 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 database = DatabaseServer.getTables();
|
||||
const locations = database.locations;
|
||||
const staticLoot = database.loot.staticLoot;
|
||||
|
||||
let count = 0;
|
||||
let looseCount = 0;
|
||||
let looseKCount = 0;
|
||||
|
||||
|
||||
for (const staticName in staticLoot)
|
||||
{
|
||||
const staticy: ItemDistribution[] = staticLoot[staticName]?.itemDistribution;
|
||||
if (!staticy)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (staticName === "578f87b7245977356274f2cd") // Drawer
|
||||
{
|
||||
for (const itemDistribution of staticy)
|
||||
{
|
||||
if (itemHelper.isOfBaseclass(itemDistribution.tpl, BaseClasses.KEY_MECHANICAL))
|
||||
{
|
||||
const matchingItem = staticy.find(s => s.tpl === itemDistribution.tpl);
|
||||
if (matchingItem)
|
||||
{
|
||||
if (itemDistribution.relativeProbability < config.drawerStaticRelativeProbability)
|
||||
{
|
||||
// By Default this is based of the Yotota Key and been divided by 2
|
||||
itemDistribution.relativeProbability = config.drawerStaticRelativeProbability;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (staticName === "578f8778245977358849a9b5") // Jackets
|
||||
{
|
||||
for (const itemDistribution of staticy)
|
||||
{
|
||||
if (itemHelper.isOfBaseclass(itemDistribution.tpl, BaseClasses.KEY_MECHANICAL))
|
||||
{
|
||||
const matchingItem = staticy.find(s => s.tpl === itemDistribution.tpl);
|
||||
if (matchingItem)
|
||||
{
|
||||
if (itemDistribution.relativeProbability < (config.jacketStaticRelativeProbability))
|
||||
{
|
||||
// By Default this is based of the Yotota Key and been divided by 4
|
||||
itemDistribution.relativeProbability = (config.jacketStaticRelativeProbability);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(`Finished Altering ${count} Container Keys `);
|
||||
|
||||
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 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);
|
||||
if (matchingItem)
|
||||
if (matchingItem)
|
||||
{
|
||||
if (spawnPoint.probability < config.LooseKeyPileProbability)
|
||||
if (spawnPoint.probability < Config.lootPileProbability)
|
||||
{
|
||||
spawnPoint.probability = config.LooseKeyPileProbability;
|
||||
|
||||
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;
|
||||
}
|
||||
looseCount++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Any loot changes wont modify items inside of loot.json(Added Keycards from SPT Team)
|
||||
if (itemHelper.isOfBaseclass(item._tpl, BaseClasses.KEYCARD) && config.AlterKeyCardProbability == true)
|
||||
{
|
||||
const matchingItem = spawnPoint.itemDistribution.find(x => x.composedKey.key === item._id);
|
||||
if (matchingItem)
|
||||
{
|
||||
if (spawnPoint.probability < config.LooseKeycardProbability)
|
||||
{
|
||||
spawnPoint.probability = config.LooseKeycardProbability;
|
||||
looseKCount++;
|
||||
}
|
||||
matchingItem.relativeProbability *= Config.relativeProbabilitymultiplier;
|
||||
//logger.debug(`Updated ${item._tpl} having new relativeProbability of ${matchingItem.relativeProbability} on loot pile ${spawnPoint.template.Id} on map ${mapId}`);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (looseCount === 0 && looseKCount === 0)
|
||||
{
|
||||
console.log("No Items modified. Check config parameters");
|
||||
}
|
||||
else
|
||||
console.log(`Finished Altering ${looseCount} LooseLoot Keys and ${looseKCount} LooseLoot Keycards. Lkm`);
|
||||
logger.debug("Altering Probabilities Complete. Lkm");
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { mod: new Lkm() };
|
@ -12,7 +12,7 @@
|
||||
"outDir": "tmp",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@spt-aki/*": ["../../../src/*"]
|
||||
"@spt-aki/*": ["./types/*"]
|
||||
}
|
||||
},
|
||||
"lib": [
|
||||
|
Loading…
x
Reference in New Issue
Block a user