mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Corrected/improved code of some hooks.
Changed critical table to be loaded before global scripts. Updated version number and year.
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
;sfall configuration settings
|
||||
;v4.1.3
|
||||
;v4.1.4
|
||||
|
||||
[Main]
|
||||
;Change to 1 if you want to use command line args to tell sfall to use another ini file.
|
||||
|
||||
@@ -174,12 +174,12 @@ static void __declspec(naked) InvenActionCursorObjDropHook() {
|
||||
goto skipHook;
|
||||
} else {
|
||||
__asm {
|
||||
pushad;
|
||||
pushadc;
|
||||
xor ecx, ecx; // no itemReplace
|
||||
push 6; // event: item drop ground
|
||||
call InventoryMoveHook_Script; // edx - item
|
||||
mov dropResult, eax; // ret value
|
||||
popad;
|
||||
popadc;
|
||||
cmp dword ptr [esp], 0x47379A + 5; // caps call address
|
||||
jz capsMultiDrop;
|
||||
}
|
||||
@@ -204,12 +204,12 @@ capsMultiDrop:
|
||||
|
||||
static void __declspec(naked) InvenActionExplosiveDropHack() {
|
||||
__asm {
|
||||
pushad;
|
||||
pushadc;
|
||||
xor ecx, ecx; // no itemReplace
|
||||
push 6; // event: item drop ground
|
||||
call InventoryMoveHook_Script; // edx - item
|
||||
cmp eax, -1; // ret value
|
||||
popad;
|
||||
popadc;
|
||||
jnz noDrop;
|
||||
mov dword ptr ds:[FO_VAR_dropped_explosive], ebp; // overwritten engine code (ebp = 1)
|
||||
mov nextHookDropSkip, ebp;
|
||||
@@ -234,14 +234,14 @@ static const DWORD DropIntoContainer_back = 0x47649D; // normal operation
|
||||
static const DWORD DropIntoContainer_skip = 0x476503;
|
||||
static void __declspec(naked) DropIntoContainerHack() {
|
||||
__asm {
|
||||
pushad;
|
||||
pushadc;
|
||||
mov ecx, ebp; // contaner ptr
|
||||
mov edx, esi; // item
|
||||
mov eax, [esp + 0x10 + 32]; // call address
|
||||
push eax;
|
||||
call DropIntoContainer;
|
||||
cmp eax, -1; // ret value
|
||||
popad;
|
||||
popadc;
|
||||
jne skipdrop;
|
||||
jmp DropIntoContainer_back;
|
||||
skipdrop:
|
||||
@@ -262,13 +262,13 @@ static const DWORD DropAmmoIntoWeaponHack_back = 0x47658D; // proceed with reloa
|
||||
static const DWORD DropAmmoIntoWeaponHack_return = 0x476643;
|
||||
static void _declspec(naked) DropAmmoIntoWeaponHack() {
|
||||
__asm {
|
||||
pushad;
|
||||
pushadc;
|
||||
mov ecx, ebp; // weapon ptr
|
||||
mov edx, [esp + 32]; // item var: ammo_
|
||||
push 4; // event: weapon reloading
|
||||
call InventoryMoveHook_Script;
|
||||
cmp eax, -1; // ret value
|
||||
popad;
|
||||
popadc;
|
||||
jne donothing;
|
||||
mov ebx, 1; // overwritten code
|
||||
jmp DropAmmoIntoWeaponHack_back;
|
||||
|
||||
@@ -369,50 +369,48 @@ skip:
|
||||
}
|
||||
}
|
||||
|
||||
static int __fastcall ExplosiveTimerHook_Script(DWORD type, DWORD item, DWORD time) {
|
||||
static int __fastcall ExplosiveTimerHook_Script(DWORD* type, DWORD item, DWORD time) {
|
||||
BeginHook();
|
||||
argCount = 3;
|
||||
|
||||
args[0] = time;
|
||||
args[1] = item;
|
||||
args[2] = (type == 11) ? fo::ROLL_FAILURE : fo::ROLL_SUCCESS;
|
||||
args[2] = (*type == 11) ? fo::ROLL_FAILURE : fo::ROLL_SUCCESS;
|
||||
|
||||
RunHookScript(HOOK_EXPLOSIVETIMER);
|
||||
|
||||
int result = 0;
|
||||
if (cRet > 0 && rets[0] >= 0) {
|
||||
if (rets[0] > 18000) rets[0] = 18000; // max 30 minutes
|
||||
if (cRet < 2 || (rets[1] < fo::ROLL_CRITICAL_FAILURE || rets[1] > fo::ROLL_CRITICAL_SUCCESS)) {
|
||||
result--; // use vanilla type
|
||||
} else {
|
||||
result++; // use returned type
|
||||
time = -1;
|
||||
if (cRet > 0 && (long)rets[0] >= 0) {
|
||||
time = min(rets[0], 18000); // max 30 minutes
|
||||
if (cRet > 1) {
|
||||
int typeRet = rets[1];
|
||||
if (typeRet >= fo::ROLL_CRITICAL_FAILURE && typeRet <= fo::ROLL_CRITICAL_SUCCESS) {
|
||||
*type = (typeRet > fo::ROLL_FAILURE) ? 8 : 11; // returned new type (8 = SUCCESS, 11 = FAILURE)
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
EndHook();
|
||||
return time;
|
||||
}
|
||||
|
||||
static void _declspec(naked) ExplosiveTimerHook() {
|
||||
using namespace fo;
|
||||
__asm {
|
||||
push eax;
|
||||
push eax; // time in ticks for queue_add_
|
||||
push edx;
|
||||
push ecx;
|
||||
//-------
|
||||
push edi; // time in ticks
|
||||
push ecx;
|
||||
mov ecx, esp; // ptr to type
|
||||
push edi; // time in ticks (w/o failure penalty)
|
||||
call ExplosiveTimerHook_Script; // ecx - type, edx - item
|
||||
cmp eax, 0;
|
||||
pop ecx;
|
||||
pop edx;
|
||||
cmp eax, -1; // return new time in ticks
|
||||
jne skip;
|
||||
pop eax;
|
||||
jz end;
|
||||
mov eax, rets[0]; // time in ticks
|
||||
jl end;
|
||||
mov ecx, 8; // type SUCCESS
|
||||
cmp rets[4], ROLL_FAILURE;
|
||||
jg end;
|
||||
add ecx, 3; // type FAILURE (11)
|
||||
jmp end;
|
||||
skip:
|
||||
add esp, 4;
|
||||
end:
|
||||
HookEnd;
|
||||
jmp fo::funcoffs::queue_add_;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,11 +102,9 @@ static DWORD __fastcall UseAnimateObjHook_Script(DWORD critter, DWORD animCode,
|
||||
|
||||
RunHookScript(HOOK_USEANIMOBJ);
|
||||
|
||||
if (cRet > 0) {
|
||||
if (static_cast<long>(rets[0]) <= 64) {
|
||||
if (cRet > 0 && static_cast<long>(rets[0]) <= 64) {
|
||||
animCode = rets[0]; // new anim code
|
||||
}
|
||||
}
|
||||
EndHook();
|
||||
|
||||
return animCode;
|
||||
|
||||
@@ -916,6 +916,15 @@ void InterfaceDontMoveOnTopPatch() {
|
||||
}
|
||||
}
|
||||
|
||||
void UseWalkDistancePatch() {
|
||||
int distance = GetConfigInt("Misc", "UseWalkDistance", 3) + 2;
|
||||
if (distance > 1 && distance < 5) {
|
||||
dlog("Applying walk distance for using objects patch.", DL_INIT);
|
||||
SafeWriteBatch<BYTE>(distance, walkDistanceAddr); // default is 5
|
||||
dlogr(" Done", DL_INIT);
|
||||
}
|
||||
}
|
||||
|
||||
void BodypartHitChances() {
|
||||
using fo::var::hit_location_penalty;
|
||||
hit_location_penalty[0] = static_cast<long>(GetConfigInt("Misc", "BodyHit_Head", -40));
|
||||
@@ -929,15 +938,6 @@ void BodypartHitChances() {
|
||||
hit_location_penalty[8] = static_cast<long>(GetConfigInt("Misc", "BodyHit_Torso_Uncalled", 0));
|
||||
}
|
||||
|
||||
void UseWalkDistancePatch() {
|
||||
int distance = GetConfigInt("Misc", "UseWalkDistance", 3) + 2;
|
||||
if (distance > 1 && distance < 5) {
|
||||
dlog("Applying walk distance for using objects patch.", DL_INIT);
|
||||
SafeWriteBatch<BYTE>(distance, walkDistanceAddr); // default is 5
|
||||
dlogr(" Done", DL_INIT);
|
||||
}
|
||||
}
|
||||
|
||||
void MiscPatches::init() {
|
||||
mapName[64] = 0;
|
||||
if (GetConfigString("Misc", "StartingMap", "", mapName, 64)) {
|
||||
|
||||
+1
-1
@@ -140,6 +140,7 @@ static void InitModules() {
|
||||
manager.add<PlayerModel>();
|
||||
manager.add<Worldmap>();
|
||||
manager.add<Stats>();
|
||||
manager.add<Criticals>();
|
||||
manager.add<ScriptExtender>();
|
||||
manager.add<HookScripts>();
|
||||
manager.add<LoadGameHook>();
|
||||
@@ -148,7 +149,6 @@ static void InitModules() {
|
||||
manager.add<Combat>();
|
||||
manager.add<Skills>();
|
||||
manager.add<FileSystem>();
|
||||
manager.add<Criticals>();
|
||||
manager.add<LoadOrder>();
|
||||
manager.add<Karma>();
|
||||
manager.add<Tiles>();
|
||||
|
||||
+3
-3
@@ -20,14 +20,14 @@
|
||||
|
||||
#define TARGETVERSION "Fallout 2 v1.02 US"
|
||||
|
||||
#define LEGAL_COPYRIGHT "Copyright (C) 2006-2018, sfall team"
|
||||
#define LEGAL_COPYRIGHT "Copyright (C) 2006-2019, sfall team"
|
||||
|
||||
#define VERSION_MAJOR 4
|
||||
#define VERSION_MINOR 1
|
||||
#define VERSION_BUILD 3
|
||||
#define VERSION_BUILD 4
|
||||
#define VERSION_REV 0
|
||||
|
||||
#define VERSION_STRING "4.1.3"
|
||||
#define VERSION_STRING "4.1.4"
|
||||
|
||||
#define CHECK_VAL (4)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user