Compare commits
No commits in common. "c302aeef2f40c228fa17cab715b1cd2e22364a22" and "44d35231e06813b36c3ff3737b5defc5a8098087" have entirely different histories.
c302aeef2f
...
44d35231e0
@ -18,7 +18,3 @@
|
|||||||
/package-lock.json
|
/package-lock.json
|
||||||
/tsconfig.json
|
/tsconfig.json
|
||||||
/types
|
/types
|
||||||
/.prettierignore
|
|
||||||
/.prettierrc.json
|
|
||||||
/icon.png
|
|
||||||
/README.md
|
|
||||||
|
@ -8,4 +8,3 @@
|
|||||||
*.json
|
*.json
|
||||||
*.txt
|
*.txt
|
||||||
*.exe
|
*.exe
|
||||||
*.mjs
|
|
197
.eslintrc.json
197
.eslintrc.json
@ -1,113 +1,98 @@
|
|||||||
{
|
{
|
||||||
"root": true,
|
"root": true,
|
||||||
"parser": "@typescript-eslint/parser",
|
"parser": "@typescript-eslint/parser",
|
||||||
"plugins": ["@typescript-eslint"],
|
"plugins": [
|
||||||
"extends": [
|
"@typescript-eslint"
|
||||||
"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"]
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"@typescript-eslint/indent": ["warn", 2],
|
"extends": [
|
||||||
"@typescript-eslint/no-unused-expressions": [
|
"eslint:recommended",
|
||||||
"warn",
|
"plugin:@typescript-eslint/eslint-recommended",
|
||||||
{
|
"plugin:@typescript-eslint/recommended"
|
||||||
"allowShortCircuit": false,
|
|
||||||
"allowTernary": false
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"@typescript-eslint/keyword-spacing": [
|
"rules": {
|
||||||
"warn",
|
"@typescript-eslint/no-explicit-any": 0,
|
||||||
{
|
"@typescript-eslint/no-unused-vars": 1,
|
||||||
"before": true,
|
"@typescript-eslint/no-empty-interface": 0,
|
||||||
"after": true
|
"@typescript-eslint/no-namespace": 0,
|
||||||
}
|
"@typescript-eslint/comma-dangle": 1,
|
||||||
],
|
"@typescript-eslint/func-call-spacing": 2,
|
||||||
"@typescript-eslint/explicit-module-boundary-types": [
|
"@typescript-eslint/quotes": 1,
|
||||||
"warn",
|
"@typescript-eslint/brace-style": [
|
||||||
{
|
"warn",
|
||||||
"allowArgumentsExplicitlyTypedAsAny": true
|
"allman"
|
||||||
}
|
|
||||||
],
|
|
||||||
"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"
|
|
||||||
],
|
],
|
||||||
"newlines-between": "always",
|
"@typescript-eslint/naming-convention": [
|
||||||
"alphabetize": {
|
"warn",
|
||||||
"order": "asc",
|
{
|
||||||
"caseInsensitive": true
|
"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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"settings": {
|
|
||||||
"import/resolver": {
|
|
||||||
"typescript": {
|
|
||||||
"project": "./tsconfig.json"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"files": ["*.mjs", "*.ts"],
|
|
||||||
"env": {
|
|
||||||
"node": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,2 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
dist/
|
dist/
|
||||||
.vscode/
|
|
@ -1,11 +0,0 @@
|
|||||||
# Exclude these folders from linting
|
|
||||||
**/node_modules
|
|
||||||
/tmp
|
|
||||||
/dist
|
|
||||||
/types
|
|
||||||
|
|
||||||
# Exclude these filetypes from linting
|
|
||||||
*.json
|
|
||||||
*.txt
|
|
||||||
*.exe
|
|
||||||
*.mjs
|
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"singleQuote": false,
|
|
||||||
"trailingComma": "all",
|
|
||||||
"tabWidth": 2,
|
|
||||||
"semi": true
|
|
||||||
}
|
|
11
README.md
11
README.md
@ -1,14 +1,10 @@
|
|||||||
# InsuranceTweaks
|
# InsuranceTweaks
|
||||||
|
|
||||||
A simple mod with little to no configuration to tweak the insurance settings
|
A simple mod with little to no configuration to tweak the insurance settings
|
||||||
|
|
||||||
# Config
|
# Config
|
||||||
|
|
||||||
| Setting | Default Value | Details |
|
| Setting | Default Value | Details |
|
||||||
| ---------------------------- | ------------- | ------------------------------------------------------------------ |
|
|------------------------------|---------------|--------------------------------------------------------------------|
|
||||||
| InstantReturn | | |
|
| PraporMinReturn | 2 | Minimum time (in hours) for Prapor to return your insured items |
|
||||||
| ├ 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 |
|
| 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 |
|
| PraporMaxStorageTime | 72 | Number of hours Prapor insured items will stay in your inbox |
|
||||||
| PraporReturnChancePercent | 50 | Return chance percentage for Prapor insured items |
|
| PraporReturnChancePercent | 50 | Return chance percentage for Prapor insured items |
|
||||||
@ -18,6 +14,5 @@ A simple mod with little to no configuration to tweak the insurance settings
|
|||||||
| TherapistReturnChancePercent | 75 | Return chance percentage for Therapist insured items |
|
| TherapistReturnChancePercent | 75 | Return chance percentage for Therapist insured items |
|
||||||
|
|
||||||
# Thanks
|
# Thanks
|
||||||
|
|
||||||
- [chomp](https://dev.sp-tarkov.com/chomp) for the mod examples
|
- [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);
|
logger.log("info", zipFilePath);
|
||||||
|
|
||||||
// Move the zip file inside of the project directory, within the temporary working directory.
|
// Move the zip file inside of the project directory, within the temporary working directory.
|
||||||
const zipFileInProjectDir = path.join(projectDir, `${projectName}-${packageJson.version}.zip`);
|
const zipFileInProjectDir = path.join(projectDir, `${projectName}.zip`);
|
||||||
await fs.move(zipFilePath, zipFileInProjectDir);
|
await fs.move(zipFilePath, zipFileInProjectDir);
|
||||||
logger.log("success", "Archive successfully moved.");
|
logger.log("success", "Archive successfully moved.");
|
||||||
logger.log("info", zipFileInProjectDir);
|
logger.log("info", zipFileInProjectDir);
|
||||||
@ -134,7 +134,7 @@ async function main() {
|
|||||||
logger.log("success", "------------------------------------");
|
logger.log("success", "------------------------------------");
|
||||||
logger.log("success", "Build script completed successfully!");
|
logger.log("success", "Build script completed successfully!");
|
||||||
logger.log("success", "Your mod package has been created in the 'dist' directory:");
|
logger.log("success", "Your mod package has been created in the 'dist' directory:");
|
||||||
logger.log("success", `/${path.relative(process.cwd(), path.join(distDir, `${projectName}-${packageJson.version}.zip`))}`);
|
logger.log("success", `/${path.relative(process.cwd(), path.join(distDir, `${projectName}.zip`))}`);
|
||||||
logger.log("success", "------------------------------------");
|
logger.log("success", "------------------------------------");
|
||||||
if (!verbose) {
|
if (!verbose) {
|
||||||
logger.log("success", "To see a detailed build log, use `npm run buildinfo`.");
|
logger.log("success", "To see a detailed build log, use `npm run buildinfo`.");
|
||||||
|
@ -1,18 +1,13 @@
|
|||||||
{
|
{
|
||||||
InstantReturn: {
|
//Prapor
|
||||||
enabled: false,
|
"PraporMinReturn": 2,
|
||||||
runIntervalSeconds: 30,
|
"PraporMaxReturn": 4,
|
||||||
},
|
"PraporMaxStorageTime": 72,
|
||||||
|
"PraporReturnChancePercent": 50,
|
||||||
//Prapor
|
|
||||||
PraporMinReturn: 2,
|
|
||||||
PraporMaxReturn: 4,
|
|
||||||
PraporMaxStorageTime: 72,
|
|
||||||
PraporReturnChancePercent: 50,
|
|
||||||
|
|
||||||
//Therapist
|
//Therapist
|
||||||
TherapistMinReturn: 1,
|
"TherapistMinReturn": 1,
|
||||||
TherapistMaxReturn: 2,
|
"TherapistMaxReturn": 2,
|
||||||
TherapistMaxStorageTime: 72,
|
"TherapistMaxStorageTime": 72,
|
||||||
TherapistReturnChancePercent: 75,
|
"TherapistReturnChancePercent": 75
|
||||||
}
|
}
|
@ -1,18 +1,13 @@
|
|||||||
{
|
{
|
||||||
"folders": [
|
"folders": [
|
||||||
{
|
{
|
||||||
"path": ".",
|
"path": "."
|
||||||
},
|
}
|
||||||
],
|
|
||||||
"extensions": {
|
|
||||||
"recommendations": [
|
|
||||||
"dbaeumer.vscode-eslint",
|
|
||||||
"refringe.spt-id-highlighter",
|
|
||||||
],
|
],
|
||||||
},
|
"extensions": {
|
||||||
"settings": {
|
"recommendations": [
|
||||||
"editor.tabSize": 2,
|
"dbaeumer.vscode-eslint",
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
"refringe.spt-id-highlighter"
|
||||||
"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",
|
"name": "InsuranceTweaks",
|
||||||
"version": "0.0.3",
|
"version": "0.0.2",
|
||||||
"sptVersion": "~3.9",
|
"sptVersion": "~3.9",
|
||||||
"loadBefore": [],
|
"loadBefore": [],
|
||||||
"loadAfter": [],
|
"loadAfter": [],
|
||||||
"incompatibilities": [],
|
"incompatibilities": [],
|
||||||
"isBundleMod": false,
|
"isBundleMod": false,
|
||||||
"main": "src/insurancetweaks.js",
|
"main": "src/mod.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"setup": "npm i",
|
"setup": "npm i",
|
||||||
"build": "node ./build.mjs",
|
"build": "node ./build.mjs",
|
||||||
@ -18,14 +18,9 @@
|
|||||||
"@typescript-eslint/parser": "7.2",
|
"@typescript-eslint/parser": "7.2",
|
||||||
"archiver": "^6.0",
|
"archiver": "^6.0",
|
||||||
"eslint": "8.57",
|
"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",
|
"fs-extra": "11.2",
|
||||||
"ignore": "^5.2",
|
"ignore": "^5.2",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"prettier": "^3.3.3",
|
|
||||||
"tsyringe": "4.8.0",
|
"tsyringe": "4.8.0",
|
||||||
"typescript": "5.4",
|
"typescript": "5.4",
|
||||||
"winston": "3.12"
|
"winston": "3.12"
|
||||||
|
@ -1,98 +0,0 @@
|
|||||||
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();
|
|
72
src/mod.ts
Normal file
72
src/mod.ts
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
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";
|
||||||
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
|
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
||||||
|
import { IInsuranceConfig } from "@spt/models/spt/config/IInsuranceConfig";
|
||||||
|
|
||||||
|
type ModConfig = {
|
||||||
|
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 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.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);
|
||||||
|
|
||||||
|
// Prapor
|
||||||
|
traders[PRAPOR].base.insurance.min_return_hour = modConfig.PraporMinReturn;
|
||||||
|
traders[PRAPOR].base.insurance.max_return_hour = modConfig.PraporMaxReturn;
|
||||||
|
traders[PRAPOR].base.insurance.max_storage_time = modConfig.PraporMaxStorageTime;
|
||||||
|
insuranceConfig.returnChancePercent[PRAPOR] = modConfig.PraporReturnChancePercent;
|
||||||
|
// Therapist
|
||||||
|
traders[THERAPIST].base.insurance.min_return_hour = modConfig.TherapistMinReturn;
|
||||||
|
traders[THERAPIST].base.insurance.max_return_hour = modConfig.TherapistMaxReturn;
|
||||||
|
traders[THERAPIST].base.insurance.max_storage_time = modConfig.TherapistMaxStorageTime;
|
||||||
|
insuranceConfig.returnChancePercent[THERAPIST] = modConfig.TherapistReturnChancePercent;
|
||||||
|
|
||||||
|
this.logger.logWithColor("[InsuranceTweaks] Applied insurance settings", LogTextColor.GREEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const mod = new InsuranceTweaks();
|
Loading…
x
Reference in New Issue
Block a user