Added new EngineTweaks module and TweaksFile option

This commit is contained in:
NovaRain
2021-08-19 23:09:03 +08:00
parent 3129e27737
commit a186014895
8 changed files with 111 additions and 4 deletions
+13
View File
@@ -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
+7 -2
View File
@@ -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
+43
View File
@@ -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 <http://www.gnu.org/licenses/>.
*/
#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() {
}
}
+33
View File
@@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "Module.h"
namespace sfall
{
class EngineTweaks : public Module {
public:
const char* name() { return "EngineTweaks"; }
void init();
void exit() override;
};
}
+5 -2
View File
@@ -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);
}
+2
View File
@@ -302,6 +302,7 @@
<ClInclude Include="IniReader.h" />
<ClInclude Include="Modules\CritterPoison.h" />
<ClInclude Include="Modules\CritterStats.h" />
<ClInclude Include="Modules\EngineTweaks.h" />
<ClInclude Include="Modules\Interface.h" />
<ClInclude Include="Modules\Drugs.h" />
<ClInclude Include="Modules\HookScripts\CombatHs.h" />
@@ -414,6 +415,7 @@
<ClCompile Include="IniReader.cpp" />
<ClCompile Include="Modules\CritterPoison.cpp" />
<ClCompile Include="Modules\CritterStats.cpp" />
<ClCompile Include="Modules\EngineTweaks.cpp" />
<ClCompile Include="Modules\Interface.cpp" />
<ClCompile Include="Modules\Drugs.cpp" />
<ClCompile Include="Modules\HookScripts\CombatHs.cpp" />
+6
View File
@@ -346,6 +346,9 @@
<ClInclude Include="Game\combatAI.h">
<Filter>Game</Filter>
</ClInclude>
<ClInclude Include="Modules\EngineTweaks.h">
<Filter>Modules</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
@@ -642,6 +645,9 @@
<ClCompile Include="Game\combatAI.cpp">
<Filter>Game</Filter>
</ClCompile>
<ClCompile Include="Modules\EngineTweaks.cpp">
<Filter>Modules</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="version.rc" />
+2
View File
@@ -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<LoadGameHook>();
manager.add<MainLoopHook>();
manager.add<EngineTweaks>();
manager.add<Books>();
manager.add<Criticals>();
manager.add<Elevators>();