feat(bosses have lega)

This commit is contained in:
GetParanoid 2025-07-18 16:16:19 -05:00
parent 3477fdc789
commit c51b14873d
5 changed files with 122 additions and 0 deletions

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 acidphantasm
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1 @@
# Welcome to Bosses Have Lega Medals

View file

@ -0,0 +1,13 @@
{
// Liklihood of boss having a lega medal in pocket
// It's not strictly a percentage - see examples below
// A setting of 15 is roughly 15% chance
// A setting of 20 is roughly 19% chance
// A setting of 40 is roughly 36% chance
// A setting of 100 is roughly 66% chance
// A setting of 500 is roughly 97% chance
// IF YOU WANT TO SEE THE ACTUAL CHANCE OF THE VALUE YOU SET, ENABLE DEBUGLOGGING & LOOK IN YOUR SERVER LOG
"legaMedalChance": 15,
"debugLogging": false
}

View file

@ -0,0 +1,31 @@
{
"name": "Bosses Have Lega Medals",
"version": "1.3.0",
"sptVersion": "~3.11",
"loadBefore": [],
"loadAfter": [],
"incompatibilities": [],
"isBundleMod": false,
"main": "src/mod.js",
"scripts": {
"setup": "npm i",
"build": "node ./build.mjs",
"buildinfo": "node ./build.mjs --verbose"
},
"devDependencies": {
"@types/node": "22.10.5",
"@typescript-eslint/eslint-plugin": "7.2",
"@typescript-eslint/parser": "7.2",
"archiver": "^6.0",
"eslint": "8.57",
"fs-extra": "11.2",
"ignore": "^5.2",
"tsyringe": "4.8.0",
"typescript": "5.7.3",
"winston": "3.17.0",
"jsonc": "2.0.0"
},
"author": "acidphantasm",
"contributors": [],
"license": "MIT"
}

View file

@ -0,0 +1,56 @@
import { container, DependencyContainer } from "tsyringe";
import { IPostDBLoadMod } from "@spt/models/external/IPostDBLoadMod";
import { DatabaseService } from "@spt/services/DatabaseService";
import { IDatabaseTables } from "@spt/models/spt/server/IDatabaseTables";
import { ILogger } from "@spt/models/spt/utils/ILogger";
import { jsonc } from "jsonc";
import path from "path";
import { FileSystemSync } from "@spt/utils/FileSystemSync";
class BossesHaveLegaMedals implements IPostDBLoadMod
{
private logger: ILogger
private static fileSystemSync = container.resolve<FileSystemSync>("FileSystemSync");
private static config: Config = jsonc.parse(BossesHaveLegaMedals.fileSystemSync.read(path.resolve(__dirname, "../config/config.jsonc")));
public postDBLoad(container: DependencyContainer): void
{
const databaseService = container.resolve<DatabaseService>("DatabaseService");
this.logger = container.resolve<ILogger>("WinstonLogger");
const tables: IDatabaseTables = databaseService.getTables();
let chance = BossesHaveLegaMedals.config.legaMedalChance;
if (chance <= 0) chance = 1;
for (const botType in tables.bots.types)
{
if (!botType.includes("boss") || botType == "bosstest")
{
continue;
}
const bossPockets = tables.bots.types[botType].inventory.items.Pockets;
const bossTotal = Object.values(bossPockets).reduce((a, b) => a + b, 0);
let value = 0;
let guess = 0;
let rollChance = 0;
guess = chance / 100 * bossTotal;
value = Math.round((chance / 100) * (bossTotal + guess));
rollChance = value / (bossTotal + value)
//this.logger.debug(`[BossesHaveLegaMedals] ${botType}: ${(bossTotal + value)} --- if value: ${value} then chance is ${rollChance}`);
if (BossesHaveLegaMedals.config.debugLogging) this.logger.debug(`[BossesHaveLegaMedals] ${botType}: Chance is ${Number(rollChance).toLocaleString(undefined,{style: 'percent', minimumFractionDigits:2})}`);
bossPockets["6656560053eaaa7a23349c86"] = value;
}
}
}
interface Config
{
legaMedalChance: number,
debugLogging: boolean
}
export const mod = new BossesHaveLegaMedals();