add instant return feature
This commit is contained in:
parent
9be6704522
commit
c302aeef2f
11
README.md
11
README.md
@ -1,10 +1,14 @@
|
|||||||
# 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 |
|
||||||
|------------------------------|---------------|--------------------------------------------------------------------|
|
| ---------------------------- | ------------- | ------------------------------------------------------------------ |
|
||||||
| PraporMinReturn | 2 | Minimum time (in hours) for Prapor to return your insured items |
|
| 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 |
|
| 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 |
|
||||||
@ -14,5 +18,6 @@ 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
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
{
|
{
|
||||||
//Prapor
|
InstantReturn: {
|
||||||
"PraporMinReturn": 2,
|
enabled: false,
|
||||||
"PraporMaxReturn": 4,
|
runIntervalSeconds: 30,
|
||||||
"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,
|
||||||
}
|
}
|
||||||
|
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();
|
72
src/mod.ts
72
src/mod.ts
@ -1,72 +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";
|
|
||||||
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