From a1860148955ed2e287a9269c1a52a321338975f9 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Thu, 19 Aug 2021 23:09:03 +0800 Subject: [PATCH] Added new EngineTweaks module and TweaksFile option --- artifacts/config_files/Tweaks.ini | 13 ++++++++++ artifacts/ddraw.ini | 9 +++++-- sfall/Modules/EngineTweaks.cpp | 43 +++++++++++++++++++++++++++++++ sfall/Modules/EngineTweaks.h | 33 ++++++++++++++++++++++++ sfall/Modules/Inventory.cpp | 7 +++-- sfall/ddraw.vcxproj | 2 ++ sfall/ddraw.vcxproj.filters | 6 +++++ sfall/main.cpp | 2 ++ 8 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 artifacts/config_files/Tweaks.ini create mode 100644 sfall/Modules/EngineTweaks.cpp create mode 100644 sfall/Modules/EngineTweaks.h diff --git a/artifacts/config_files/Tweaks.ini b/artifacts/config_files/Tweaks.ini new file mode 100644 index 00000000..44f5609b --- /dev/null +++ b/artifacts/config_files/Tweaks.ini @@ -0,0 +1,13 @@ +;Game engine tweaks + +[Main] + + +[Items] +;Override the PIDs of the standard healing drugs that AI will use in combat +;Set to -1 if you don't want AI to identify this item as a healing drug +;Note: Starting from sfall 4.3.1/3.8.31, you can set a new flag (FlagsExt: 0x04000000) +;in the proto for other items, so AI will use them for healing in combat as well +STIMPAK=40 +SUPER_STIMPAK=144 +HEALING_POWDER=237 diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index f6438c4b..dd34aa07 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -450,7 +450,7 @@ NPCsTryToSpendExtraAP=0 ;Note that enabling this option can affect the weapon of choice for some NPCs AIBestWeaponFix=1 -;Set to 1 to fix NPCs not taking chem_primary_desire in AI.txt as drug use preference when using drugs in their inventory +;Set to 1 to fix NPCs not taking chem_primary_desire in AI.txt as a preference list when using drugs in their inventory ;Set to 2 to allow NPCs to use only the drugs listed in chem_primary_desire and healing drugs (stimpaks and healing powder) ;Note: chem_primary_desire w/o fixes prevents the specified item PID from being consumed if all three values in the list are the same PID ;chem_primary_desire also works as a priority list of drug items the NPC will try to pick up in combat when they are on the ground @@ -786,7 +786,8 @@ CreditsAtBottom=0 ;Point the next line to an ini file containing the replacement skill data ;SkillsFile=sfall\Skills.ini -;To add additional perks to the game, uncomment the next line and set it to point to a file containing perk information +;To add additional perks to the game, uncomment the next line and point to a file containing perk information +;See the Perks.ini in the modders pack for an example file ;PerksFile=sfall\Perks.ini ;To add additional books to the game, uncomment the next line and point to a file containing book information @@ -800,6 +801,10 @@ CreditsAtBottom=0 ;Point to an ini file containing elevator data ;ElevatorsFile=sfall\Elevators.ini +;Allows you to change some engine parameters for the game mechanics +;See the Tweaks.ini in the modders pack for an example file +;TweaksFile=sfall\Tweaks.ini + ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX [Scripts] ;Comma-separated list of masked paths to load global scripts from diff --git a/sfall/Modules/EngineTweaks.cpp b/sfall/Modules/EngineTweaks.cpp new file mode 100644 index 00000000..608da459 --- /dev/null +++ b/sfall/Modules/EngineTweaks.cpp @@ -0,0 +1,43 @@ +/* + * sfall + * Copyright (C) 2008-2021 The sfall team + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "..\main.h" +#include "..\FalloutEngine\Fallout2.h" + +#include "..\Game\items.h" + +#include "EngineTweaks.h" + +namespace sfall +{ + +void EngineTweaks::init() { + auto tweaksFile = IniReader::GetConfigString("Misc", "TweaksFile", "", MAX_PATH); + if (!tweaksFile.empty()) { + const char* cTweaksFile = tweaksFile.insert(0, ".\\").c_str(); + + game::Items::SetHealingPID(0, IniReader::GetInt("Items", "STIMPAK", fo::PID_STIMPAK, cTweaksFile)); + game::Items::SetHealingPID(1, IniReader::GetInt("Items", "SUPER_STIMPAK", fo::PID_SUPER_STIMPAK, cTweaksFile)); + game::Items::SetHealingPID(2, IniReader::GetInt("Items", "HEALING_POWDER", fo::PID_HEALING_POWDER, cTweaksFile)); + } +} + +void EngineTweaks::exit() { +} + +} diff --git a/sfall/Modules/EngineTweaks.h b/sfall/Modules/EngineTweaks.h new file mode 100644 index 00000000..15b9517b --- /dev/null +++ b/sfall/Modules/EngineTweaks.h @@ -0,0 +1,33 @@ +/* + * sfall + * Copyright (C) 2008-2021 The sfall team + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include "Module.h" + +namespace sfall +{ + +class EngineTweaks : public Module { +public: + const char* name() { return "EngineTweaks"; } + void init(); + void exit() override; +}; + +} diff --git a/sfall/Modules/Inventory.cpp b/sfall/Modules/Inventory.cpp index 526a0f09..68ed7cb6 100644 --- a/sfall/Modules/Inventory.cpp +++ b/sfall/Modules/Inventory.cpp @@ -24,6 +24,7 @@ #include "LoadGameHook.h" #include "..\Game\inventory.h" +#include "..\Game\items.h" #include "Inventory.h" @@ -310,8 +311,10 @@ static void __declspec(naked) gdControlUpdateInfo_hack() { //////////////////////////////////////////////////////////////////////////////// static std::string superStimMsg; +constexpr long SUPER_STIMPAK = 1; + static int __fastcall SuperStimFix(fo::GameObject* item, fo::GameObject* target) { - if (item->protoId != fo::PID_SUPER_STIMPAK || !target || target->IsNotCritter()) { + if (item->protoId != game::Items::GetHealingPID(SUPER_STIMPAK) || !target || target->IsNotCritter()) { return 0; } @@ -682,7 +685,7 @@ void Inventory::init() { SafeWrite32(0x472632, widthWeight); if (IniReader::GetConfigInt("Misc", "SuperStimExploitFix", 0)) { - superStimMsg = Translate::Get("sfall", "SuperStimExploitMsg", "You cannot use a super stim on someone who is not injured!"); + superStimMsg = Translate::Get("sfall", "SuperStimExploitMsg", "You cannot use this item on someone who is not injured!"); MakeCall(0x49C3D9, protinst_use_item_on_hack); } diff --git a/sfall/ddraw.vcxproj b/sfall/ddraw.vcxproj index 497fc3c1..a1b77d5c 100644 --- a/sfall/ddraw.vcxproj +++ b/sfall/ddraw.vcxproj @@ -302,6 +302,7 @@ + @@ -414,6 +415,7 @@ + diff --git a/sfall/ddraw.vcxproj.filters b/sfall/ddraw.vcxproj.filters index edb22c53..f731436f 100644 --- a/sfall/ddraw.vcxproj.filters +++ b/sfall/ddraw.vcxproj.filters @@ -346,6 +346,9 @@ Game + + Modules + @@ -642,6 +645,9 @@ Game + + Modules + diff --git a/sfall/main.cpp b/sfall/main.cpp index a9761adf..e9aa99bb 100644 --- a/sfall/main.cpp +++ b/sfall/main.cpp @@ -39,6 +39,7 @@ #include "Modules\DebugEditor.h" #include "Modules\Drugs.h" #include "Modules\Elevators.h" +#include "Modules\EngineTweaks.h" #include "Modules\Explosions.h" #include "Modules\ExtraSaveSlots.h" #include "Modules\FileSystem.h" @@ -125,6 +126,7 @@ static void InitModules() { manager.add(); manager.add(); + manager.add(); manager.add(); manager.add(); manager.add();