Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
40f78e2775 | ||
![]() |
4f06544a00 |
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"relativeProbabilityThreshold": 3,
|
"relativeProbabilityThreshold": 3,
|
||||||
"relativeProbabilitymultiplier": 20,
|
"relativeProbabilitymultiplier": 20,
|
||||||
"LooseKeyPileProbability": 0.10,
|
"LooseKeyPileProbability": 0.2,
|
||||||
"AlterKeyCardProbability": true,
|
"AlterKeyCardProbability": true,
|
||||||
"LooseKeycardProbability": 0.02
|
"LooseKeycardProbability": 0.02,
|
||||||
}
|
"drawerStaticRelativeProbability": 1658,
|
||||||
|
"jacketStaticRelativeProbability": 829
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "LooseKeyModifier",
|
"name": "LooseKeyModifier",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"main": "src/mod.js",
|
"main": "src/mod.js",
|
||||||
"license": "See License file",
|
"license": "See License file",
|
||||||
"author": "Kaeno",
|
"author": "Kaeno",
|
||||||
"akiVersion": "^3.5.1",
|
"akiVersion": "^3.6.1",
|
||||||
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "16.18.10",
|
"@types/node": "16.18.10",
|
||||||
|
132
src/mod.ts
132
src/mod.ts
@ -1,57 +1,129 @@
|
|||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
|
||||||
import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
|
import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
|
||||||
import { Spawnpoint } from "@spt-aki/models/eft/common/ILooseLoot";
|
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 { BaseClasses } from "@spt-aki/models/enums/BaseClasses";
|
||||||
import type { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod";
|
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 { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
||||||
import { DependencyContainer } from "tsyringe";
|
import { DependencyContainer } from "tsyringe";
|
||||||
|
|
||||||
|
import config from "../config/config.json";
|
||||||
|
|
||||||
const Config = require("../config/config.json");
|
class Lkm implements IPostDBLoadMod
|
||||||
|
{
|
||||||
class Lkm implements IPostDBLoadMod {
|
public postDBLoad(container: DependencyContainer): void
|
||||||
public postDBLoad(container: DependencyContainer): void {
|
{
|
||||||
const DatabaseServer: DatabaseServer = container.resolve<DatabaseServer>("DatabaseServer");
|
const databaseServer: DatabaseServer = container.resolve<DatabaseServer>("DatabaseServer");
|
||||||
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;
|
||||||
|
const staticLoot = database.loot.staticLoot;
|
||||||
|
|
||||||
|
let count = 0;
|
||||||
|
let looseCount = 0;
|
||||||
|
let looseKCount = 0;
|
||||||
|
|
||||||
for (const mapId in locations) {
|
|
||||||
const spawnPoints: Spawnpoint[] = locations[mapId]?.looseLoot?.spawnpoints;
|
for (const staticName in staticLoot)
|
||||||
if (!spawnPoints) {
|
{
|
||||||
|
const staticy: ItemDistribution[] = staticLoot[staticName]?.itemDistribution;
|
||||||
|
if (!staticy)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (const spawnPoint of spawnPoints) {
|
if (staticName === "578f87b7245977356274f2cd") // Drawer
|
||||||
for (const item of spawnPoint.template.Items) {
|
{
|
||||||
if (itemHelper.isOfBaseclass(item._tpl, BaseClasses.KEY_MECHANICAL)) {
|
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)
|
||||||
|
{
|
||||||
|
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_MECHANICAL))
|
||||||
|
{
|
||||||
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) {
|
{
|
||||||
spawnPoint.probability = Config.LooseKeyPileProbability;
|
if (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.LooseKeyPileProbability;
|
||||||
|
|
||||||
}
|
}
|
||||||
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}`);
|
matchingItem.relativeProbability *= config.relativeProbabilitymultiplier;
|
||||||
}
|
}
|
||||||
|
looseCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Config.AlterKeyCardProbability && itemHelper.isOfBaseclass(item._tpl, BaseClasses.KEYCARD)) {
|
else
|
||||||
const matchingItem = spawnPoint.itemDistribution.find(x => x.composedKey.key === item._id);
|
{
|
||||||
if (matchingItem) {
|
// Any loot changes wont modify items inside of loot.json(Added Keycards from SPT Team)
|
||||||
if (spawnPoint.probability < Config.LooseKeycardProbability) {
|
if (itemHelper.isOfBaseclass(item._tpl, BaseClasses.KEYCARD) && config.AlterKeyCardProbability == true)
|
||||||
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?`);
|
const matchingItem = spawnPoint.itemDistribution.find(x => x.composedKey.key === item._id);
|
||||||
|
if (matchingItem)
|
||||||
|
{
|
||||||
|
if (spawnPoint.probability < config.LooseKeycardProbability)
|
||||||
|
{
|
||||||
|
spawnPoint.probability = config.LooseKeycardProbability;
|
||||||
|
looseKCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.debug("Altering Probabilities Complete. Lkm");
|
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`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = { mod: new Lkm() };
|
module.exports = { mod: new Lkm() };
|
Loading…
x
Reference in New Issue
Block a user