Update LooseLootModifier to handle Container keys
This commit is contained in:
parent
d7f2acefc0
commit
4f06544a00
@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"relativeProbabilityThreshold": 3,
|
"relativeProbabilityThreshold": 3,
|
||||||
"relativeProbabilitymultiplier": 20,
|
"relativeProbabilitymultiplier": 20,
|
||||||
"LooseKeyPileProbability": 0.10,
|
"LooseKeyPileProbability": 0.2,
|
||||||
"AlterKeyCardProbability": true,
|
"AlterKeyCardProbability": true,
|
||||||
"LooseKeycardProbability": 0.02
|
"LooseKeycardProbability": 0.02,
|
||||||
}
|
"staticRelativeProbability": 1658
|
||||||
|
}
|
||||||
|
|
110
src/mod.ts
110
src/mod.ts
@ -1,57 +1,107 @@
|
|||||||
/* 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) {
|
for (const itemDistribution of staticy)
|
||||||
for (const item of spawnPoint.template.Items) {
|
{
|
||||||
if (itemHelper.isOfBaseclass(item._tpl, BaseClasses.KEY_MECHANICAL)) {
|
if (itemHelper.isOfBaseclass(itemDistribution.tpl, BaseClasses.KEY_MECHANICAL))
|
||||||
|
{
|
||||||
|
const matchingItem = staticy.find(s => s.tpl === itemDistribution.tpl);
|
||||||
|
if (matchingItem)
|
||||||
|
{
|
||||||
|
if (itemDistribution.relativeProbability < config.staticRelativeProbability)
|
||||||
|
{
|
||||||
|
// By Default this is based of the Yotota Key and been divided by 2
|
||||||
|
itemDistribution.relativeProbability = config.staticRelativeProbability;
|
||||||
|
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