mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Added a function extension for vanilla metarule3 function
Added SET_HORRIGAN_ENCOUNTER function to metarule3. Updated German translation.
This commit is contained in:
@@ -262,8 +262,8 @@
|
|||||||
#define party_member_list_all party_member_list(1)
|
#define party_member_list_all party_member_list(1)
|
||||||
|
|
||||||
// fake perks/traits add mode flags
|
// fake perks/traits add mode flags
|
||||||
#define ADD_PERK_MODE_TRAIT (1) // add to the player's traits
|
#define ADD_PERK_MODE_TRAIT (1) // add to the player's traits list
|
||||||
#define ADD_PERK_MODE_PERK (2) // add to the player's perks
|
#define ADD_PERK_MODE_PERK (2) // add to the player's perks list
|
||||||
#define ADD_PERK_MODE_REMOVE (4) // remove from the list of selectable perks (after added to the player)
|
#define ADD_PERK_MODE_REMOVE (4) // remove from the list of selectable perks (after added to the player)
|
||||||
|
|
||||||
// instantly apply the item to dude_obj (w/o animation)
|
// instantly apply the item to dude_obj (w/o animation)
|
||||||
@@ -277,7 +277,15 @@
|
|||||||
if (get_flags(obj1) bwand FLAG_MULTIHEX) distance--; \
|
if (get_flags(obj1) bwand FLAG_MULTIHEX) distance--; \
|
||||||
if (get_flags(obj2) bwand FLAG_MULTIHEX) distance--
|
if (get_flags(obj2) bwand FLAG_MULTIHEX) distance--
|
||||||
|
|
||||||
// sfall_funcX macros
|
|
||||||
|
/* sfall metalure3 function macros */
|
||||||
|
#define SET_HORRIGAN_ENCOUNTER (200)
|
||||||
|
|
||||||
|
// sets the number of days (range 1...127) for the Frank Horrigan encounter, or disable the encounter if days is set to 0
|
||||||
|
#define set_horrigan_days(day) metarule3(SET_HORRIGAN_ENCOUNTER, day, 0, 0)
|
||||||
|
|
||||||
|
|
||||||
|
/* sfall_funcX macros */
|
||||||
#define add_extra_msg_file(name) sfall_func1("add_extra_msg_file", name)
|
#define add_extra_msg_file(name) sfall_func1("add_extra_msg_file", name)
|
||||||
#define add_global_timer_event(time, fixedParam) sfall_func2("add_g_timer_event", time, fixedParam)
|
#define add_global_timer_event(time, fixedParam) sfall_func2("add_g_timer_event", time, fixedParam)
|
||||||
#define add_iface_tag sfall_func0("add_iface_tag")
|
#define add_iface_tag sfall_func0("add_iface_tag")
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[sfall]
|
[sfall]
|
||||||
SaveInCombat=Momentan kein Speichern möglich.
|
SaveInCombat=Momentan kein Speichern möglich.
|
||||||
KarmaGain=Du gewinnst %d Karma.
|
KarmaGain=Du erhältst %d Karma.
|
||||||
KarmaLoss=Du verlierst %d Karma.
|
KarmaLoss=Du verlierst %d Karma.
|
||||||
HighlightFail1=Du trägst keinen Bewegungssensor.
|
HighlightFail1=Du trägst keinen Bewegungssensor.
|
||||||
HighlightFail2=Dein Bewegungssensor ist entladen.
|
HighlightFail2=Dein Bewegungssensor ist entladen.
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ std::multimap<long, long> writeAddress;
|
|||||||
|
|
||||||
static std::vector<long> excludeWarning = {
|
static std::vector<long> excludeWarning = {
|
||||||
0x44E949, 0x44E94A, 0x44E937, 0x4F5F40, 0x4CB850, // from movies.cpp
|
0x44E949, 0x44E94A, 0x44E937, 0x4F5F40, 0x4CB850, // from movies.cpp
|
||||||
|
0x4C06D8, // DisableHorrigan
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::vector<long> excludeConflict = {
|
static std::vector<long> excludeConflict = {
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
#define FO_VAR_curr_font_num 0x51E3B0
|
#define FO_VAR_curr_font_num 0x51E3B0
|
||||||
#define FO_VAR_curr_pc_stat 0x6681AC
|
#define FO_VAR_curr_pc_stat 0x6681AC
|
||||||
#define FO_VAR_curr_stack 0x59E96C
|
#define FO_VAR_curr_stack 0x59E96C
|
||||||
|
#define FO_VAR_currentProgram 0x59E78C
|
||||||
#define FO_VAR_currentWindow 0x51DCB8
|
#define FO_VAR_currentWindow 0x51DCB8
|
||||||
#define FO_VAR_cursor_line 0x664514
|
#define FO_VAR_cursor_line 0x664514
|
||||||
#define FO_VAR_debug_func 0x51DF04
|
#define FO_VAR_debug_func 0x51DF04
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ VAR_(crnt_func, DWORD)
|
|||||||
VAR_(curr_font_num, DWORD)
|
VAR_(curr_font_num, DWORD)
|
||||||
VARA(curr_pc_stat, long, PCSTAT_max_pc_stat)
|
VARA(curr_pc_stat, long, PCSTAT_max_pc_stat)
|
||||||
VAR_(curr_stack, DWORD)
|
VAR_(curr_stack, DWORD)
|
||||||
|
VAR_(currentProgram, Program*)
|
||||||
VAR_(cursor_line, DWORD)
|
VAR_(cursor_line, DWORD)
|
||||||
VAR_(DARK_GREY_Color, BYTE)
|
VAR_(DARK_GREY_Color, BYTE)
|
||||||
VAR_(DarkGreenColor, BYTE)
|
VAR_(DarkGreenColor, BYTE)
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* sfall
|
||||||
|
* Copyright (C) 2008-2020 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 "LoadGameHook.h"
|
||||||
|
|
||||||
|
#include "MetaruleExtender.h"
|
||||||
|
|
||||||
|
namespace sfall
|
||||||
|
{
|
||||||
|
|
||||||
|
#define HorriganEncounterDays (0x4C06EA)
|
||||||
|
#define HorriganEncounterCheck (0x4C06D8)
|
||||||
|
|
||||||
|
static signed char HorriganEncounterDefaultDays = 35;
|
||||||
|
static signed char HorriganEncounterSetDays = 35;
|
||||||
|
static bool HorriganEncounterDisabled = false;
|
||||||
|
|
||||||
|
enum class MetaruleFunction : long {
|
||||||
|
SET_HORRIGAN_ENCOUNTER = 200, // sets the number of days for the Frank Horrigan encounter or disable encounter
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
args - contains a pointer to an array (size of 3) of arguments for the metarule3 function [located on the stack]
|
||||||
|
*/
|
||||||
|
static long __fastcall op_metarule3_ext(long metafunc, long* args) {
|
||||||
|
long result = 0;
|
||||||
|
|
||||||
|
switch (static_cast<MetaruleFunction>(metafunc)) {
|
||||||
|
case MetaruleFunction::SET_HORRIGAN_ENCOUNTER: {
|
||||||
|
long argValue = args[0]; // arg1
|
||||||
|
if (argValue <= 0) { // disable Horrigan encounter
|
||||||
|
if (*(BYTE*)HorriganEncounterCheck == CodeType::JumpNZ) {
|
||||||
|
SafeWrite8(HorriganEncounterCheck, CodeType::JumpShort); // skip the Horrigan encounter check
|
||||||
|
HorriganEncounterDisabled = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (argValue > 127) argValue = 127;
|
||||||
|
SafeWrite8(HorriganEncounterDays, static_cast<BYTE>(argValue));
|
||||||
|
HorriganEncounterSetDays = static_cast<BYTE>(argValue);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
fo::func::debug_printf("\nOPCODE ERROR: metarule3(%d, ...) - metarule function number does not exist.\n > Script: %s, procedure %s.",
|
||||||
|
metafunc, fo::var::currentProgram->fileName, fo::func::findCurrentProc(fo::var::currentProgram));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __declspec(naked) op_metarule3_hack() {
|
||||||
|
static const DWORD op_metarule3_hack_Ret = 0x45732C;
|
||||||
|
__asm {
|
||||||
|
cmp ecx, 111;
|
||||||
|
jnz extended;
|
||||||
|
retn;
|
||||||
|
extended:
|
||||||
|
lea edx, [esp + 0x4C - 0x4C + 4]; // pointer to args
|
||||||
|
// swap arg1 <> arg3
|
||||||
|
mov eax, [edx]; // get: arg3
|
||||||
|
xchg eax, [edx + 2*4]; // get: arg1, set: arg3 > arg1
|
||||||
|
mov [edx], eax; // set: arg1 > arg3
|
||||||
|
//
|
||||||
|
call op_metarule3_ext; // ecx - metafunc arg
|
||||||
|
add esp, 4;
|
||||||
|
jmp op_metarule3_hack_Ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Reset() {
|
||||||
|
if (HorriganEncounterSetDays != HorriganEncounterDefaultDays) {
|
||||||
|
SafeWrite8(HorriganEncounterDays, HorriganEncounterDefaultDays);
|
||||||
|
}
|
||||||
|
if (HorriganEncounterDisabled) {
|
||||||
|
HorriganEncounterDisabled = false;
|
||||||
|
SafeWrite8(HorriganEncounterCheck, CodeType::JumpNZ); // enable
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MetaruleExtender::init() {
|
||||||
|
// Keep default value
|
||||||
|
HorriganEncounterDefaultDays = *(BYTE*)HorriganEncounterDays;
|
||||||
|
|
||||||
|
MakeCall(0x457322, op_metarule3_hack);
|
||||||
|
|
||||||
|
LoadGameHook::OnGameReset() += Reset;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* sfall
|
||||||
|
* Copyright (C) 2008-2020 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 MetaruleExtender : public Module {
|
||||||
|
public:
|
||||||
|
const char* name() { return "MetaruleExtender"; }
|
||||||
|
void init();
|
||||||
|
//void exit() override;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
@@ -304,6 +304,7 @@
|
|||||||
<ClInclude Include="Modules\Input.h" />
|
<ClInclude Include="Modules\Input.h" />
|
||||||
<ClInclude Include="ModuleManager.h" />
|
<ClInclude Include="ModuleManager.h" />
|
||||||
<ClInclude Include="Modules\MainLoopHook.h" />
|
<ClInclude Include="Modules\MainLoopHook.h" />
|
||||||
|
<ClInclude Include="Modules\MetaruleExtender.h" />
|
||||||
<ClInclude Include="Modules\Module.h" />
|
<ClInclude Include="Modules\Module.h" />
|
||||||
<ClInclude Include="Modules\AI.h" />
|
<ClInclude Include="Modules\AI.h" />
|
||||||
<ClInclude Include="Modules\DamageMod.h" />
|
<ClInclude Include="Modules\DamageMod.h" />
|
||||||
@@ -402,6 +403,7 @@
|
|||||||
<ClCompile Include="Modules\DamageMod.cpp" />
|
<ClCompile Include="Modules\DamageMod.cpp" />
|
||||||
<ClCompile Include="Modules\Animations.cpp" />
|
<ClCompile Include="Modules\Animations.cpp" />
|
||||||
<ClCompile Include="Modules\MainLoopHook.cpp" />
|
<ClCompile Include="Modules\MainLoopHook.cpp" />
|
||||||
|
<ClCompile Include="Modules\MetaruleExtender.cpp" />
|
||||||
<ClCompile Include="Modules\MiscPatches.cpp" />
|
<ClCompile Include="Modules\MiscPatches.cpp" />
|
||||||
<ClCompile Include="Modules\Karma.cpp" />
|
<ClCompile Include="Modules\Karma.cpp" />
|
||||||
<ClCompile Include="Modules\LoadOrder.cpp" />
|
<ClCompile Include="Modules\LoadOrder.cpp" />
|
||||||
|
|||||||
@@ -298,6 +298,9 @@
|
|||||||
<ClInclude Include="FalloutEngine\AsmMacros.h">
|
<ClInclude Include="FalloutEngine\AsmMacros.h">
|
||||||
<Filter>FalloutEngine</Filter>
|
<Filter>FalloutEngine</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Modules\MetaruleExtender.h">
|
||||||
|
<Filter>Modules</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
@@ -550,6 +553,9 @@
|
|||||||
<ClCompile Include="Modules\Scripting\Handlers\Math.cpp">
|
<ClCompile Include="Modules\Scripting\Handlers\Math.cpp">
|
||||||
<Filter>Modules\Scripting\Handlers</Filter>
|
<Filter>Modules\Scripting\Handlers</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Modules\MetaruleExtender.cpp">
|
||||||
|
<Filter>Modules</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="version.rc" />
|
<ResourceCompile Include="version.rc" />
|
||||||
|
|||||||
@@ -58,6 +58,7 @@
|
|||||||
#include "Modules\MainMenu.h"
|
#include "Modules\MainMenu.h"
|
||||||
#include "Modules\MainLoopHook.h"
|
#include "Modules\MainLoopHook.h"
|
||||||
#include "Modules\Message.h"
|
#include "Modules\Message.h"
|
||||||
|
#include "Modules\MetaruleExtender.h"
|
||||||
#include "Modules\MiscPatches.h"
|
#include "Modules\MiscPatches.h"
|
||||||
#include "Modules\Movies.h"
|
#include "Modules\Movies.h"
|
||||||
#include "Modules\Objects.h"
|
#include "Modules\Objects.h"
|
||||||
@@ -218,6 +219,7 @@ static void InitModules() {
|
|||||||
manager.add<ScriptShaders>();
|
manager.add<ScriptShaders>();
|
||||||
|
|
||||||
// all built-in events(delegates) of modules should be executed before running the script handlers
|
// all built-in events(delegates) of modules should be executed before running the script handlers
|
||||||
|
manager.add<MetaruleExtender>();
|
||||||
manager.add<HookScripts>();
|
manager.add<HookScripts>();
|
||||||
manager.add<ScriptExtender>();
|
manager.add<ScriptExtender>();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user