diff --git a/.nvmrc b/.nvmrc index d6af9a0..cd9b7db 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v14.15.3 +v14.15.3 diff --git a/CustomStamina.png b/CustomStamina.png index 37129d1..a55251e 100644 Binary files a/CustomStamina.png and b/CustomStamina.png differ diff --git a/config/config.json b/config/config.json index 5d3eac4..70480f3 100644 --- a/config/config.json +++ b/config/config.json @@ -1,63 +1,63 @@ -{ - "_comment": "Enables the use of the mod. [true/false]", - "mod_enabled": true, - - "_comment": "Verbose logging. [true/false]", - "debug": false, - - "_comment": "Selects the method to adjust stamina. ['unlimited'/'percent'/'fixed']", - "adjustment_method": "percent", - - "_comment": "The percentage the stamina values will be adjusted by. [integer]", - "_comment": "A positive value will increase stamina capacities and regeneration rates, but lower the drain rates.", - "_comment": "Only used if adjustment_method is set to 'percent'.", - "_comment": "Example: 50% (increase) to 200 = 300", - "_comment": "Example: -50% (decrease) to 200 = 100", - "percent_stamina": 15, - - "_comment": "Set the stamina values manually.", - "_comment": "Only used if adjustment_method is set to 'fixed'.", - "AimConsumptionByPose": { - "x": 0.15, - "y": 0.75, - "z": 1 - }, - "AimDrainRate": 1.1, - "AimRangeFinderDrainRate": 0.55, - "BaseHoldBreathConsumption": 4, - "BaseRestorationRate": 4.4, - "Capacity": 100, - "CrouchConsumption": { - "x": 0.17, - "y": 1 - }, - "GrenadeHighThrow": 11, - "GrenadeLowThrow": 8, - "HoldBreathStaminaMultiplier": { - "x": 2, - "y": 1 - }, - "HandsCapacity": 70, - "HandsRestoration": 2.1, - "JumpConsumption": 16, - "OxygenCapacity": 300, - "OxygenRestoration": 4, - "PoseLevelConsumptionPerNotch": { - "x": 1.1, - "y": 3 - }, - "ProneConsumption": 1, - "SitToStandConsumption": 1, - "SprintDrainRate": 4.2, - "StaminaExhaustionCausesJiggle": true, - "StaminaExhaustionRocksCamera": false, - "StaminaExhaustionStartsBreathSound": true, - "StandupConsumption": { - "x": 10, - "y": 20 - }, - "WalkConsumption": { - "x": 0.2, - "y": 0.5 - } -} +{ + "_comment": "Enables the use of the mod. [true/false]", + "mod_enabled": true, + + "_comment": "Verbose logging. [true/false]", + "debug": false, + + "_comment": "Selects the method to adjust stamina. ['unlimited'/'percent'/'fixed']", + "adjustment_method": "percent", + + "_comment": "The percentage the stamina values will be adjusted by. [integer]", + "_comment": "A positive value will increase stamina capacities and regeneration rates, but lower the drain rates.", + "_comment": "Only used if adjustment_method is set to 'percent'.", + "_comment": "Example: 50% (increase) to 200 = 300", + "_comment": "Example: -50% (decrease) to 200 = 100", + "percent_stamina": 15, + + "_comment": "Set the stamina values manually.", + "_comment": "Only used if adjustment_method is set to 'fixed'.", + "AimConsumptionByPose": { + "x": 0.15, + "y": 0.75, + "z": 1 + }, + "AimDrainRate": 1.1, + "AimRangeFinderDrainRate": 0.55, + "BaseHoldBreathConsumption": 4, + "BaseRestorationRate": 4.4, + "Capacity": 100, + "CrouchConsumption": { + "x": 0.17, + "y": 1 + }, + "GrenadeHighThrow": 11, + "GrenadeLowThrow": 8, + "HoldBreathStaminaMultiplier": { + "x": 2, + "y": 1 + }, + "HandsCapacity": 70, + "HandsRestoration": 2.1, + "JumpConsumption": 16, + "OxygenCapacity": 300, + "OxygenRestoration": 4, + "PoseLevelConsumptionPerNotch": { + "x": 1.1, + "y": 3 + }, + "ProneConsumption": 1, + "SitToStandConsumption": 1, + "SprintDrainRate": 4.2, + "StaminaExhaustionCausesJiggle": true, + "StaminaExhaustionRocksCamera": false, + "StaminaExhaustionStartsBreathSound": true, + "StandupConsumption": { + "x": 10, + "y": 20 + }, + "WalkConsumption": { + "x": 0.2, + "y": 0.5 + } +} diff --git a/packageBuild.ts b/packageBuild.ts index 7011f84..3b53dd0 100644 --- a/packageBuild.ts +++ b/packageBuild.ts @@ -1,71 +1,71 @@ -#!/usr/bin/env node - -// This is a simple script used to build a mod package. The script will copy necessary files to the build directory -// and compress the build directory into a zip file that can be easily shared. - -const fs = require("fs-extra"); -const glob = require("glob"); -const zip = require('bestzip'); -const path = require("path"); - -// Load the package.json file to get some information about the package so we can name things appropriately. This is -// atypical, and you would never do this in a production environment, but this script is only used for development so -// it's fine in this case. Some of these values are stored in environment variables, but those differ between node -// versions; the 'author' value is not available after node v14. -const { author, name:packageName, version } = require("./package.json"); - -// Generate the name of the package, stripping out all non-alphanumeric characters in the 'author' and 'name'. -const modName = `${author.replace(/[^a-z0-9]/gi, "")}-${packageName.replace(/[^a-z0-9]/gi, "")}-${version}`; -console.log(`Generated package name: ${modName}`); - -// Delete the old build directory and compressed package file. -fs.rmSync(`${__dirname}/dist`, { force: true, recursive: true }); -console.log("Previous build files deleted."); - -// Generate a list of files that should not be copied over into the distribution directory. This is a blacklist to ensure -// we always copy over additional files and directories that authors may have added to their project. This may need to be -// expanded upon by the mod author to allow for node modules that are used within the mod; example commented out below. -const ignoreList = [ - "node_modules/", - // "node_modules/!(weighted|glob)", // Instead of excluding the entire node_modules directory, allow two node modules. - "src/**/*.js", - "types/", - ".git/", - ".github/", - ".eslintignore", - ".eslintrc.json", - ".gitignore", - ".DS_Store", - ".nvmrc", - "packageBuild.ts", - "mod.code-workspace", - "package-lock.json", - "tsconfig.json", - "CustomStamina.png" -]; -const exclude = glob.sync(`{${ignoreList.join(",")}}`, { realpath: true, dot: true }); - -// For some reason these basic-bitch functions won't allow us to copy a directory into itself, so we have to resort to -// using a temporary directory, like an idiot. Excuse the normalize spam; some modules cross-platform, some don't... -fs.copySync(__dirname, path.normalize(`${__dirname}/../~${modName}`), {filter:(filePath) => { - return !exclude.includes(filePath); -}}); -fs.moveSync(path.normalize(`${__dirname}/../~${modName}`), path.normalize(`${__dirname}/${modName}`), { overwrite: true }); -fs.copySync(path.normalize(`${__dirname}/${modName}`), path.normalize(`${__dirname}/dist`)); -console.log("Build files copied."); - -// Compress the files for easy distribution. The compressed file is saved into the dist directory. When uncompressed we -// need to be sure that it includes a directory that the user can easily copy into their game mods directory. -zip({ - source: modName, - destination: `dist/${modName}.zip`, - cwd: __dirname -}).catch(function(err) { - console.error("A bestzip error has occurred: ", err.stack); -}).then(function() { - console.log(`Compressed mod package to: /dist/${modName}.zip`); - - // Now that we're done with the compression we can delete the temporary build directory. - fs.rmSync(`${__dirname}/${modName}`, { force: true, recursive: true }); - console.log("Build successful!"); -}); +#!/usr/bin/env node + +// This is a simple script used to build a mod package. The script will copy necessary files to the build directory +// and compress the build directory into a zip file that can be easily shared. + +const fs = require("fs-extra"); +const glob = require("glob"); +const zip = require('bestzip'); +const path = require("path"); + +// Load the package.json file to get some information about the package so we can name things appropriately. This is +// atypical, and you would never do this in a production environment, but this script is only used for development so +// it's fine in this case. Some of these values are stored in environment variables, but those differ between node +// versions; the 'author' value is not available after node v14. +const { author, name:packageName, version } = require("./package.json"); + +// Generate the name of the package, stripping out all non-alphanumeric characters in the 'author' and 'name'. +const modName = `${author.replace(/[^a-z0-9]/gi, "")}-${packageName.replace(/[^a-z0-9]/gi, "")}-${version}`; +console.log(`Generated package name: ${modName}`); + +// Delete the old build directory and compressed package file. +fs.rmSync(`${__dirname}/dist`, { force: true, recursive: true }); +console.log("Previous build files deleted."); + +// Generate a list of files that should not be copied over into the distribution directory. This is a blacklist to ensure +// we always copy over additional files and directories that authors may have added to their project. This may need to be +// expanded upon by the mod author to allow for node modules that are used within the mod; example commented out below. +const ignoreList = [ + "node_modules/", + // "node_modules/!(weighted|glob)", // Instead of excluding the entire node_modules directory, allow two node modules. + "src/**/*.js", + "types/", + ".git/", + ".github/", + ".eslintignore", + ".eslintrc.json", + ".gitignore", + ".DS_Store", + ".nvmrc", + "packageBuild.ts", + "mod.code-workspace", + "package-lock.json", + "tsconfig.json", + "CustomStamina.png" +]; +const exclude = glob.sync(`{${ignoreList.join(",")}}`, { realpath: true, dot: true }); + +// For some reason these basic-bitch functions won't allow us to copy a directory into itself, so we have to resort to +// using a temporary directory, like an idiot. Excuse the normalize spam; some modules cross-platform, some don't... +fs.copySync(__dirname, path.normalize(`${__dirname}/../~${modName}`), {filter:(filePath) => { + return !exclude.includes(filePath); +}}); +fs.moveSync(path.normalize(`${__dirname}/../~${modName}`), path.normalize(`${__dirname}/${modName}`), { overwrite: true }); +fs.copySync(path.normalize(`${__dirname}/${modName}`), path.normalize(`${__dirname}/dist`)); +console.log("Build files copied."); + +// Compress the files for easy distribution. The compressed file is saved into the dist directory. When uncompressed we +// need to be sure that it includes a directory that the user can easily copy into their game mods directory. +zip({ + source: modName, + destination: `dist/${modName}.zip`, + cwd: __dirname +}).catch(function(err) { + console.error("A bestzip error has occurred: ", err.stack); +}).then(function() { + console.log(`Compressed mod package to: /dist/${modName}.zip`); + + // Now that we're done with the compression we can delete the temporary build directory. + fs.rmSync(`${__dirname}/${modName}`, { force: true, recursive: true }); + console.log("Build successful!"); +});