From 0ccced991556bbf1f2ced10520f3d31d17555e15 Mon Sep 17 00:00:00 2001 From: George Gaulin Date: Mon, 27 Jun 2022 00:11:22 -0400 Subject: [PATCH] WIP, ready for preliminary testing --- .../src/Notifications.ts | 3 +- Ereshkigal-AkiConfig/config/config.json | 46 +- Ereshkigal-AkiConfig/locale/locale.json | 43 +- Ereshkigal-AkiConfig/models/IConfig.ts | 34 +- Ereshkigal-AkiConfig/models/ILocale.ts | 34 +- Ereshkigal-AkiConfig/src/Notifications.ts | 848 +----------------- Ereshkigal-AkiConfig/src/bots.ts | 38 +- Ereshkigal-AkiConfig/src/generator.ts | 201 +++-- Ereshkigal-AkiConfig/src/mod.ts | 38 +- Ereshkigal-AkiConfig/src/quests.ts | 33 +- Ereshkigal-AkiConfig/src/ragfair.ts | 66 +- Ereshkigal-AkiConfig/src/raids.ts | 51 +- Ereshkigal-AkiConfig/src/server.ts | 45 +- Ereshkigal-AkiConfig/src/traders.ts | 55 +- Ereshkigal-AkiConfig/src/weather.ts | 30 +- 15 files changed, 462 insertions(+), 1103 deletions(-) diff --git a/Ereshkigal-AIO/ZEreshkigal-AllinOneMod/src/Notifications.ts b/Ereshkigal-AIO/ZEreshkigal-AllinOneMod/src/Notifications.ts index 41009f3..e094f39 100644 --- a/Ereshkigal-AIO/ZEreshkigal-AllinOneMod/src/Notifications.ts +++ b/Ereshkigal-AIO/ZEreshkigal-AllinOneMod/src/Notifications.ts @@ -13,14 +13,13 @@ export class Notifications public sendNotifications(): void { - const config = this.configHandler.getConfig(); const locale = this.configHandler.getLocales(); if (!config.other.hideWarningMessage) { this.logger.log("[AIO Mod INFORMATION]", "yellow"); - this.logger.info("Please read the README.PDF carefully as this has all the information you need."); + this.logger.info("Please read the AIO README.pdf carefully as this has all the information you need."); this.logger.log("[AIO Mod INFORMATION]", "yellow"); } diff --git a/Ereshkigal-AkiConfig/config/config.json b/Ereshkigal-AkiConfig/config/config.json index e270dad..cc8d875 100644 --- a/Ereshkigal-AkiConfig/config/config.json +++ b/Ereshkigal-AkiConfig/config/config.json @@ -41,12 +41,12 @@ "max": 2000 } } - } + }, + "fuelDrainRateMultipler": 1 } }, "Raids values": { "Loot values": { - "allowLootOverlay": false, "looseLootMultiplier": { "bigmap": 1, "develop": 1, @@ -82,27 +82,25 @@ "tarkovstreets": 1, "terminal": 1, "town": 1 - }, - "limits": { - "bigmap": 1000, - "develop": 30, - "factory4_day": 100, - "factory4_night": 100, - "interchange": 2000, - "laboratory": 1000, - "rezervbase": 3000, - "shoreline": 1000, - "woods": 200, - "hideout": 0, - "lighthouse": 1500, - "privatearea": 0, - "suburbs": 0, - "tarkovstreets": 0, - "terminal": 0, - "town": 0 } }, - "Airdrop values": {}, + "Airdrop values": { + "airdropChancePercent": { + "bigmap": 25, + "woods": 25, + "lighthouse": 25, + "shoreline": 25, + "interchange": 25, + "reserve": 25 + }, + "airdropMinStartTimeSeconds": 60, + "airdropMaxStartTimeSeconds": 300, + "airdropMinOpenHeight": 350, + "airdropMaxOpenHeight": 400, + "planeMinFlyHeight": 400, + "planeMaxFlyHeight": 500, + "planeVolume": 1 + }, "MIAOnRaidEnd": false, "raidMenuSettings": { "aiAmount": "AsOnline", @@ -329,5 +327,9 @@ "max": 764 } } - } + }, + "other": { + "hideWarningMessage": true, + "showModLogs": true + } } \ No newline at end of file diff --git a/Ereshkigal-AkiConfig/locale/locale.json b/Ereshkigal-AkiConfig/locale/locale.json index 76b1b9f..831636b 100644 --- a/Ereshkigal-AkiConfig/locale/locale.json +++ b/Ereshkigal-AkiConfig/locale/locale.json @@ -44,7 +44,6 @@ }, "Raids values": { "Loot values": { - "allowLootOverlay": "", "looseLootMultiplier": { "bigmap": "", "develop": "", @@ -80,27 +79,25 @@ "tarkovstreets": "", "terminal": "", "town": "" - }, - "limits": { - "bigmap": "", - "develop": "", - "factory4day": "", - "factory4night": "", - "interchange": "", - "laboratory": "", - "rezervbase": "", - "shoreline": "", - "woods": "", - "hideout": "", - "lighthouse": "", - "privatearea": "", - "suburbs": "", - "tarkovstreets": "", - "terminal": "", - "town": "" } }, - "Airdrop values": {}, + "Airdrop values": { + "airdropChancePercent": { + "bigmap": "", + "woods": "", + "lighthouse": "", + "shoreline": "", + "interchange": "", + "reserve": "" + }, + "airdropMinStartTimeSeconds": "", + "airdropMaxStartTimeSeconds": "", + "airdropMinOpenHeight": "", + "airdropMaxOpenHeight": "", + "planeMinFlyHeight": "", + "planeMaxFlyHeight": "", + "planeVolume": "" + }, "MIAOnRaidEnd": "", "raidMenuSettings": { "aiAmount": "", @@ -249,5 +246,9 @@ "max": "" } } - } + }, + "other": { + "hideWarningMessage": "", + "showModLogs": "" + } } \ No newline at end of file diff --git a/Ereshkigal-AkiConfig/models/IConfig.ts b/Ereshkigal-AkiConfig/models/IConfig.ts index 6a3cb03..12af60c 100644 --- a/Ereshkigal-AkiConfig/models/IConfig.ts +++ b/Ereshkigal-AkiConfig/models/IConfig.ts @@ -54,6 +54,7 @@ export interface Hideout { runIntervalSeconds: number; scavCase: ScavCase; + fuelDrainRateMultipler: number; } export interface LootMultiplier @@ -78,10 +79,30 @@ export interface LootMultiplier export interface LootValues { - allowLootOverlay: boolean; looseLootMultiplier: LootMultiplier; staticLootMultiplier: LootMultiplier; - limits: LootMultiplier; +} + +export interface AirdropChancePercent +{ + bigmap: number; + woods: number; + lighthouse: number; + shoreline: number; + interchange: number; + reserve: number; +} + +export interface AirdropValues +{ + airdropChancePercent: AirdropChancePercent; + airdropMinOpenHeight: number; + airdropMaxOpenHeight: number; + planeMinFlyHeight: number; + planeMaxFlyHeight: number; + planeVolume: number; + airdropMinStartTimeSeconds: number; + airdropMaxStartTimeSeconds: number; } export interface RaidMenuSettings @@ -210,6 +231,12 @@ export interface Weather pressure: MinMax; } +export interface Other +{ + hideWarningMessage: boolean; + showModLogs: boolean; +} + export interface ServerValues { http: HTTP; @@ -220,7 +247,7 @@ export interface ServerValues export interface RaidsValues { lootValues: LootValues; - airdropValues: any; + airdropValues: AirdropValues; miaOnRaidEnd: boolean; raidMenuSettings: RaidMenuSettings; save: RaidsValuesSave; @@ -258,4 +285,5 @@ export interface IConfig tradersValues: TradersValues; fleaMarketConfiguration: FleaMarketConfiguration; weatherValues: WeatherValues; + other: Other; } \ No newline at end of file diff --git a/Ereshkigal-AkiConfig/models/ILocale.ts b/Ereshkigal-AkiConfig/models/ILocale.ts index 84f2fc6..eb4fe3d 100644 --- a/Ereshkigal-AkiConfig/models/ILocale.ts +++ b/Ereshkigal-AkiConfig/models/ILocale.ts @@ -54,6 +54,7 @@ export interface Hideout { runIntervalSeconds: string; scavCase: ScavCase; + fuelDrainRateMultipler: number; } export interface LootMultiplier @@ -78,10 +79,30 @@ export interface LootMultiplier export interface LootValues { - allowLootOverlay: boolean; looseLootMultiplier: LootMultiplier; staticLootMultiplier: LootMultiplier; - limits: LootMultiplier; +} + +export interface AirdropChancePercent +{ + bigmap: number; + woods: number; + lighthouse: number; + shoreline: number; + interchange: number; + reserve: number; +} + +export interface AirdropValues +{ + airdropChancePercent: AirdropChancePercent; + airdropMinOpenHeight: number; + airdropMaxOpenHeight: number; + planeMinFlyHeight: number; + planeMaxFlyHeight: number; + planeVolume: number; + airdropMinStartTimeSeconds: number; + airdropMaxStartTimeSeconds: number; } export interface RaidMenuSettings @@ -210,6 +231,12 @@ export interface Weather pressure: MinMax; } +export interface Other +{ + hideWarningMessage: boolean; + showModLogs: boolean; +} + export interface ServerValues { http: HTTP; @@ -220,7 +247,7 @@ export interface ServerValues export interface RaidsValues { lootValues: LootValues; - airdropValues: string; + airdropValues: AirdropValues; miaOnRaidEnd: boolean; raidMenuSettings: RaidMenuSettings; save: RaidsValuesSave; @@ -258,4 +285,5 @@ export interface ILocale tradersValues: TradersValues; fleaMarketConfiguration: FleaMarketConfiguration; weatherValues: WeatherValues; + other: Other; } \ No newline at end of file diff --git a/Ereshkigal-AkiConfig/src/Notifications.ts b/Ereshkigal-AkiConfig/src/Notifications.ts index 41009f3..385da6b 100644 --- a/Ereshkigal-AkiConfig/src/Notifications.ts +++ b/Ereshkigal-AkiConfig/src/Notifications.ts @@ -1,866 +1,28 @@ import { inject, injectable } from "tsyringe"; import type { ILogger } from "@spt-aki/models/spt/utils/ILogger"; -import { AIOConfigHandler } from "./AIOConfigHandler"; +import { AkiConfigHandler } from "./AkiConfigHandler"; @injectable() export class Notifications { constructor( @inject("WinstonLogger") private logger: ILogger, - @inject("AIOConfigHandler") private configHandler: AIOConfigHandler + @inject("AkiConfigHandler") private configHandler: AkiConfigHandler ) {} public sendNotifications(): void { - const config = this.configHandler.getConfig(); const locale = this.configHandler.getLocales(); if (!config.other.hideWarningMessage) { - this.logger.log("[AIO Mod INFORMATION]", "yellow"); - this.logger.info("Please read the README.PDF carefully as this has all the information you need."); - this.logger.log("[AIO Mod INFORMATION]", "yellow"); + this.logger.log("[AIO Config INFORMATION]", "yellow"); + this.logger.info("Please read the AKICONFIG README.pdf carefully as this has all the information you need."); + this.logger.log("[AIO Config INFORMATION]", "yellow"); } - //Items: - // All Examined Items: - if (config.items.allExaminedItems) - { - this.logger.info("AllInOne Mod: AllExaminedItems activated."); - if (typeof config.items.allExaminedItems !== "boolean") - { - this.logger.warning(locale.items.allExaminedItems); - } - } - - // Weight Changes: - if (config.items.weightChanges !== false) - { - this.logger.info("AllInOne Mod: WeightChanges activated."); - if (typeof config.items.weightChanges !== "boolean" && config.items.weightChanges <= 0) - { - this.logger.warning(locale.items.weightChanges); - } - } - - // More Stack: - if (config.items.moreStack !== false) - { - this.logger.info("AllInOne Mod: moreStack activated."); - if (typeof config.items.moreStack !== "number") - { - this.logger.warning(locale.items.moreStack); - } - } - - // Equip Rigs With Armors: - if (config.items.equipRigsWithArmors) - { - this.logger.info("AllInOne Mod: equipRigsWithArmors activated."); - if (typeof config.items.equipRigsWithArmors !== "boolean") - { - this.logger.warning(locale.items.equipRigsWithArmors); - } - } - - // Force Money Stack: - if (config.items.forceMoneyStack !== false) - { - this.logger.info("AllInOne Mod: forceMoneyStack activated."); - if (typeof config.items.forceMoneyStack !== "number") - { - this.logger.warning(locale.items.forceMoneyStack); - } - } - - // Remove Secure Container Filters: - if (config.items.removeSecureContainerFilters) - { - this.logger.info("AllInOne Mod: removeSecureContainerFilters activated."); - if (typeof config.items.removeSecureContainerFilters !== "boolean") - { - this.logger.warning(locale.items.removeSecureContainerFilters); - } - } - - // Remove Backpack Restrictions: - if (config.items.removeBackpacksRestrictions) - { - this.logger.info("AllInOne Mod: removeBackpacksRestrictions activated."); - if (typeof config.items.removeBackpacksRestrictions !== "boolean") - { - this.logger.warning(locale.items.removeBackpacksRestrictions); - } - } - - // Remove Secure Container Filters: - if (config.items.removeContainersRestrictions) - { - this.logger.info("AllInOne Mod: removeContainersRestrictions activated."); - if (typeof config.items.removeContainersRestrictions !== "boolean") - { - this.logger.warning(locale.items.removeContainersRestrictions); - } - } - - // In Raid Moddable - if (config.items.inRaidModdable) - { - this.logger.info("AllInOne Mod: inRaidModdable activated."); - if (typeof config.items.inRaidModdable !== "boolean") - { - this.logger.warning(locale.items.inRaidModdable); - } - } - - // Increase Loot Exp - if (config.items.increaseLootExp !== false) - { - this.logger.info("AllInOne Mod: increaseLootExp activated."); - if (typeof config.items.increaseLootExp !== "number") - { - this.logger.warning(locale.items.increaseLootExp); - } - } - - // Increase Examine Exp - if (config.items.increaseExamineExp !== false) - { - this.logger.info("AllInOne Mod: increaseExamineExp activated."); - if (typeof config.items.increaseExamineExp !== "number") - { - this.logger.warning(locale.items.increaseExamineExp); - } - } - - // Remove Key Usage Number - if (config.items.removeKeyUsageNumber) - { - this.logger.info("AllInOne Mod: removeKeyUsageNumber activated."); - if (typeof config.items.removeKeyUsageNumber !== "boolean") - { - this.logger.warning(locale.items.removeKeyUsageNumber); - } - } - - // Stackable Barters - if (config.items.stackableBarters.activated) - { - this.logger.info("AllInOne Mod: stackableBarters activated."); - if (typeof config.items.stackableBarters.activated !== "boolean") - { - this.logger.warning(locale.items.stackableBarters); - } - } - - // Weapon Malf - Overheat - if (config.items.weaponMalfunctions.overheat) - { - this.logger.info("AllInOne Mod: weaponMalfunctions.overheat activated."); - if (typeof config.items.weaponMalfunctions.overheat !== "boolean") - { - this.logger.warning(locale.items.weaponMalfunctions.overheat); - } - } - - // Weapon Malf - jam - if (config.items.weaponMalfunctions.jam) - { - this.logger.info("AllInOne Mod: weaponMalfunctions.jam activated."); - if (typeof config.items.weaponMalfunctions.jam !== "boolean") - { - this.logger.warning(locale.items.weaponMalfunctions.jam); - } - } - - // Weapon Malf - slide - if (config.items.weaponMalfunctions.slide) - { - this.logger.info("AllInOne Mod: weaponMalfunctions.slide activated."); - if (typeof config.items.weaponMalfunctions.slide !== "boolean") - { - this.logger.warning(locale.items.weaponMalfunctions.slide); - } - } - - // Weapon Malf - misfire - if (config.items.weaponMalfunctions.misfire) - { - this.logger.info("AllInOne Mod: weaponMalfunctions.misfire activated."); - if (typeof config.items.weaponMalfunctions.misfire !== "boolean") - { - this.logger.warning(locale.items.weaponMalfunctions.misfire); - } - } - - // Weapon Malf - misfire - if (config.items.weaponMalfunctions.feed) - { - this.logger.info("AllInOne Mod: weaponMalfunctions.feed activated."); - if (typeof config.items.weaponMalfunctions.feed !== "boolean") - { - this.logger.warning(locale.items.weaponMalfunctions.feed); - } - } - - // Weapon Dura - Min - if (config.items.weaponDurabilities.minimumSpawnDurability !== false) - { - this.logger.info("AllInOne Mod: weaponsDurabilities.minimumSpawnDurability activated."); - if (typeof config.items.weaponDurabilities.minimumSpawnDurability !== "number") - { - this.logger.warning(locale.items.weaponDurabilities.minimumSpawnDurability); - } - } - - // Weapon Dura - Max - if (config.items.weaponDurabilities.maximumSpawnDurability !== false) - { - this.logger.info("AllInOne Mod: weaponsDurabilities.maximumSpawnDurability activated."); - if (typeof config.items.weaponDurabilities.maximumSpawnDurability !== "number") - { - this.logger.warning(locale.items.weaponDurabilities.maximumSpawnDurability); - } - } - - // Remove All Gear Penalties - if (config.items.removeAllGearPenalties) - { - this.logger.info("AllInOne Mod: removeAllGearPenalties activated."); - if (typeof config.items.removeAllGearPenalties !== "boolean") - { - this.logger.warning(locale.items.removeAllGearPenalties); - } - } - - // Remove Item Durability Burn - if (config.items.removeItemDurabilityBurn) - { - this.logger.info("AllInOne Mod: removeItemDurabilityBurn activated."); - if (typeof config.items.removeItemDurabilityBurn !== "boolean") - { - this.logger.warning(locale.items.removeItemDurabilityBurn); - } - } - - // Remove Bullet Weapon Durability Damage - if (config.items.removeBulletWeaponDurabilityDamage) - { - this.logger.info("AllInOne Mod: removeBulletWeaponDurabilityDamage activated."); - if (typeof config.items.removeBulletWeaponDurabilityDamage !== "boolean") - { - this.logger.warning(locale.items.removeBulletWeaponDurabilityDamage); - } - } - - // Remove Weapon Preset Restriction - if (config.items.removeWeaponPresetRestriction) - { - this.logger.info("AllInOne Mod: removeWeaponPresetRestriction activated."); - if (typeof config.items.removeWeaponPresetRestriction !== "boolean") - { - this.logger.warning(locale.items.removeWeaponPresetRestriction); - } - } - - // Change Indicidual Item Property - if (config.items.changeIndividualItemProperty.activated) - { - this.logger.info("AllInOne Mod: changeIndividualItemProperty activated."); - if (typeof config.items.changeIndividualItemProperty.activated !== "boolean") - { - this.logger.warning(locale.items.changeIndividualItemProperty.activated); - } - } - - // Hideout: - // Change Fuel Consumption Rate - if (config.hideout.changeFuelConsumptionRate !== false) - { - this.logger.info("AllInOne Mod: changeFuelConsumptionRate activated."); - if (typeof config.hideout.changeFuelConsumptionRate !== "number") - { - this.logger.warning(locale.hideout.changeFuelConsumptionRate); - } - } - - // Fast Hideout Construction - if (config.hideout.fastHideoutConstruction) - { - this.logger.info("AllInOne Mod: fastHideoutConstruction activated."); - if (typeof config.hideout.fastHideoutConstruction !== "boolean") - { - this.logger.warning(locale.hideout.fastHideoutConstruction); - } - } - - // Fast Hideout Construction - if (config.hideout.fastHideoutProduction) - { - this.logger.info("AllInOne Mod: fastHideoutProduction activated."); - if (typeof config.hideout.fastHideoutProduction !== "boolean") - { - this.logger.warning(locale.hideout.fastHideoutProduction); - } - } - - // Fast Scav Case - if (config.hideout.fastScavCase) - { - this.logger.info("AllInOne Mod: fastScavCase activated."); - if (typeof config.hideout.fastScavCase !== "boolean") - { - this.logger.warning(locale.hideout.fastScavCase); - } - } - - // Scav Case Price Reducer - if (config.hideout.scavCasePriceReducer) - { - this.logger.info("AllInOne Mod: scavCasePriceReducer activated."); - if (typeof config.hideout.scavCasePriceReducer !== "boolean") - { - this.logger.warning(locale.hideout.scavCasePriceReducer); - } - } - - // Remove Construction Requirements - if (config.hideout.removeConstructionRequirements) - { - this.logger.info("AllInOne Mod: removeConstructionRequirements activated."); - if (typeof config.hideout.removeConstructionRequirements !== "boolean") - { - this.logger.warning(locale.hideout.removeConstructionRequirements); - } - } - - // Player: - // Remove Scav Timer - if (config.player.removeScavTimer) - { - this.logger.info("AllInOne Mod: removeScavTimer activated."); - if (typeof config.player.removeScavTimer !== "boolean") - { - this.logger.warning(locale.player.removeScavTimer); - } - } - - // Change Skill Progression Multiplier - if (config.player.changeSkillProgressionMultiplier !== false) - { - this.logger.info("AllInOne Mod: changeSkillProgressionMultiplier activated."); - if (typeof config.player.changeSkillProgressionMultiplier !== "number") - { - this.logger.warning(locale.player.changeSkillProgressionMultiplier); - } - } - - // Change Weapon Skill Multiplier - if (config.player.changeWeaponSkillMultiplier !== false) - { - this.logger.info("AllInOne Mod: changeWeaponSkillMultiplier activated."); - if (typeof config.player.changeWeaponSkillMultiplier !== "number") - { - this.logger.warning(locale.player.changeWeaponSkillMultiplier); - } - } - - // Disable Skill Fatigue - if (config.player.disableSkillFatigue !== false) - { - this.logger.info("AllInOne Mod: disableSkillFatigue activated."); - if (typeof config.player.disableSkillFatigue !== "boolean" && ( config.player.disableSkillFatigue).toLowerCase() !== "custom") - { - this.logger.warning(locale.player.disableSkillFatigue); - } - } - - // skillFatiguePerPoint - if (typeof config.player.skillFatiguePerPoint !== "number") - { - this.logger.warning(locale.player.skillFatiguePerPoint) - } - - // skillFreshEffectiveness - if (typeof config.player.skillFreshEffectiveness !== "number") - { - this.logger.warning(locale.player.skillFreshEffectiveness) - } - - // skillFreshPoints - if (typeof config.player.skillFreshPoints !== "number") - { - this.logger.warning(locale.player.skillFreshPoints) - } - - // skillPointsBeforeFatigue - if (typeof config.player.skillPointsBeforeFatigue !== "number") - { - this.logger.warning(locale.player.skillPointsBeforeFatigue) - } - - // skillFatigueReset - if (typeof config.player.skillFatigueReset !== "number") - { - this.logger.warning(locale.player.skillFatigueReset) - } - - // Change Max Stamina - if (config.player.changeMaxStamina !== false) - { - this.logger.info("AllInOne Mod: changeMaxStamina activated."); - if (typeof config.player.changeMaxStamina !== "number") - { - this.logger.warning(locale.player.changeMaxStamina); - } - } - - // Unlimited Stamina - if (config.player.unlimitedStamina) - { - this.logger.info("AllInOne Mod: unlimitedStamina activated."); - if (typeof config.player.unlimitedStamina !== "boolean") - { - this.logger.warning(locale.player.unlimitedStamina); - } - } - - // Remove In Raid Restrictions - if (config.player.removeInRaidsRestrictions) - { - this.logger.info("AllInOne Mod: removeInRaidsRestrictions activated."); - if (typeof config.player.removeInRaidsRestrictions !== "boolean") - { - this.logger.warning(locale.player.removeInRaidsRestrictions); - } - } - // Diable Fall Damage - if (config.player.disableFallDamage) - { - this.logger.info("AllInOne Mod: disableFallDamage activated."); - if (typeof config.player.disableFallDamage !== "boolean") - { - this.logger.warning(locale.player.disableFallDamage); - } - } - - // All Skills Master - if (config.player.allSkillsMaster) - { - this.logger.info("AllInOne Mod: allSkillsMaster activated."); - if (typeof config.player.allSkillsMaster !== "boolean") - { - this.logger.warning(locale.player.allSkillsMaster); - } - } - - // Enable Skill BotReload - if (config.player.enableSkillBotReload) - { - this.logger.info("AllInOne Mod: enableSkillBotReload activated."); - if (typeof config.player.enableSkillBotReload !== "boolean") - { - this.logger.warning(locale.player.enableSkillBotReload); - } - } - - // Enable Skill BotSound - if (config.player.enableSkillBotSound) - { - this.logger.info("AllInOne Mod: enableSkillBotSound activated."); - if (typeof config.player.enableSkillBotSound !== "boolean") - { - this.logger.warning(locale.player.enableSkillBotSound); - } - } - - // Remove Scav Karma - if (config.player.removeScavKarma) - { - this.logger.info("AllInOne Mod: removeScavKarma activated."); - if (typeof config.player.removeScavKarma !== "boolean") - { - this.logger.warning(locale.player.removeScavKarma); - } - } - - // Energy Drain Rate - if (config.player.energyDrainRate !== false) - { - this.logger.info("AllInOne Mod: energyDrainRate activated."); - if (typeof config.player.energyDrainRate !== "number") - { - this.logger.warning(locale.player.energyDrainRate); - } - } - - // Energy Drain Time - if (config.player.energyDrainTime !== false) - { - this.logger.info("AllInOne Mod: energyDrainTime activated."); - if (typeof config.player.energyDrainTime !== "number") - { - this.logger.warning(locale.player.energyDrainTime); - } - } - - // Hydratation Drain Rate - if (config.player.hydrationDrainRate !== false) - { - this.logger.info("AllInOne Mod: hydratationDrainRate activated."); - if (typeof config.player.hydrationDrainRate !== "number") - { - this.logger.warning(locale.player.hydrationDrainRate); - } - } - - // Hydratation Drain Time - if (config.player.hydrationDrainTime !== false) - { - this.logger.info("AllInOne Mod: hydratationDrainTime activated."); - if (typeof config.player.hydrationDrainTime !== "number") - { - this.logger.warning(locale.player.hydrationDrainTime); - } - } - - // Regeneration Loop Time - if (config.player.regenerationLoopTime !== false) - { - this.logger.info("AllInOne Mod: regenerationLoopTime activated."); - if (typeof config.player.regenerationLoopTime !== "number") - { - this.logger.warning(locale.player.regenerationLoopTime); - } - } - - // Energy Restoration - if (config.player.energyRestoration !== false) - { - this.logger.info("AllInOne Mod: energyRestoration activated."); - if (typeof config.player.energyRestoration !== "number") - { - this.logger.warning(locale.player.energyRestoration); - } - } - - // Hydration Restoration - if (config.player.hydrationRestoration !== false) - { - this.logger.info("AllInOne Mod: hydrationRestoration activated."); - if (typeof config.player.hydrationRestoration !== "number") - { - this.logger.warning(locale.player.hydrationRestoration); - } - } - - // Traders: - // All Quests Available - if (config.traders.allQuestsAvailable) - { - this.logger.info("AllInOne Mod: allQuestsAvailable activated."); - if (typeof config.traders.allQuestsAvailable !== "boolean") - { - this.logger.warning(locale.traders.allQuestsAvailable); - } - } - - // All Clothes Free - if (config.traders.allClothesFree) - { - this.logger.info("AllInOne Mod: allClothesFree activated."); - if (typeof config.traders.allClothesFree !== "boolean") - { - this.logger.warning(locale.traders.allClothesFree); - } - } - - // All Clothes For Every Side - if (config.traders.allClothesForEverySide) - { - this.logger.info("AllInOne Mod: allClothesForEverySide activated."); - if (typeof config.traders.allClothesForEverySide !== "boolean") - { - this.logger.warning(locale.traders.allClothesForEverySide); - } - } - - // Change Flea Market Level - if (config.traders.changeFleaMarketLvl !== false) - { - this.logger.info("AllInOne Mod: changeFleaMarketLvl activated."); - if (typeof config.traders.changeFleaMarketLvl !== "number") - { - this.logger.warning(locale.traders.changeFleaMarketLvl); - } - } - - // Insurance Time Activated - if (config.traders.insuranceTime.activated) - { - this.logger.info("AllInOne Mod: insuranceTime activated.") - if (typeof config.traders.insuranceTime.activated !== "boolean") - { - this.logger.warning(locale.traders.insuranceTime.activated); - } - } - - // Insurance Time - Therapist - if (config.traders.insuranceTime.therapist.activated) - { - this.logger.info("AllInOne Mod: InsuranceTime.Therapist activated.") - if (typeof config.traders.insuranceTime.therapist.activated !== "boolean") - { - this.logger.warning(locale.traders.insuranceTime.therapist.activated); - } - } - - // Insurance Time - Prapor - if (config.traders.insuranceTime.prapor.activated) - { - this.logger.info("AllInOne Mod: InsuranceTime.Prapor activated.") - if (typeof config.traders.insuranceTime.prapor.activated !== "boolean") - { - this.logger.warning(locale.traders.insuranceTime.prapor.activated); - } - } - - // All Traders 4 Star - Unlock All Items At LL1 - if (config.traders.traderChanges.unlockAllItemsAtLL1 && config.traders.traderChanges.allTraders4Stars) - { - this.logger.warning(locale.traders.traderChanges.all4StarAndLL1); - } - else if (config.traders.traderChanges.allTraders4Stars) - { - this.logger.info("AllInOne Mod: allTraders4Stars activated.") - if (typeof config.traders.traderChanges.allTraders4Stars !== "boolean") - { - this.logger.warning(locale.traders.traderChanges.allTraders4Stars); - } - } - else if (config.traders.traderChanges.unlockAllItemsAtLL1) - { - this.logger.info("AllInOne Mod: unlockAllItemsAtLL1 activated.") - if (typeof config.traders.traderChanges.unlockAllItemsAtLL1 !== "boolean") - { - this.logger.warning(locale.traders.traderChanges.unlockAllItemsAtLL1); - } - } - - // Remove Items From Quest Locks - if (config.traders.traderChanges.removeItemsFromQuestLocks) - { - this.logger.info("AllInOne Mod: removeItemsFromQuestLocks activated.") - if (typeof config.traders.traderChanges.removeItemsFromQuestLocks !== "boolean") - { - this.logger.warning(locale.traders.traderChanges.removeItemsFromQuestLocks); - } - } - - // Max Insurance Storage Time - if (config.traders.maxInsuranceStorageTime) - { - this.logger.info("AllInOne Mod: maxInsuranceStorageTime activated.") - if (typeof config.traders.maxInsuranceStorageTime !== "boolean" && config.traders.maxInsuranceStorageTime <= 0) - { - this.logger.warning(locale.traders.maxInsuranceStorageTime); - } - } - - // Prevent Fence Mastering - if (config.traders.preventFenceMastering) - { - this.logger.info("AllInOne Mod: preventFenceMastering activated.") - if (typeof config.traders.preventFenceMastering !== "boolean") - { - this.logger.warning(locale.traders.preventFenceMastering); - } - } - - // Remove FIR Condition On Quests - if (config.traders.removeFIRConditionOnQuests) - { - this.logger.info("AllInOne Mod: removeFIRConditionOnQuests activated.") - if (typeof config.traders.removeFIRConditionOnQuests !== "boolean") - { - this.logger.warning(locale.traders.removeFIRConditionOnQuests); - } - } - - // Raids: - // No Extract Restrictions - if (config.raids.noExtractRestrictions) - { - this.logger.info("AllInOne Mod: noExtractRestrictions activated.") - if (typeof config.raids.noExtractRestrictions !== "boolean") - { - this.logger.warning(locale.raids.noExtractRestrictions); - } - } - - // All Extractions Avaliable - if (config.raids.allExtractionsAvailable) - { - this.logger.info("AllInOne Mod: allExtractionsAvailable activated.") - if (typeof config.raids.allExtractionsAvailable !== "boolean") - { - this.logger.warning(locale.raids.allExtractionsAvailable); - } - } - - // Increased Boss Chances - if (config.raids.increasedBossChance) - { - this.logger.info("AllInOne Mod: increasedBossChance activated.") - if (typeof config.raids.increasedBossChance !== "boolean") - { - this.logger.warning(locale.raids.increasedBossChance); - } - } - - // Extended Raid - if (config.raids.extendedRaid !== false) - { - this.logger.info("AllInOne Mod: extendedRaid activated."); - if (typeof config.raids.extendedRaid !== "number") - { - this.logger.warning(locale.raids.extendedRaid); - } - } - - // Remove Labs Keycard - if (config.raids.removeLabsKeycard) - { - this.logger.info("AllInOne Mod: removeLabsKeycard activated.") - if (typeof config.raids.removeLabsKeycard !== "boolean") - { - this.logger.warning(locale.raids.removeLabsKeycard); - } - } - - // Extractions Extended - if (config.raids.extractionsExtended) - { - this.logger.info("AllInOne Mod: extractionsExtended activated.") - if (typeof config.raids.extractionsExtended !== "boolean") - { - this.logger.warning(locale.raids.extractionsExtended); - } - } - - // Insurance On All Maps - if (config.raids.insuranceOnAllMaps) - { - this.logger.info("AllInOne Mod: insuranceOnAllMaps activated.") - if (typeof config.raids.insuranceOnAllMaps !== "boolean") - { - this.logger.warning(locale.raids.insuranceOnAllMaps); - } - } - - // Fixes: - // Fins Choke Me Harder - if (config.fixes.finsChokeMeHarder) - { - this.logger.info("AllInOne Mod: finsChokeMeHarder activated.") - if (typeof config.fixes.finsChokeMeHarder !== "boolean") - { - this.logger.warning(locale.fixes.finsChokeMeHarder); - } - } - - // Chomps Raider Spawn Fix - if (config.fixes.chompsRaiderSpawnFix) - { - this.logger.info("AllInOne Mod: chompsRaiderSpawnFix activated.") - if (typeof config.fixes.chompsRaiderSpawnFix !== "boolean") - { - this.logger.warning(locale.fixes.chompsRaiderSpawnFix); - } - } - - // justNUs Even More Open Zones - if (config.fixes.justNUsEvenMoreOpenZones) - { - this.logger.info("AllInOne Mod: justNUsEvenMoreOpenZones activated.") - if (typeof config.fixes.justNUsEvenMoreOpenZones !== "boolean") - { - this.logger.warning(locale.fixes.justNUsEvenMoreOpenZones); - } - } - - // Other: - // Pre Wipe Events: - if (config.other.preWipeEvents.raidersOnAllMaps) - { - this.logger.info("AllInOne Mod: raidersOnAllMaps activated.") - if (typeof config.other.preWipeEvents.raidersOnAllMaps !== "boolean") - { - this.logger.warning(locale.other.preWipeEvents.raidersOnAllMaps); - } - } - - // Killa On Factory: - if (config.other.preWipeEvents.killaOnFactory) - { - this.logger.info("AllInOne Mod: killaOnFactory activated.") - if (typeof config.other.preWipeEvents.killaOnFactory !== "boolean") - { - this.logger.warning(locale.other.preWipeEvents.killaOnFactory); - } - } - - // All Bosses On Reserve: - if (config.other.preWipeEvents.allBossesOnReserve) - { - this.logger.info("AllInOne Mod: allBossesOnReserve activated.") - if (typeof config.other.preWipeEvents.allBossesOnReserve !== "boolean") - { - this.logger.warning(locale.other.preWipeEvents.allBossesOnReserve); - } - } - - // All Traders Sell Cheap Items - if (config.other.preWipeEvents.allTradersSellCheapItems) - { - this.logger.info("AllInOne Mod: allTradersSellCheapItems activated.") - if (typeof config.other.preWipeEvents.allTradersSellCheapItems !== "boolean") - { - this.logger.warning(locale.other.preWipeEvents.allTradersSellCheapItems); - } - } - - // Make Obdolbos Powerful - if (config.other.preWipeEvents.makeObdolbosPowerful) - { - this.logger.info("AllInOne Mod: makeObdolbosPowerful activated.") - if (typeof config.other.preWipeEvents.makeObdolbosPowerful !== "boolean") - { - this.logger.warning(locale.other.preWipeEvents.makeObdolbosPowerful); - } - } - - // Gluhkar On Labs - if (config.other.preWipeEvents.gluhkarOnLabs) - { - this.logger.info("AllInOne Mod: gluhkarOnLabs activated.") - if (typeof config.other.preWipeEvents.gluhkarOnLabs !== "boolean") - { - this.logger.warning(locale.other.preWipeEvents.gluhkarOnLabs); - } - } - - // Heat Wave - if (config.other.inGameEvents.heatWave) - { - this.logger.info("AllInOne Mod: heatWave activated.") - if (typeof config.other.inGameEvents.heatWave !== "boolean") - { - this.logger.warning(locale.other.inGameEvents.heatWave); - } - } } } \ No newline at end of file diff --git a/Ereshkigal-AkiConfig/src/bots.ts b/Ereshkigal-AkiConfig/src/bots.ts index 2730a86..6edef6c 100644 --- a/Ereshkigal-AkiConfig/src/bots.ts +++ b/Ereshkigal-AkiConfig/src/bots.ts @@ -1,46 +1,50 @@ import { inject, injectable } from "tsyringe"; -import type { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; +import type { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { IBotConfig } from "@spt-aki/models/spt/config/IBotConfig"; +import { ConfigServer } from "@spt-aki/servers/ConfigServer"; +import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; import { AkiConfigHandler } from "./AkiConfigHandler"; @injectable() -export class bots +export class Bots { constructor( - @inject("AkiConfigHandler") private configHandler: AkiConfigHandler, - @inject("DatabaseServer") private database: DatabaseServer + @inject("AkiConfigHandler") protected configHandler: AkiConfigHandler, + @inject("ConfigServer") protected configServer: ConfigServer, + @inject("WinstonLogger") private logger: ILogger ) {} public applyChanges(): void { - const configServer = container.resolve("ConfigServer"); - const BotConfig = configServer.getConfig(ConfigTypes.BOT); + const pmcConfig = this.configHandler.getPmcConfig(); + const bots = this.configServer.getConfig(ConfigTypes.BOT); - const pmcsConfig = this.configHandler.getPmcConfig().pmc.types - for (const bot in pmcsConfig) + for (const bot in pmcConfig.pmc.types) { - switch (bot) { + switch (bot) + { default: - bots.pmc.types[bot] = pmcsConfig[bot] + bots.pmc.types[bot] = pmcConfig.pmc.types[bot]; break; } } - for(const options in config.pmc){ - switch(options){ + for (const options in pmcConfig.pmc) + { + switch (options) + { case "types": break; default: - bots.pmc[options] = config.pmc[options] + bots.pmc[options] = pmcConfig.pmc[options]; break; } } - for (const bot in config.presetBatch) { - bots.presetBatch[bot] = config.presetBatch[bot] + for (const bot in pmcConfig.presetBatch) + { + bots.presetBatch[bot] = pmcConfig.presetBatch[bot]; } } } - -module.exports = bots; \ No newline at end of file diff --git a/Ereshkigal-AkiConfig/src/generator.ts b/Ereshkigal-AkiConfig/src/generator.ts index b03b547..72860d5 100644 --- a/Ereshkigal-AkiConfig/src/generator.ts +++ b/Ereshkigal-AkiConfig/src/generator.ts @@ -1,30 +1,39 @@ -import type { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { inject, injectable } from "tsyringe"; +import type { ILogger } from "@spt-aki/models/spt/utils/ILogger"; +import { IBotConfig } from "@spt-aki/models/spt/config/IBotConfig"; +import { IHealthConfig } from "@spt-aki/models/spt/config/IHealthConfig"; +import { IHideoutConfig } from "@spt-aki/models/spt/config/IHideoutConfig"; +import { IHttpConfig } from "@spt-aki/models/spt/config/IHttpConfig"; +import { IInRaidConfig } from "@spt-aki/models/spt/config/IInRaidConfig"; +import { IInsuranceConfig } from "@spt-aki/models/spt/config/IInsuranceConfig"; +import { IInventoryConfig } from "@spt-aki/models/spt/config/IInventoryConfig"; +import { ILocationConfig } from "@spt-aki/models/spt/config/ILocationConfig"; +import { IQuestConfig } from "@spt-aki/models/spt/config/IQuestConfig"; +import { IRagfairConfig } from "@spt-aki/models/spt/config/IRagfairConfig"; +import { IRepairConfig } from "@spt-aki/models/spt/config/IRepairConfig"; +import { ITraderConfig } from "@spt-aki/models/spt/config/ITraderConfig"; +import { IWeatherConfig } from "@spt-aki/models/spt/config/IWeatherConfig"; +import { IAirdropConfig } from "@spt-aki/models/spt/config/IAirdropConfig"; import { VFS } from "@spt-aki/utils/VFS"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; -import { IBotConfig } from "@spt-aki/models/spt/config/IBotConfig"; -import { IAirdropConfig } from "@spt-aki/models/spt/config/IAirdropConfig"; -import { IInRaidConfig } from "@spt-aki/models/spt/config/IInRaidConfig"; -import { IInventoryConfig } from "@spt-aki/models/spt/config/IInventoryConfig"; -import { ILocationConfig } from "@spt-aki/models/spt/config/ILocationConfig"; -import { IRagfairConfig } from "@spt-aki/models/spt/config/IRagfairConfig"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; @injectable() -export class AkiGenerator +export class Generator { - private mod; - private firstRun; - + private pkg = require("../package.json"); + constructor( + @inject("VFS") protected vfs: VFS, + @inject("JsonUtil") protected jsonUtil: JsonUtil, + @inject("ConfigServer") protected configServer: ConfigServer, @inject("WinstonLogger") private logger: ILogger ) {} - private createConfig(file: string): void + private createConfig(modPath: string, file: string): void { - this.mod = require("../package.json"); - this.firstRun = true; let config = null; let dailyConfig = null; let pmcConfig = null; @@ -39,42 +48,42 @@ export class AkiGenerator //"Enable Christmas Gifts": false, "HTTP": {}, "Health": {}, - "Hideout": {}, + "Hideout": {} }, "Raids values": { "Loot values": {}, - "Airdrop values": {}, + "Airdrop values": {} }, "Traders values": { "Traders": {}, "Repair": {}, "Insurances": {}, - "Trading": {}, + "Trading": {} }, "FleaMarket configuration": {}, - "Weather values": {}, + "Weather values": {} }; dailyConfig = {}; pmcConfig = {}; //We will have to gather every config that exists atm and throw them together into the object - const bots = ConfigServer.getConfig(ConfigTypes.BOT); - const health = HealthConfig; - const hideout = HideoutConfig; - const http = HttpConfig; - const inraid = InraidConfig; - const insurance = InsuranceConfig; - const inventory = InventoryConfig; - const location = LocationConfig; - const quest = QuestConfig; - const ragfair = RagfairConfig; - const repair = RepairConfig; - const trader = TraderConfig; - const weather = WeatherConfig; - //const airdrops = AirdropConfig + const bots = this.configServer.getConfig(ConfigTypes.BOT); + const health = this.configServer.getConfig(ConfigTypes.HEALTH); + const hideout = this.configServer.getConfig(ConfigTypes.HIDEOUT); + const http = this.configServer.getConfig(ConfigTypes.HTTP); + const inraid = this.configServer.getConfig(ConfigTypes.IN_RAID); + const insurance = this.configServer.getConfig(ConfigTypes.INSURANCE); + const inventory = this.configServer.getConfig(ConfigTypes.INVENTORY); + const location = this.configServer.getConfig(ConfigTypes.LOCATION); + const quest = this.configServer.getConfig(ConfigTypes.QUEST); + const ragfair = this.configServer.getConfig(ConfigTypes.RAGFAIR); + const repair = this.configServer.getConfig(ConfigTypes.REPAIR); + const trader = this.configServer.getConfig(ConfigTypes.TRADER); + const weather = this.configServer.getConfig(ConfigTypes.WEATHER); + const airdrops = this.configServer.getConfig(ConfigTypes.AIRDROP); - //Sorting the bots config now - Object.assign(pmcConfig, bots); + //Sorting the http values + Object.assign(config["Server values"]["HTTP"], http); //Sorting the health config Object.assign(config["Server values"]["Health"], health); @@ -82,11 +91,20 @@ export class AkiGenerator //Sorting the hideout values Object.assign(config["Server values"]["Hideout"], hideout); - //Sorting the http values - Object.assign(config["Server values"]["HTTP"], http); - //Sorting the inraid values Object.assign(config["Raids values"], inraid); + + //Sorting location values + Object.assign(config["Raids values"]["Loot values"], location); + + //Sorting airdrop values + //Object.assign(config["Raids values"]["Airdrop values"], airdrops) + + //Sorting trader values + Object.assign(config["Traders values"]["Traders"], trader); + + //Sorting repair values + Object.assign(config["Traders values"]["Repair"], repair); //Sorting insurance values Object.assign(config["Traders values"]["Insurances"], insurance); @@ -94,24 +112,15 @@ export class AkiGenerator //Sorting inventory values Object.assign(config["Traders values"]["Trading"], inventory); - //Sorting location values - Object.assign(config["Raids values"]["Loot values"], location); - - //Sorting airdrop values - //Object.assign(config["Raids values"]["Airdrop values"], airdrops) - //Sorting quest values Object.assign(dailyConfig, quest); + //Sorting the bots config now + Object.assign(pmcConfig, bots); + //Sorting ragfair values Object.assign(config["FleaMarket configuration"], ragfair); - //Sorting repair values - Object.assign(config["Traders values"]["Repair"], repair); - - //Sorting trader values - Object.assign(config["Traders values"]["Traders"], trader); - //Weather values Object.assign(config["Weather values"], weather); @@ -130,80 +139,102 @@ export class AkiGenerator if (file === null) { //Write the config in the folder - VFS.writeFile( - `${ModLoader.getModPath(mod.name)}config/config.json`, - JsonUtil.serialize(config, true) + this.vfs.writeFile( + `${modPath}config/config.json`, + this.jsonUtil.serialize(config, true) ); - VFS.writeFile( - `${ModLoader.getModPath(mod.name)}config/dailyConfig.json`, - JsonUtil.serialize(dailyConfig, true) + this.vfs.writeFile( + `${modPath}config/dailyConfig.json`, + this.jsonUtil.serialize(dailyConfig, true) ); - VFS.writeFile( - `${ModLoader.getModPath(mod.name)}config/pmcConfig.json`, - JsonUtil.serialize(pmcConfig, true) + this.vfs.writeFile( + `${modPath}config/pmcConfig.json`, + this.jsonUtil.serialize(pmcConfig, true) ); } else { this.logger.warning(`[AKI-CONFIG] - Generating ${file} file`) let toWrite = null - if(file === "config"){toWrite = config}else if(file === 'dailyConfig'){toWrite = dailyConfig}else if(file === 'pmcConfig'){toWrite = pmcConfig} - VFS.writeFile( - `${ModLoader.getModPath(mod.name)}config/${file}.json`, - JsonUtil.serialize(toWrite, true) + if (file === "config") + { + toWrite = config + } + else if (file === 'dailyConfig') + { + toWrite = dailyConfig + } + else if (file === 'pmcConfig') + { + toWrite = pmcConfig + } + this.vfs.writeFile( + `${modPath}config/${file}.json`, + this.jsonUtil.serialize(toWrite, true) ); } this.logger.error("[AKI-Config]: New configuration file created, please restart your server to use it."); } - public checkConfigExisting(): void + public checkConfigExisting(modPath: string): void { - const mod = require("../../package.json"); - const modPath = ModLoader.getModPath(mod.name); const validation = []; //Check if config folder exists - if (VFS.exists(`${modPath}config`)) { + if (this.vfs.exists(`${modPath}config`)) + { //Check if all the config folder exists - const fileList = VFS.getFiles(`${modPath}config/`); - for (const file in fileList) { - let fileName = fileList[file]; - if (fileName === "config.json") { - validation.push('config'); + const fileList = this.vfs.getFiles(`${modPath}config/`); + for (const file in fileList) + { + const fileName = fileList[file]; + if (fileName === "config.json") + { + validation.push("config"); } - if (fileName === "dailyConfig.json") { + if (fileName === "dailyConfig.json") + { validation.push("dailyConfig"); } - if (fileName === "pmcConfig.json") { + if (fileName === "pmcConfig.json") + { validation.push("pmcConfig"); } } //All configurations files existing - if ((validation.length === 3)) { + if ((validation.length === 3)) + { this.logger.success( - `[AKI-CONFIG] - All configurations files already created, all green.` + "[AKI-CONFIG] - All configurations files already created, all green." ); - } else { + } + else + { //One of the 3 file is missing, we only want to regenerate the missing one this.logger.error( - `[AKI-CONFIG] - A config file is missing. Generating the missing file` + "[AKI-CONFIG] - A config file is missing. Generating the missing file" ); - if (validation.includes("config")) {} else { - this.createConfig("config"); + if (!validation.includes("config")) + { + this.createConfig(modPath, "config"); } - if (validation.includes("dailyConfig")) {} else { - this.createConfig("dailyConfig"); + if (!validation.includes("dailyConfig")) + { + this.createConfig(modPath, "dailyConfig"); } - if (validation.includes("pmcConfig")) {} else { - this.createConfig("pmcConfig"); + if (!validation.includes("pmcConfig")) + { + this.createConfig(modPath, "pmcConfig"); } } - } else { + } + else + { this.logger.warning( "First time AKI-Configurator is run, generating the config file..." ); - this.createConfig(null); + this.createConfig(modPath, null); } } } \ No newline at end of file diff --git a/Ereshkigal-AkiConfig/src/mod.ts b/Ereshkigal-AkiConfig/src/mod.ts index 8bc0601..d3c2178 100644 --- a/Ereshkigal-AkiConfig/src/mod.ts +++ b/Ereshkigal-AkiConfig/src/mod.ts @@ -1,7 +1,17 @@ import { DependencyContainer, Lifecycle } from "tsyringe"; import type { IMod } from "@spt-aki/models/external/mod"; import type { ILogger } from "@spt-aki/models/spt/utils/ILogger"; +import { InitialModLoader } from "@spt-aki/loaders/InitialModLoader"; +import { Generator } from "./generator"; +import { Ragfair } from "./ragfair"; +import { Weather } from "./weather"; import { Bots } from "./bots"; +import { Raids } from "./raids"; +import { Server } from "./server"; +import { Traders } from "./traders"; +import { Quests } from "./quests"; +import { Notifications } from "./notifications"; +import { AkiConfigHandler } from "./AkiConfigHandler"; class AkiConfig implements IMod { @@ -10,6 +20,17 @@ class AkiConfig implements IMod public load(container: DependencyContainer): void { + container.register("AkiConfigHandler", AkiConfigHandler, {lifecycle:Lifecycle.Singleton}); + container.register("Generator", Generator); + container.register("Ragfair", Ragfair); + container.register("Weather", Weather); + container.register("Bots", Bots); + container.register("Raids", Raids); + container.register("Server", Server); + container.register("Traders", Traders); + container.register("Quests", Quests); + container.register("Notifications", Notifications); + this.logger = container.resolve("WinstonLogger"); this.pkg = require("../package.json"); @@ -18,7 +39,22 @@ class AkiConfig implements IMod public delayedLoad(container: DependencyContainer): void { - return; + const initialModLoader = container.resolve("InitialModLoader"); + const modPath = `./${initialModLoader.getModPath(this.pkg.name)}`; + + container.resolve("Generator").checkConfigExisting(modPath); + container.resolve("Ragfair").applyChanges(); + container.resolve("Weather").applyChanges(); + container.resolve("Bots").applyChanges(); + container.resolve("Raids").applyChanges(); + container.resolve("Server").applyChanges(); + container.resolve("Traders").applyChanges(); + container.resolve("Quests").applyChanges(); + + if (container.resolve("AkiConfigHandler").getConfig().other.showModLogs) + { + container.resolve("Notifications").sendNotifications() + } } } diff --git a/Ereshkigal-AkiConfig/src/quests.ts b/Ereshkigal-AkiConfig/src/quests.ts index 06ef6e7..ab66a07 100644 --- a/Ereshkigal-AkiConfig/src/quests.ts +++ b/Ereshkigal-AkiConfig/src/quests.ts @@ -1,17 +1,26 @@ -/* -エレシュキガル -*/ +import { inject, injectable } from "tsyringe"; +import type { ILogger } from "@spt-aki/models/spt/utils/ILogger"; +import { IQuestConfig } from "@spt-aki/models/spt/config/IQuestConfig"; +import { ConfigServer } from "@spt-aki/servers/ConfigServer"; +import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; +import { AkiConfigHandler } from "./AkiConfigHandler"; -"use strict"; - -class quests +@injectable() +export class Quests { - static applyValues() - { - const config = require('../../config/dailyConfig.json'); + constructor( + @inject("AkiConfigHandler") protected configHandler: AkiConfigHandler, + @inject("ConfigServer") protected configServer: ConfigServer, + @inject("WinstonLogger") private logger: ILogger + ) + {} - QuestConfig = config + public applyChanges(): void + { + const dailyConfig = this.configHandler.getDailyConfig(); + const questConfig = this.configServer.getConfig(ConfigTypes.QUEST); + + questConfig.redeemTime = dailyConfig.redeemTime; + questConfig.repeatableQuests = dailyConfig.repeatableQuests; } } - -module.exports = quests; \ No newline at end of file diff --git a/Ereshkigal-AkiConfig/src/ragfair.ts b/Ereshkigal-AkiConfig/src/ragfair.ts index a17b02b..04d4191 100644 --- a/Ereshkigal-AkiConfig/src/ragfair.ts +++ b/Ereshkigal-AkiConfig/src/ragfair.ts @@ -1,60 +1,72 @@ -/* -エレシュキガル -*/ +import { inject, injectable } from "tsyringe"; +import type { ILogger } from "@spt-aki/models/spt/utils/ILogger"; +import { IRagfairConfig } from "@spt-aki/models/spt/config/IRagfairConfig"; +import { ConfigServer } from "@spt-aki/servers/ConfigServer"; +import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; +import { Traders } from "@spt-aki/models/enums/Traders"; +import { AkiConfigHandler } from "./AkiConfigHandler"; -"use strict"; - -class ragfair +@injectable() +export class Ragfair { - static applyValues() + constructor( + @inject("AkiConfigHandler") protected configHandler: AkiConfigHandler, + @inject("ConfigServer") protected configServer: ConfigServer, + @inject("WinstonLogger") private logger: ILogger + ) + {} + + public applyChanges(): void { - const ragfair = RagfairConfig - const config = require('../../config/config.json') + const config = this.configHandler.getConfig(); + const ragfair = this.configServer.getConfig(ConfigTypes.RAGFAIR); - for(const options in ragfair.sell){ - ragfair.sell[options] = config["FleaMarket configuration"].sell[options] + for (const options in ragfair.sell) + { + ragfair.sell[options] = config["FleaMarket configuration"].sell[options]; } - for(const options in ragfair.dynamic){ - ragfair.dynamic[options] = config["FleaMarket configuration"].dynamic[options] + for (const options in ragfair.dynamic) + { + ragfair.dynamic[options] = config["FleaMarket configuration"].dynamic[options]; } - const traderList = config["FleaMarket configuration"].traders - for (const trader in config["FleaMarket configuration"].traders) { - switch (trader) { + const traderList = config["FleaMarket configuration"].traders; + for (const trader in config["FleaMarket configuration"].traders) + { + switch (trader) + { case "EnablePraporOffers": - ragfair.traders["54cb50c76803fa8b248b4571"] = traderList.EnablePraporOffers + ragfair.traders[Traders.PRAPOR] = traderList.EnablePraporOffers; break; case "EnableTheRapistOffers": - ragfair.traders["54cb57776803fa99248b456e"] = traderList.EnableTheRapistOffers; + ragfair.traders[Traders.THERAPIST] = traderList.EnableTheRapistOffers; break; case "EnableFenceOffers": - ragfair.traders["579dc571d53a0658a154fbec"] = traderList.EnableFenceOffers; + ragfair.traders[Traders.FENCE] = traderList.EnableFenceOffers; break; case "EnableSkierOffers": - ragfair.traders["58330581ace78e27b8b10cee"] = traderList.EnableSkierOffers; + ragfair.traders[Traders.SKIER] = traderList.EnableSkierOffers; break; case "EnablePeacekeeperOffers": - ragfair.traders["5935c25fb3acc3127c3d8cd9"] = traderList.EnablePeacekeeperOffers; + ragfair.traders[Traders.PEACEKEEPER] = traderList.EnablePeacekeeperOffers; break; case "EnableMechanicOffers": - ragfair.traders["5a7c2eca46aef81a7ca2145d"] = traderList.EnableMechanicOffers; + ragfair.traders[Traders.MECHANIC] = traderList.EnableMechanicOffers; break; case "EnableRagmanOffers": - ragfair.traders["5ac3b934156ae10c4430e83c"] = traderList.EnableRagmanOffers; + ragfair.traders[Traders.RAGMAN] = traderList.EnableRagmanOffers; break; case "EnableJaegerOffers": - ragfair.traders["54cb50c76803fa8b248b4571"] = traderList.EnableJaegerOffers; + ragfair.traders[Traders.JAEGER] = traderList.EnableJaegerOffers; break; case "EnableAllAvailableOffers": ragfair.traders["ragfair"] = traderList.EnableAllAvailableOffers; break; default: - ragfair.traders[trader] = traderList[trader] + ragfair.traders[trader] = traderList[trader]; break; } } } } - -module.exports = ragfair; \ No newline at end of file diff --git a/Ereshkigal-AkiConfig/src/raids.ts b/Ereshkigal-AkiConfig/src/raids.ts index 0670482..bb87c0f 100644 --- a/Ereshkigal-AkiConfig/src/raids.ts +++ b/Ereshkigal-AkiConfig/src/raids.ts @@ -1,25 +1,40 @@ -/* -エレシュキガル -*/ +import { inject, injectable } from "tsyringe"; +import type { ILogger } from "@spt-aki/models/spt/utils/ILogger"; +import { IInRaidConfig } from "@spt-aki/models/spt/config/IInRaidConfig"; +import { ILocationConfig } from "@spt-aki/models/spt/config/ILocationConfig"; +import { IAirdropConfig } from "@spt-aki/models/spt/config/IAirdropConfig"; +import { ConfigServer } from "@spt-aki/servers/ConfigServer"; +import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; +import { AkiConfigHandler } from "./AkiConfigHandler"; -"use strict"; - -class raids +@injectable() +export class Raids { - static applyValues() + constructor( + @inject("AkiConfigHandler") protected configHandler: AkiConfigHandler, + @inject("ConfigServer") protected configServer: ConfigServer, + @inject("WinstonLogger") private logger: ILogger + ) + {} + + public applyChanges(): void { - const inraid = InraidConfig; - const config = require('../../config/config.json'); - - for(const options in inraid) - { - inraid[options] = config["Raids values"][options]; - } + const config = this.configHandler.getConfig(); + const locationConfig = this.configServer.getConfig(ConfigTypes.LOCATION); + const airdropConfig = this.configServer.getConfig(ConfigTypes.AIRDROP); + const inRaidConfig = this.configServer.getConfig(ConfigTypes.IN_RAID); - LocationConfig = config['Raids values']['Loot values']; - AirdropConfig = config['Raids values']['Airdrop values'] + locationConfig.looseLootMultiplier = config["Raids values"]["Loot values"].looseLootMultiplier; + locationConfig.staticLootMultiplier = config["Raids values"]["Loot values"].staticLootMultiplier; + + for (const options in airdropConfig) + { + airdropConfig[options] = config["Raids values"]["Airdrop values"][options]; + } + for (const options in inRaidConfig) + { + inRaidConfig[options] = config["Raids values"][options]; + } } } - -module.exports = raids; \ No newline at end of file diff --git a/Ereshkigal-AkiConfig/src/server.ts b/Ereshkigal-AkiConfig/src/server.ts index 69a2677..6094ca5 100644 --- a/Ereshkigal-AkiConfig/src/server.ts +++ b/Ereshkigal-AkiConfig/src/server.ts @@ -1,22 +1,37 @@ -/* -エレシュキガル -*/ +import { inject, injectable } from "tsyringe"; +import type { ILogger } from "@spt-aki/models/spt/utils/ILogger"; +import { IHealthConfig } from "@spt-aki/models/spt/config/IHealthConfig"; +import { IHideoutConfig } from "@spt-aki/models/spt/config/IHideoutConfig"; +import { IHttpConfig } from "@spt-aki/models/spt/config/IHttpConfig"; +import { ConfigServer } from "@spt-aki/servers/ConfigServer"; +import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; +import { AkiConfigHandler } from "./AkiConfigHandler"; -"use strict"; - -class server +@injectable() +export class Server { - static applyValues() + constructor( + @inject("AkiConfigHandler") protected configHandler: AkiConfigHandler, + @inject("ConfigServer") protected configServer: ConfigServer, + @inject("WinstonLogger") private logger: ILogger + ) + {} + + public applyChanges(): void { + const config = this.configHandler.getConfig(); + const serverConfig = this.configServer.getConfig(ConfigTypes.HTTP); + const healthConfig = this.configServer.getConfig(ConfigTypes.HEALTH); + const hideoutConfig = this.configServer.getConfig(ConfigTypes.HIDEOUT); + + serverConfig.ip = config["Server values"].HTTP.ip; + serverConfig.port = config["Server values"].HTTP.port; - const config = require('../../config/config.json'); + healthConfig.healthMultipliers = config["Server values"].Health.healthMultipliers; + healthConfig.save = config["Server values"].Health.save; - DatabaseServer.tables.server = config["Server values"].HTTP; - - HideoutConfig = config["Server values"].Hideout; - - HealthConfig = config["Server values"].Health; + hideoutConfig.runIntervalSeconds = config["Server values"].Hideout.runIntervalSeconds; + hideoutConfig.scavCase = config["Server values"].Hideout.scavCase; + hideoutConfig.fuelDrainRateMultipler = config["Server values"].Hideout.fuelDrainRateMultipler; } } - -module.exports = server; \ No newline at end of file diff --git a/Ereshkigal-AkiConfig/src/traders.ts b/Ereshkigal-AkiConfig/src/traders.ts index 5fb05a7..f45f701 100644 --- a/Ereshkigal-AkiConfig/src/traders.ts +++ b/Ereshkigal-AkiConfig/src/traders.ts @@ -1,38 +1,49 @@ -/* -エレシュキガル -*/ +import { inject, injectable } from "tsyringe"; +import type { ILogger } from "@spt-aki/models/spt/utils/ILogger"; +import { IInsuranceConfig } from "@spt-aki/models/spt/config/IInsuranceConfig"; +import { IInventoryConfig } from "@spt-aki/models/spt/config/IInventoryConfig"; +import { IRepairConfig } from "@spt-aki/models/spt/config/IRepairConfig"; +import { ITraderConfig } from "@spt-aki/models/spt/config/ITraderConfig"; +import { ConfigServer } from "@spt-aki/servers/ConfigServer"; +import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; +import { AkiConfigHandler } from "./AkiConfigHandler"; -"use strict"; +@injectable() +export class Traders +{ + constructor( + @inject("AkiConfigHandler") protected configHandler: AkiConfigHandler, + @inject("ConfigServer") protected configServer: ConfigServer, + @inject("WinstonLogger") private logger: ILogger + ) + {} -class traders { - static applyValues() { - const insurance = InsuranceConfig; - const inventory = InventoryConfig; - const repair = RepairConfig; - const trader = TraderConfig; + public applyChanges(): void + { + const config = this.configHandler.getConfig(); + const insurance = this.configServer.getConfig(ConfigTypes.INSURANCE); + const inventory = this.configServer.getConfig(ConfigTypes.INVENTORY); + const repair = this.configServer.getConfig(ConfigTypes.REPAIR); + const trader = this.configServer.getConfig(ConfigTypes.TRADER); - const config = require('../../config/config.json') - - for(const options in insurance) + for (const options in insurance) { - insurance[options] = config["Traders values"].Insurances[options] + insurance[options] = config["Traders values"].Insurances[options]; } - for(const options in inventory) + for (const options in inventory) { - inventory[options] = config["Traders values"].Trading[options] + inventory[options] = config["Traders values"].Trading[options]; } - for(const options in repair) + for (const options in repair) { - repair[options] = config["Traders values"].Repair[options] + repair[options] = config["Traders values"].Repair[options]; } - for(const options in trader) + for (const options in trader) { - trader[options] = config["Traders values"].Traders[options] + trader[options] = config["Traders values"].Traders[options]; } } } - -module.exports = traders; \ No newline at end of file diff --git a/Ereshkigal-AkiConfig/src/weather.ts b/Ereshkigal-AkiConfig/src/weather.ts index ffa1401..6623f2e 100644 --- a/Ereshkigal-AkiConfig/src/weather.ts +++ b/Ereshkigal-AkiConfig/src/weather.ts @@ -1,15 +1,24 @@ -/* -エレシュキガル -*/ +import { inject, injectable } from "tsyringe"; +import type { ILogger } from "@spt-aki/models/spt/utils/ILogger"; +import { IWeatherConfig } from "@spt-aki/models/spt/config/IWeatherConfig"; +import { ConfigServer } from "@spt-aki/servers/ConfigServer"; +import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; +import { AkiConfigHandler } from "./AkiConfigHandler"; -"use strict"; - -class weather +@injectable() +export class Weather { - static applyValues() + constructor( + @inject("AkiConfigHandler") protected configHandler: AkiConfigHandler, + @inject("ConfigServer") protected configServer: ConfigServer, + @inject("WinstonLogger") private logger: ILogger + ) + {} + + public applyChanges(): void { - const weatherValues = WeatherConfig; - const config = require('../../config/config.json'); + const config = this.configHandler.getConfig(); + const weatherValues = this.configServer.getConfig(ConfigTypes.WEATHER); weatherValues.acceleration = config["Weather values"].acceleration; weatherValues.weather.clouds.min = config["Weather values"].weather.clouds.min; @@ -30,8 +39,5 @@ class weather weatherValues.weather.temp.max = config["Weather values"].weather.temp.max; weatherValues.weather.pressure.min = config["Weather values"].weather.pressure.min; weatherValues.weather.pressure.max = config["Weather values"].weather.pressure.max; - } } - -module.exports = weather; \ No newline at end of file