From c51b14873def797780d2706bd2f310849e3337a6 Mon Sep 17 00:00:00 2001 From: GetParanoid Date: Fri, 18 Jul 2025 16:16:19 -0500 Subject: [PATCH] feat(bosses have lega) --- .../acidphantasm-bosseshavelegamedals/LICENSE | 21 +++++++ .../README.md | 1 + .../config/config.jsonc | 13 +++++ .../package.json | 31 ++++++++++ .../src/mod.ts | 56 +++++++++++++++++++ 5 files changed, 122 insertions(+) create mode 100644 user/mods/acidphantasm-bosseshavelegamedals/LICENSE create mode 100644 user/mods/acidphantasm-bosseshavelegamedals/README.md create mode 100644 user/mods/acidphantasm-bosseshavelegamedals/config/config.jsonc create mode 100644 user/mods/acidphantasm-bosseshavelegamedals/package.json create mode 100644 user/mods/acidphantasm-bosseshavelegamedals/src/mod.ts diff --git a/user/mods/acidphantasm-bosseshavelegamedals/LICENSE b/user/mods/acidphantasm-bosseshavelegamedals/LICENSE new file mode 100644 index 0000000..f38cebf --- /dev/null +++ b/user/mods/acidphantasm-bosseshavelegamedals/LICENSE @@ -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. \ No newline at end of file diff --git a/user/mods/acidphantasm-bosseshavelegamedals/README.md b/user/mods/acidphantasm-bosseshavelegamedals/README.md new file mode 100644 index 0000000..bd5f7d8 --- /dev/null +++ b/user/mods/acidphantasm-bosseshavelegamedals/README.md @@ -0,0 +1 @@ +# Welcome to Bosses Have Lega Medals \ No newline at end of file diff --git a/user/mods/acidphantasm-bosseshavelegamedals/config/config.jsonc b/user/mods/acidphantasm-bosseshavelegamedals/config/config.jsonc new file mode 100644 index 0000000..86a424f --- /dev/null +++ b/user/mods/acidphantasm-bosseshavelegamedals/config/config.jsonc @@ -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 +} \ No newline at end of file diff --git a/user/mods/acidphantasm-bosseshavelegamedals/package.json b/user/mods/acidphantasm-bosseshavelegamedals/package.json new file mode 100644 index 0000000..22ee4da --- /dev/null +++ b/user/mods/acidphantasm-bosseshavelegamedals/package.json @@ -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" +} diff --git a/user/mods/acidphantasm-bosseshavelegamedals/src/mod.ts b/user/mods/acidphantasm-bosseshavelegamedals/src/mod.ts new file mode 100644 index 0000000..8156fb2 --- /dev/null +++ b/user/mods/acidphantasm-bosseshavelegamedals/src/mod.ts @@ -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"); + 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"); + this.logger = container.resolve("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();