From 705b06bd031dee5a6f4f7757a7e58e9215c4299c Mon Sep 17 00:00:00 2001 From: Rage Date: Mon, 6 Jan 2025 19:33:42 -0500 Subject: [PATCH] Added Weapon Customization Mod --- .../plugins/Tyfon.WeaponCustomizer.dll | Bin 0 -> 19968 bytes mods/Weapon Customizer/meta.ini | 28 +++++ .../mods/tyfon-weaponcustomizer/package.json | 33 ++++++ .../mods/tyfon-weaponcustomizer/src/mod.ts | 100 ++++++++++++++++++ profiles/Multiplayer/modlist.txt | 1 + profiles/Server/modlist.txt | 2 +- 6 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 mods/Weapon Customizer/BepInEx/plugins/Tyfon.WeaponCustomizer.dll create mode 100644 mods/Weapon Customizer/meta.ini create mode 100644 mods/Weapon Customizer/user/mods/tyfon-weaponcustomizer/package.json create mode 100644 mods/Weapon Customizer/user/mods/tyfon-weaponcustomizer/src/mod.ts diff --git a/mods/Weapon Customizer/BepInEx/plugins/Tyfon.WeaponCustomizer.dll b/mods/Weapon Customizer/BepInEx/plugins/Tyfon.WeaponCustomizer.dll new file mode 100644 index 0000000000000000000000000000000000000000..53b0bb26ce3caf7969ceeb4b92608f413193de13 GIT binary patch literal 19968 zcmeHve|%h3weLDV=FE>Ilgy+^Tbj00=#OcVPLnqM1*J4i(l*c^p-BpbN;;XGG(#tI z(law{V+c${ke_N5(W)Q?y~5SYM?}5C6NRgY+*`chPq-=<9_j@Z#rr_Tr{#UuI%j^Q zEqeXDzuxEFL(V#Dt-bczd#|cZgFK3Z^B)e< z7yM5x__DI?sRex_$xLL-w)Wfc(MTemPFvZ?pc%1q=}0mi>D<{H8MTJYSXEVEp{u&5 zi)fpoQQ&_(bF|Rf3v_m*LTMrD1jpxaznQ=@f;*3!s77$r={GYB27En=8+^Vr+IJm` z@?YuclFY(&5PEkqlE;{JMozizBB})ImO-MvQ;Pl~87X#M#C)K)mQ{#l%_CXRCprL7 zCS!H`4N9&E(Y~0Sv3cmyw>%IY=w{qy*G3e_Y%^s+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L(05r@y~e1zcB7>)$c)`RaeBhwbi2;@#b-4iS@ zv#4WC`Z*3>T=a1l|CU9U<#&s|f;BqPs|=17&U=FLvHz`lTabR0qHT6VFW$J8*|N0W z^P127m;-tChI1fFV@#>Ck^L?0$8ao5;Xl6kUtuWtvW?$3wB|OJ@&WRx4a*Y-<$*65IoDrxBnZzy$f%86!!pF(08hpOEzx8A+;5D zUV}(%6Sx-N<*uUD7}qf1T0947C9oE7S3!CRaxEw`0S8gO2K9%*Uj+{H_*yGIZiip_ rEI$gl6f7HoFQZ{a1=e_#LqS>XQwN%5ps literal 0 HcmV?d00001 diff --git a/mods/Weapon Customizer/meta.ini b/mods/Weapon Customizer/meta.ini new file mode 100644 index 0000000..0ca81db --- /dev/null +++ b/mods/Weapon Customizer/meta.ini @@ -0,0 +1,28 @@ +[General] +gameName=spt +modid=0 +version=d2025.1.6.0 +newestVersion= +category="2," +nexusFileStatus=1 +installationFile=Tyfon-WeaponCustomizer-1.0.0.zip +repository=Nexus +ignoredVersion= +comments= +notes= +nexusDescription= +url= +hasCustomURL=false +lastNexusQuery= +lastNexusUpdate= +nexusLastModified=2025-01-07T00:12:11Z +nexusCategory=0 +converted=false +validated=false +color=@Variant(\0\0\0\x43\0\xff\xff\0\0\0\0\0\0\0\0) +tracked=0 + +[installedFiles] +1\modid=0 +1\fileid=0 +size=1 diff --git a/mods/Weapon Customizer/user/mods/tyfon-weaponcustomizer/package.json b/mods/Weapon Customizer/user/mods/tyfon-weaponcustomizer/package.json new file mode 100644 index 0000000..ea0ce22 --- /dev/null +++ b/mods/Weapon Customizer/user/mods/tyfon-weaponcustomizer/package.json @@ -0,0 +1,33 @@ +{ + "name": "weapon-customizer", + "version": "1.0.0", + "main": "src/mod.js", + "license": "MIT", + "author": "Tyfon", + "sptVersion": "~3.10", + "loadBefore": [], + "loadAfter": [], + "incompatibilities": [], + "contributors": [], + "isBundleMod": false, + "scripts": { + "setup": "npm i", + "build": "node ./build.mjs", + "buildinfo": "node ./build.mjs --verbose" + }, + "devDependencies": { + "@types/node": "20.11", + "@typescript-eslint/eslint-plugin": "7.2", + "@typescript-eslint/parser": "7.2", + "archiver": "^6.0", + "eslint": "8.57", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.1.3", + "fs-extra": "11.2", + "ignore": "^5.2", + "os": "^0.1", + "tsyringe": "4.8.0", + "typescript": "5.4", + "winston": "3.12" + } +} diff --git a/mods/Weapon Customizer/user/mods/tyfon-weaponcustomizer/src/mod.ts b/mods/Weapon Customizer/user/mods/tyfon-weaponcustomizer/src/mod.ts new file mode 100644 index 0000000..4c996e0 --- /dev/null +++ b/mods/Weapon Customizer/user/mods/tyfon-weaponcustomizer/src/mod.ts @@ -0,0 +1,100 @@ +import type { DependencyContainer } from "tsyringe"; + +import type { IPreSptLoadMod } from "@spt/models/external/IPreSptLoadMod"; +import { LogTextColor } from "@spt/models/spt/logging/LogTextColor"; +import type { ILogger } from "@spt/models/spt/utils/ILogger"; +import type { StaticRouterModService } from "@spt/services/mod/staticRouter/StaticRouterModService"; +import { VFS } from "@spt/utils/VFS"; +import fs from "node:fs"; +import path from "node:path"; + +type Vector3 = { + x: number; + y: number; + z: number; +}; + +type CustomPosition = { + original: Vector3; + modified: Vector3; +}; + +type CustomizePayload = { + weaponId: string; + slots: Record; +}; + +type Customizations = Record>; + +class WeaponCustomizer implements IPreSptLoadMod { + private logger: ILogger; + private vfs: VFS; + private customizations: Customizations = null; + private filepath: string; + + public preSptLoad(container: DependencyContainer): void { + this.logger = container.resolve("PrimaryLogger"); + this.vfs = container.resolve("VFS"); + const staticRouterModService = container.resolve("StaticRouterModService"); + + this.filepath = path.resolve(__dirname, "../customizations.json"); + this.load(); + + staticRouterModService.registerStaticRouter( + "WeaponCustomizerRoutes", + [ + { + url: "/weaponcustomizer/save", + action: async (url, info: CustomizePayload, sessionId, output) => this.saveCustomization(info) + }, + { + url: "/weaponcustomizer/load", + action: async (url, info, sessionId, output) => JSON.stringify(this.customizations) + } + ], + "custom-static-weapon-customizer" + ); + } + + private async saveCustomization(payload: CustomizePayload): Promise { + //this.logger.info(`WeaponCustomizer: Saving customization for weapon ${payload.weaponId}`); + if (Object.keys(payload.slots).length === 0) { + delete this.customizations[payload.weaponId]; + } else { + this.customizations[payload.weaponId] = payload.slots; + } + await this.save(); + return JSON.stringify({ success: true }); + } + + private load() { + try { + if (this.vfs.exists(this.filepath)) { + this.customizations = JSON.parse(this.vfs.readFile(this.filepath)); + } else { + this.customizations = {}; + + // Create the file with fs - vfs.writeFile pukes on windows paths if it needs to create the file + fs.writeFileSync(this.filepath, JSON.stringify(this.customizations)); + } + + const count = Object.keys(this.customizations).length; + if (count > 0) { + this.logger.logWithColor(`WeaponCustomizer: ${count} weapon customizations loaded.`, LogTextColor.CYAN); + } + } catch (error) { + this.logger.error("WeaponCustomizer: Failed to load weapon customization! " + error); + this.customizations = {}; + } + } + + private async save() { + try { + await this.vfs.writeFileAsync(this.filepath, JSON.stringify(this.customizations, null, 2)); + } catch (error) { + this.logger.error("WeaponCustomizer: Failed to save weapon customization! " + error); + } + } +} + +export const mod = new WeaponCustomizer(); diff --git a/profiles/Multiplayer/modlist.txt b/profiles/Multiplayer/modlist.txt index 8f7d1cd..70744e5 100644 --- a/profiles/Multiplayer/modlist.txt +++ b/profiles/Multiplayer/modlist.txt @@ -22,6 +22,7 @@ +SAIN - EpicRangeTimes Preset +SAIN -AI & Combat Tweaks_separator ++Weapon Customizer +Little Drummer Boy +SVD +M249 diff --git a/profiles/Server/modlist.txt b/profiles/Server/modlist.txt index 4b3528f..d4ca4dc 100644 --- a/profiles/Server/modlist.txt +++ b/profiles/Server/modlist.txt @@ -1,4 +1,3 @@ -# This file was automatically generated by Mod Organizer. +Unsorted_separator -Visceral Combat -SWAG + DONUTS @@ -22,6 +21,7 @@ +SAIN - EpicRangeTimes Preset +SAIN +AI & Combat Tweaks_separator +-Weapon Customizer +Little Drummer Boy +SVD +M249