Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
c302aeef2f | |||
9be6704522 | |||
7ef907bedd | |||
7fb74a7cf5 | |||
b3fc3d87e8 | |||
44d35231e0 | |||
65c4b4919e | |||
2ae704839c |
@ -18,3 +18,7 @@
|
||||
/package-lock.json
|
||||
/tsconfig.json
|
||||
/types
|
||||
/.prettierignore
|
||||
/.prettierrc.json
|
||||
/icon.png
|
||||
/README.md
|
||||
|
@ -8,3 +8,4 @@
|
||||
*.json
|
||||
*.txt
|
||||
*.exe
|
||||
*.mjs
|
197
.eslintrc.json
197
.eslintrc.json
@ -1,98 +1,113 @@
|
||||
{
|
||||
"root": true,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
"root": true,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
|
||||
"plugin:import/recommended",
|
||||
"plugin:import/typescript"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-explicit-any": 0,
|
||||
"@typescript-eslint/no-unused-vars": 1,
|
||||
"@typescript-eslint/no-empty-interface": 0,
|
||||
"@typescript-eslint/no-namespace": 0,
|
||||
"@typescript-eslint/func-call-spacing": 2,
|
||||
"@typescript-eslint/quotes": ["warn", "double"],
|
||||
"@typescript-eslint/brace-style": ["warn", "1tbs"],
|
||||
"@typescript-eslint/naming-convention": [
|
||||
"warn",
|
||||
{
|
||||
"selector": "default",
|
||||
"format": ["camelCase"],
|
||||
"leadingUnderscore": "allow"
|
||||
},
|
||||
{
|
||||
"selector": "typeLike",
|
||||
"format": ["PascalCase"]
|
||||
},
|
||||
{
|
||||
"selector": "objectLiteralProperty",
|
||||
"format": ["PascalCase", "camelCase"],
|
||||
"leadingUnderscore": "allow"
|
||||
},
|
||||
{
|
||||
"selector": "typeProperty",
|
||||
"format": ["PascalCase", "camelCase"],
|
||||
"leadingUnderscore": "allow"
|
||||
},
|
||||
{
|
||||
"selector": "enumMember",
|
||||
"format": ["UPPER_CASE"]
|
||||
}
|
||||
],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
"@typescript-eslint/indent": ["warn", 2],
|
||||
"@typescript-eslint/no-unused-expressions": [
|
||||
"warn",
|
||||
{
|
||||
"allowShortCircuit": false,
|
||||
"allowTernary": false
|
||||
}
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-explicit-any": 0,
|
||||
"@typescript-eslint/no-unused-vars": 1,
|
||||
"@typescript-eslint/no-empty-interface": 0,
|
||||
"@typescript-eslint/no-namespace": 0,
|
||||
"@typescript-eslint/comma-dangle": 1,
|
||||
"@typescript-eslint/func-call-spacing": 2,
|
||||
"@typescript-eslint/quotes": 1,
|
||||
"@typescript-eslint/brace-style": [
|
||||
"warn",
|
||||
"allman"
|
||||
"@typescript-eslint/keyword-spacing": [
|
||||
"warn",
|
||||
{
|
||||
"before": true,
|
||||
"after": true
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/explicit-module-boundary-types": [
|
||||
"warn",
|
||||
{
|
||||
"allowArgumentsExplicitlyTypedAsAny": true
|
||||
}
|
||||
],
|
||||
"sort-imports": [
|
||||
"error",
|
||||
{
|
||||
"ignoreCase": false,
|
||||
"ignoreDeclarationSort": true, // don"t want to sort import lines, use eslint-plugin-import instead
|
||||
"ignoreMemberSort": false,
|
||||
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"],
|
||||
"allowSeparatedGroups": true
|
||||
}
|
||||
],
|
||||
"import/no-unresolved": "error",
|
||||
"import/order": [
|
||||
"error",
|
||||
{
|
||||
"groups": [
|
||||
"builtin",
|
||||
"external",
|
||||
"internal",
|
||||
["sibling", "parent"],
|
||||
"index",
|
||||
"unknown"
|
||||
],
|
||||
"@typescript-eslint/naming-convention": [
|
||||
"warn",
|
||||
{
|
||||
"selector": "default",
|
||||
"format": [
|
||||
"camelCase"
|
||||
],
|
||||
"leadingUnderscore": "allow"
|
||||
},
|
||||
{
|
||||
"selector": "typeLike",
|
||||
"format": [
|
||||
"PascalCase"
|
||||
]
|
||||
},
|
||||
{
|
||||
"selector": "objectLiteralProperty",
|
||||
"format": [
|
||||
"PascalCase",
|
||||
"camelCase"
|
||||
],
|
||||
"leadingUnderscore": "allow"
|
||||
},
|
||||
{
|
||||
"selector": "typeProperty",
|
||||
"format": [
|
||||
"PascalCase",
|
||||
"camelCase"
|
||||
],
|
||||
"leadingUnderscore": "allow"
|
||||
},
|
||||
{
|
||||
"selector": "enumMember",
|
||||
"format": [
|
||||
"UPPER_CASE"
|
||||
]
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/indent": [
|
||||
"warn",
|
||||
4
|
||||
],
|
||||
"@typescript-eslint/no-unused-expressions": [
|
||||
"warn",
|
||||
{
|
||||
"allowShortCircuit": false,
|
||||
"allowTernary": false
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/keyword-spacing": [
|
||||
"warn",
|
||||
{
|
||||
"before": true,
|
||||
"after": true
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/explicit-module-boundary-types": [
|
||||
"warn",
|
||||
{
|
||||
"allowArgumentsExplicitlyTypedAsAny": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"*.mjs",
|
||||
"*.ts"
|
||||
],
|
||||
"env": {
|
||||
"node": true
|
||||
}
|
||||
"newlines-between": "always",
|
||||
"alphabetize": {
|
||||
"order": "asc",
|
||||
"caseInsensitive": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"settings": {
|
||||
"import/resolver": {
|
||||
"typescript": {
|
||||
"project": "./tsconfig.json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.mjs", "*.ts"],
|
||||
"env": {
|
||||
"node": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
node_modules/
|
||||
dist/
|
||||
dist/
|
||||
.vscode/
|
11
.prettierignore
Normal file
11
.prettierignore
Normal file
@ -0,0 +1,11 @@
|
||||
# Exclude these folders from linting
|
||||
**/node_modules
|
||||
/tmp
|
||||
/dist
|
||||
/types
|
||||
|
||||
# Exclude these filetypes from linting
|
||||
*.json
|
||||
*.txt
|
||||
*.exe
|
||||
*.mjs
|
6
.prettierrc.json
Normal file
6
.prettierrc.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"singleQuote": false,
|
||||
"trailingComma": "all",
|
||||
"tabWidth": 2,
|
||||
"semi": true
|
||||
}
|
25
README.md
25
README.md
@ -1,16 +1,23 @@
|
||||
# InsuranceTweaks
|
||||
|
||||
A simple mod with little to no configuration to tweak the insurance settings
|
||||
|
||||
# Config
|
||||
| Setting | Default Value | Details |
|
||||
|-------------------------|---------------|--------------------------------------------------------------------|
|
||||
| PraporMinReturn | 2 | Minimum time (in hours) for Prapor to return your insured items |
|
||||
| PraporMaxReturn | 4 | Maximum time (in hours) for Prapor to return your insured items |
|
||||
| PraporMaxStorageTime | 72 | Number of hours Prapor insured items will stay in your inbox |
|
||||
| TherapistMinReturn | 1 | Minimum time (in hours) for Therapist to return your insured items |
|
||||
| TherapistMaxReturn | 2 | Maximum time (in hours) for Therapist to return your insured items |
|
||||
| TherapistMaxStorageTime | 72 | Number of hours Therapist insured items will stay in your inbox |
|
||||
|
||||
| Setting | Default Value | Details |
|
||||
| ---------------------------- | ------------- | ------------------------------------------------------------------ |
|
||||
| InstantReturn | | |
|
||||
| ├ enabled | false | Whether or not the instant return is enabled |
|
||||
| └ runIntervalSeconds | 30 | Time (in seconds) between each insurance check |
|
||||
| PraporMaxReturn | 4 | Maximum time (in hours) for Prapor to return your insured items |
|
||||
| PraporMaxStorageTime | 72 | Number of hours Prapor insured items will stay in your inbox |
|
||||
| PraporReturnChancePercent | 50 | Return chance percentage for Prapor insured items |
|
||||
| TherapistMinReturn | 1 | Minimum time (in hours) for Therapist to return your insured items |
|
||||
| TherapistMaxReturn | 2 | Maximum time (in hours) for Therapist to return your insured items |
|
||||
| TherapistMaxStorageTime | 72 | Number of hours Therapist insured items will stay in your inbox |
|
||||
| TherapistReturnChancePercent | 75 | Return chance percentage for Therapist insured items |
|
||||
|
||||
# Thanks
|
||||
|
||||
- [chomp](https://dev.sp-tarkov.com/chomp) for the mod examples
|
||||
- [DJLang](https://github.com/KillerDJLang) for [RaidOverhaul](https://hub.sp-tarkov.com/files/file/1673-raid-overhaul/) giving me the idea to make this mod
|
||||
- [DJLang](https://github.com/KillerDJLang) for [RaidOverhaul](https://hub.sp-tarkov.com/files/file/1673-raid-overhaul/) giving me the idea to make this mod
|
||||
|
@ -121,7 +121,7 @@ async function main() {
|
||||
logger.log("info", zipFilePath);
|
||||
|
||||
// Move the zip file inside of the project directory, within the temporary working directory.
|
||||
const zipFileInProjectDir = path.join(projectDir, `${projectName}.zip`);
|
||||
const zipFileInProjectDir = path.join(projectDir, `${projectName}-${packageJson.version}.zip`);
|
||||
await fs.move(zipFilePath, zipFileInProjectDir);
|
||||
logger.log("success", "Archive successfully moved.");
|
||||
logger.log("info", zipFileInProjectDir);
|
||||
@ -134,7 +134,7 @@ async function main() {
|
||||
logger.log("success", "------------------------------------");
|
||||
logger.log("success", "Build script completed successfully!");
|
||||
logger.log("success", "Your mod package has been created in the 'dist' directory:");
|
||||
logger.log("success", `/${path.relative(process.cwd(), path.join(distDir, `${projectName}.zip`))}`);
|
||||
logger.log("success", `/${path.relative(process.cwd(), path.join(distDir, `${projectName}-${packageJson.version}.zip`))}`);
|
||||
logger.log("success", "------------------------------------");
|
||||
if (!verbose) {
|
||||
logger.log("success", "To see a detailed build log, use `npm run buildinfo`.");
|
||||
|
@ -1,11 +1,18 @@
|
||||
{
|
||||
//Prapor
|
||||
"PraporMinReturn": 2,
|
||||
"PraporMaxReturn": 4,
|
||||
"PraporMaxStorageTime": 72,
|
||||
InstantReturn: {
|
||||
enabled: false,
|
||||
runIntervalSeconds: 30,
|
||||
},
|
||||
|
||||
//Prapor
|
||||
PraporMinReturn: 2,
|
||||
PraporMaxReturn: 4,
|
||||
PraporMaxStorageTime: 72,
|
||||
PraporReturnChancePercent: 50,
|
||||
|
||||
//Therapist
|
||||
"TherapistMinReturn": 1,
|
||||
"TherapistMaxReturn": 2,
|
||||
"TherapistMaxStorageTime": 72
|
||||
}
|
||||
TherapistMinReturn: 1,
|
||||
TherapistMaxReturn: 2,
|
||||
TherapistMaxStorageTime: 72,
|
||||
TherapistReturnChancePercent: 75,
|
||||
}
|
||||
|
@ -1,13 +1,18 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
}
|
||||
"folders": [
|
||||
{
|
||||
"path": ".",
|
||||
},
|
||||
],
|
||||
"extensions": {
|
||||
"recommendations": [
|
||||
"dbaeumer.vscode-eslint",
|
||||
"refringe.spt-id-highlighter",
|
||||
],
|
||||
"extensions": {
|
||||
"recommendations": [
|
||||
"dbaeumer.vscode-eslint",
|
||||
"refringe.spt-id-highlighter"
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"editor.tabSize": 2,
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true,
|
||||
},
|
||||
}
|
||||
|
1553
package-lock.json
generated
1553
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "InsuranceTweaks",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.3",
|
||||
"sptVersion": "~3.9",
|
||||
"loadBefore": [],
|
||||
"loadAfter": [],
|
||||
"incompatibilities": [],
|
||||
"isBundleMod": false,
|
||||
"main": "src/mod.js",
|
||||
"main": "src/insurancetweaks.js",
|
||||
"scripts": {
|
||||
"setup": "npm i",
|
||||
"build": "node ./build.mjs",
|
||||
@ -18,9 +18,14 @@
|
||||
"@typescript-eslint/parser": "7.2",
|
||||
"archiver": "^6.0",
|
||||
"eslint": "8.57",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-import-resolver-typescript": "^3.6.1",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"fs-extra": "11.2",
|
||||
"ignore": "^5.2",
|
||||
"json5": "^2.2.3",
|
||||
"prettier": "^3.3.3",
|
||||
"tsyringe": "4.8.0",
|
||||
"typescript": "5.4",
|
||||
"winston": "3.12"
|
||||
|
98
src/insurancetweaks.ts
Normal file
98
src/insurancetweaks.ts
Normal file
@ -0,0 +1,98 @@
|
||||
import * as path from "node:path";
|
||||
|
||||
import { parse } from "json5";
|
||||
import { DependencyContainer } from "tsyringe";
|
||||
|
||||
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
||||
import { IPostDBLoadMod } from "@spt/models/external/IPostDBLoadMod";
|
||||
import { IPreSptLoadMod } from "@spt/models/external/IPreSptLoadMod";
|
||||
import { IInsuranceConfig } from "@spt/models/spt/config/IInsuranceConfig";
|
||||
import { LogTextColor } from "@spt/models/spt/logging/LogTextColor";
|
||||
import { IDatabaseTables } from "@spt/models/spt/server/IDatabaseTables";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { DatabaseServer } from "@spt/servers/DatabaseServer";
|
||||
import { SaveServer } from "@spt/servers/SaveServer";
|
||||
import { VFS } from "@spt/utils/VFS";
|
||||
|
||||
type ModConfig = {
|
||||
InstantReturn: {
|
||||
enabled: boolean;
|
||||
runIntervalSeconds: number;
|
||||
};
|
||||
|
||||
PraporMinReturn: number;
|
||||
PraporMaxReturn: number;
|
||||
PraporMaxStorageTime: number;
|
||||
PraporReturnChancePercent: number;
|
||||
|
||||
TherapistMinReturn: number;
|
||||
TherapistMaxReturn: number;
|
||||
TherapistMaxStorageTime: number;
|
||||
TherapistReturnChancePercent: number;
|
||||
};
|
||||
|
||||
class InsuranceTweaks implements IPreSptLoadMod, IPostDBLoadMod {
|
||||
public logger: ILogger;
|
||||
public tables: IDatabaseTables;
|
||||
public modConfig: ModConfig;
|
||||
public configServer: ConfigServer;
|
||||
public saveServer: SaveServer;
|
||||
|
||||
public preSptLoad(container: DependencyContainer): void {
|
||||
this.logger = container.resolve<ILogger>("WinstonLogger");
|
||||
const vfs = container.resolve<VFS>("VFS");
|
||||
this.modConfig = parse(
|
||||
vfs.readFile(path.resolve(__dirname, "../config/config.json5")),
|
||||
);
|
||||
}
|
||||
|
||||
public postDBLoad(container: DependencyContainer): void {
|
||||
this.tables = container
|
||||
.resolve<DatabaseServer>("DatabaseServer")
|
||||
.getTables();
|
||||
this.configServer = container.resolve<ConfigServer>("ConfigServer");
|
||||
this.traderTweaks(this.modConfig);
|
||||
}
|
||||
|
||||
private traderTweaks(modConfig: ModConfig): void {
|
||||
const traders = this.tables.traders;
|
||||
const PRAPOR = "54cb50c76803fa8b248b4571";
|
||||
const THERAPIST = "54cb57776803fa99248b456e";
|
||||
|
||||
const insuranceConfig = this.configServer.getConfig<IInsuranceConfig>(
|
||||
ConfigTypes.INSURANCE,
|
||||
);
|
||||
|
||||
if (!modConfig.InstantReturn.enabled) {
|
||||
traders[PRAPOR].base.insurance.min_return_hour =
|
||||
modConfig.PraporMinReturn;
|
||||
traders[PRAPOR].base.insurance.max_return_hour =
|
||||
modConfig.PraporMaxReturn;
|
||||
traders[THERAPIST].base.insurance.min_return_hour =
|
||||
modConfig.TherapistMinReturn;
|
||||
traders[THERAPIST].base.insurance.max_return_hour =
|
||||
modConfig.TherapistMaxReturn;
|
||||
} else {
|
||||
insuranceConfig.runIntervalSeconds =
|
||||
modConfig.InstantReturn.runIntervalSeconds;
|
||||
insuranceConfig.returnTimeOverrideSeconds = 1;
|
||||
}
|
||||
|
||||
traders[PRAPOR].base.insurance.max_storage_time =
|
||||
modConfig.PraporMaxStorageTime;
|
||||
traders[THERAPIST].base.insurance.max_storage_time =
|
||||
modConfig.TherapistMaxStorageTime;
|
||||
insuranceConfig.returnChancePercent[PRAPOR] =
|
||||
modConfig.PraporReturnChancePercent;
|
||||
insuranceConfig.returnChancePercent[THERAPIST] =
|
||||
modConfig.TherapistReturnChancePercent;
|
||||
|
||||
this.logger.logWithColor(
|
||||
"[InsuranceTweaks] Applied insurance settings",
|
||||
LogTextColor.GREEN,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const mod = new InsuranceTweaks();
|
59
src/mod.ts
59
src/mod.ts
@ -1,59 +0,0 @@
|
||||
import { DependencyContainer } from "tsyringe";
|
||||
import json5 from "json5";
|
||||
|
||||
import { IPreSptLoadMod } from "@spt/models/external/IPreSptLoadMod";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { LogTextColor } from "@spt/models/spt/logging/LogTextColor";
|
||||
import { IDatabaseTables } from "@spt/models/spt/server/IDatabaseTables";
|
||||
import { DatabaseServer } from "@spt/servers/DatabaseServer";
|
||||
import { IPostDBLoadMod } from "@spt/models/external/IPostDBLoadMod";
|
||||
import { VFS } from "@spt/utils/VFS";
|
||||
|
||||
import * as path from "node:path";
|
||||
|
||||
type ModConfig = {
|
||||
PraporMinReturn: number,
|
||||
PraporMaxReturn: number,
|
||||
PraporMaxStorageTime: number,
|
||||
TherapistMinReturn: number,
|
||||
TherapistMaxReturn: number,
|
||||
TherapistMaxStorageTime: number
|
||||
}
|
||||
|
||||
class InsuranceTweaks implements IPreSptLoadMod, IPostDBLoadMod
|
||||
{
|
||||
public logger: ILogger;
|
||||
public tables: IDatabaseTables;
|
||||
public modConfig: ModConfig;
|
||||
|
||||
public preSptLoad(container: DependencyContainer): void
|
||||
{
|
||||
this.logger = container.resolve<ILogger>("WinstonLogger");
|
||||
const vfs = container.resolve<VFS>("VFS");
|
||||
this.modConfig = json5.parse(vfs.readFile(path.resolve(__dirname, "../config/config.json5")));
|
||||
}
|
||||
|
||||
public postDBLoad(container: DependencyContainer): void
|
||||
{
|
||||
this.tables = container.resolve<DatabaseServer>("DatabaseServer").getTables();
|
||||
this.traderTweaks(this.modConfig);
|
||||
}
|
||||
|
||||
private traderTweaks(modConfig: ModConfig): void
|
||||
{
|
||||
const traders = this.tables.traders;
|
||||
|
||||
// Prapor
|
||||
traders["54cb50c76803fa8b248b4571"].base.insurance.min_return_hour = modConfig.PraporMinReturn
|
||||
traders["54cb50c76803fa8b248b4571"].base.insurance.max_return_hour = modConfig.PraporMaxReturn
|
||||
traders["54cb50c76803fa8b248b4571"].base.insurance.max_storage_time = modConfig.PraporMaxStorageTime
|
||||
// Therapist
|
||||
traders["54cb57776803fa99248b456e"].base.insurance.min_return_hour = modConfig.TherapistMinReturn
|
||||
traders["54cb57776803fa99248b456e"].base.insurance.max_return_hour = modConfig.TherapistMaxReturn
|
||||
traders["54cb57776803fa99248b456e"].base.insurance.max_storage_time = modConfig.TherapistMaxStorageTime
|
||||
|
||||
this.logger.logWithColor("[InsuranceTweaks] Applied insurance settings", LogTextColor.GREEN);
|
||||
}
|
||||
}
|
||||
|
||||
export const mod = new InsuranceTweaks();
|
Loading…
x
Reference in New Issue
Block a user