Echo55
Hello Echo55.
I was adding a new stim in your mod so i can use ingame and i made your “mod.ts” more compact and extracted alot of reusable code, so it is easier to use. Feel free to use it and upgrade if you want to.
Observation: I commented the stim lines that adds the one i aditioned.
The code is from your version 1.1.1, but it is the same if i compare with 1.1.5. The only difference is the “addToLocale” method exists on 1.1.5
import { DependencyContainer } from “tsyringe” import { IPreAkiLoadMod } from “@spt-aki/models/external/IPreAkiLoadMod” //import { IPostAkiLoadMod } from “@spt-aki/models/external/IPostAkiLoadMod”; import { IPostDBLoadMod } from “@spt-aki/models/external/IPostDBLoadMod” import { ILogger } from “@spt-aki/models/spt/utils/ILogger”; import { PreAkiModLoader } from “@spt-aki/loaders/PreAkiModLoader” import { LogTextColor } from “@spt-aki/models/spt/logging/LogTextColor”; import { CustomItemService } from “@spt-aki/services/mod/CustomItemService”; import { JsonUtil } from “@spt-aki/utils/JSONUtil”; import { VFS } from “@spt-aki/utils/VFS”; import { DatabaseServer } from “@spt-aki/servers/DatabaseServer” import { DatabaseImporter } from “@spt-aki/utils/DatabaseImporter” class ConstConfig { public logger: ILogger; public JsonUtil: JsonUtil; public VFS: VFS; public preAkiModLoader: PreAkiModLoader; public db: any; public modPath: any; public config: any; public mydb: any; public items: any; public locales: any; public handbook: any; public buffs: any; public myItems: any; public myLocales: any; public myHandbook: any; public myBuffs: any; constructor (container: DependencyContainer, modName: any) { this.logger = container.resolve<ILogger>(“WinstonLogger”); this.JsonUtil = container.resolve<JsonUtil>(“JsonUtil”); this.VFS = container.resolve<VFS>(“VFS”); this.preAkiModLoader = container.resolve<PreAkiModLoader>(“PreAkiModLoader”); this.db = container.resolve<DatabaseServer>(“DatabaseServer”).getTables(); this.modPath = this.preAkiModLoader.getModPath(modName); this.config = require(’../config.json’) this.mydb = this.JsonUtil.deserialize(this.VFS.readFile(${this.modPath}/db.json)); this.items = this.db.templates.items this.locales = this.db.locales.global this.handbook = this.db.templates.handbook.Items this.buffs = this.db.globals.config.Health.Effects.Stimulator.Buffs this.myItems = this.mydb.items this.myLocales = this.mydb.locales.en.templates this.myHandbook = this.mydb.templates.handbook this.myBuffs = this.mydb.buffs } } class TrainingStims implements IPostDBLoadMod { modName = “TrainingStims” initialConfig(configs: ConstConfig): void { for (const itemKey in configs.myItems) { const path = configs.myItems[itemKey]; const item = configs.JsonUtil.deserialize(configs.VFS.readFile(${configs.modPath}/${path})); configs.items[item._id] = item; } // Add Handbook Entry for (const itemKey in configs.myHandbook) { const path = configs.myHandbook[itemKey]; const handbookitem = configs.JsonUtil.deserialize(configs.VFS.readFile(${configs.modPath}/${path})); configs.handbook.push(handbookitem) } // Add locales for (const localeID in configs.locales) { for (const langKey in configs.myLocales) { const path = configs.mydb.locales.en.templates[langKey]; const lang = configs.JsonUtil.deserialize(configs.VFS.readFile(${configs.modPath}/${path})); configs.locales[localeID].templates[langKey] = lang; } } // Add buffs for (const buff in configs.myBuffs) { const path = configs.myBuffs[buff]; const buffitem = configs.JsonUtil.deserialize(configs.VFS.readFile(${configs.modPath}/${path})); configs.buffs[buff] = buffitem; } } configPriceNCurrency(Training_Stim: any, therapistBS: any, name: string): void { if (Training_Stim.customBarterEnabled === true) { const ts1BS = therapistBS[name]; const ts1Config = Training_Stim; for (const key in ts1BS) { for (const key2 in ts1BS[key]) { ts1BS[key][key2].count = ts1Config.price; ts1BS[key][key2]._tpl = ts1Config.currency; } } } } configTherapist(configs: ConstConfig): void { const therapistAssorts = configs.db.traders[“54cb57776803fa99248b456e”].assort.items; const therapistBS = configs.db.traders[“54cb57776803fa99248b456e”].assort.barter_scheme; const therapistLL = configs.db.traders[“54cb57776803fa99248b456e”].assort.loyal_level_items; const myAssorts = configs.mydb.assort.therapist.items; const myLL = configs.mydb.assort.therapist.loyal_level_items; const myBarter = configs.mydb.assort.therapist.barter_scheme; // Add items to therapist assort // Item info for (const itemKey in myAssorts) { const path = myAssorts[itemKey]; const assort = configs.JsonUtil.deserialize(configs.VFS.readFile(${configs.modPath}/${path})); therapistAssorts.push(assort); } // LL info for (const itemKey in myLL) { const path = myLL[itemKey]; const llItem = configs.JsonUtil.deserialize(configs.VFS.readFile(${configs.modPath}/${path})); therapistLL[itemKey] = llItem; } // Barter info for (const itemKey in myBarter) { const path = myBarter[itemKey]; const schemeItem = configs.JsonUtil.deserialize(configs.VFS.readFile(${configs.modPath}/${path})); therapistBS[itemKey] = schemeItem; } this.configPriceNCurrency(configs.config.Training_Stim_1, therapistBS, “Training_Stim_1”); this.configPriceNCurrency(configs.config.Training_Stim_2, therapistBS, “Training_Stim_2”); this.configPriceNCurrency(configs.config.Training_Stim_3, therapistBS, “Training_Stim_3”); this.configPriceNCurrency(configs.config.Training_Stim_4, therapistBS, “Training_Stim_4”); this.configPriceNCurrency(configs.config.Training_Stim_5, therapistBS, “Training_Stim_5”); this.configPriceNCurrency(configs.config.Training_Stim_Mega, therapistBS, “Training_Stim_Mega”); } configEffects(stim: any, stimName: string, buffs: any): void { if (stim.customEffectsEnabled === true) { const ts1Buffs = stim.effect buffs[stimName] = ts1Buffs } } configUses(stim: any, stimName: string, items: any): void { if (stim.customUseAmountEnabled) { const numUses = stim.useAmount items[stimName]._props.MaxHpResource = numUses } } postDBLoad(container: DependencyContainer): void { const configs: ConstConfig = new ConstConfig(container, this.modName); if (configs.config.enable_all === true) { this.initialConfig(configs); this.configTherapist(configs); // Config effects this.configEffects(configs.config.Training_Stim_1, “Buffs_Training_01”, configs.buffs); this.configEffects(configs.config.Training_Stim_2, “Buffs_Training_02”, configs.buffs); this.configEffects(configs.config.Training_Stim_3, “Buffs_Training_03”, configs.buffs); this.configEffects(configs.config.Training_Stim_4, “Buffs_Training_04”, configs.buffs); this.configEffects(configs.config.Training_Stim_5, “Buffs_Training_05”, configs.buffs); //this.configEffects(configs.config.Training_Stim_Mega, “Buffs_Training_Mega”, configs.buffs); // Config uses this.configUses(configs.config.Training_Stim_1, “Training_Stim_1”, configs.items); this.configUses(configs.config.Training_Stim_2, “Training_Stim_2”, configs.items); this.configUses(configs.config.Training_Stim_3, “Training_Stim_3”, configs.items); this.configUses(configs.config.Training_Stim_4, “Training_Stim_4”, configs.items); this.configUses(configs.config.Training_Stim_5, “Training_Stim_5”, configs.items); //this.configUses(configs.config.Training_Stim_Mega, “Training_Stim_Mega”, configs.items); } } } module.exports = { mod: new TrainingStims() } Cheers.
No Addons Yet
This user has not yet published any addons.
No recent activity to display
Activity will appear here as the user interacts with the platform
Yoo the dude that made a test client for my mod.
Do you mind If I update HotCultist?