Added an optional bug fix for not counting in the weight of equipped items on NPC when stealing or bartering.

Added an additional fix to InventoryDragIssuesFix for only using one box of ammo when the weapon is before the ammo.
Partially refactored Credits.cpp and QuestList.cpp to use proper engine function/variable names.
This commit is contained in:
NovaRain
2015-11-16 15:07:24 +08:00
parent 879315b4d0
commit 225f36808d
4 changed files with 297 additions and 310 deletions
+3
View File
@@ -567,6 +567,9 @@ NPCTurnsIntoContainerFix=1
;Set to 1 to fix issues with being able to charge the car with using cells on scenary/critters and cells getting consumed even when the car is already fully charged
CarChargingFix=1
;Set to 1 to fix issues with the weight of equipped items on NPC not being counted in when stealing or bartering
NPCWeightFix=1
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[Debugging]
+35 -34
View File
@@ -4,7 +4,7 @@
#include "Define.h"
#include "FalloutEngine.h"
//DWORD WeightOnBody = 0;
DWORD WeightOnBody = 0;
static void __declspec(naked) SharpShooterFix() {
__asm {
@@ -22,7 +22,6 @@ end:
}
}
static void __declspec(naked) pipboy_hack() {
__asm {
cmp ebx, 0x210 // Back button?
@@ -181,7 +180,8 @@ itsJet:
mov eax, 0x47A3FB
jmp eax
}
}*/
}
*/
static void __declspec(naked) item_d_load_hack() {
__asm {
@@ -293,7 +293,7 @@ end:
static void __declspec(naked) gdProcessUpdate_hack() {
__asm {
add eax, esi
cmp eax, dword ptr ds:[0x58ECCC] // _optionRect.offy
cmp eax, dword ptr ds:[_optionRect + 0xC] // _optionRect.offy
jge skip
add eax, 2
mov esi, 0x44702D
@@ -304,8 +304,6 @@ skip:
}
}
static void __declspec(naked) invenWieldFunc_item_get_type_hook() {
__asm {
pushad
@@ -341,9 +339,7 @@ noWeapon:
}
}
/*
static void __declspec(naked) loot_container_hook() {
static void __declspec(naked) loot_container_hack() {
__asm {
mov eax, [esp+0x114+0x4]
test eax, eax
@@ -369,10 +365,8 @@ noArmor:
retn
}
}
*/
/*
static void __declspec(naked) barter_inventory_hook() {
static void __declspec(naked) barter_inventory_hack() {
__asm {
mov eax, [esp+0x20+0x4]
test eax, eax
@@ -396,9 +390,6 @@ end:
retn
}
}
*/
/*
static void __declspec(naked) barter_attempt_transaction_hook() {
__asm {
@@ -428,7 +419,6 @@ end:
retn
}
}
*/
static void __declspec(naked) inven_pickup_hack() {
__asm {
@@ -442,9 +432,8 @@ static void __declspec(naked) inven_pickup_hack() {
}
}
static DWORD inven_pickup_loop=-1;
static const DWORD inven_pickup_hook1_Loop = 0x471145;
static const DWORD inven_pickup_hack2_Loop = 0x471145;
static void __declspec(naked) inven_pickup_hack2() {
__asm {
cmp inven_pickup_loop, -1
@@ -462,7 +451,7 @@ nextLoop:
add edx, 35 // y_start
mov ecx, edx
add ecx, 48 // y_end
jmp inven_pickup_hook1_Loop
jmp inven_pickup_hack2_Loop
inLoop:
test eax, eax
mov eax, inven_pickup_loop
@@ -496,7 +485,6 @@ inRange:
}
}
/*
static void __declspec(naked) drop_ammo_into_weapon_hook() {
__asm {
dec esi
@@ -536,7 +524,6 @@ end:
retn
}
}
*/
static void __declspec(naked) PipStatus_AddHotLines_hook() {
__asm {
@@ -583,7 +570,7 @@ static void __declspec(naked) action_melee_hack() {
cmp ebx, OBJ_TYPE_CRITTER // check if object FID type flag is set to critter
jne end // if object not a critter leave jump condition flags
// set to skip dodge animation
test byte ptr [eax+0x44], 3 // (original code) DAM_KNOCKED_OUT or DAM_KNOCKED_DOWN
test byte ptr [eax+0x44], 0x3 // (original code) DAM_KNOCKED_OUT or DAM_KNOCKED_DOWN
jnz end
mov edx, 0x4113FE
end:
@@ -600,7 +587,7 @@ static void __declspec(naked) action_ranged_hack() {
cmp ebx, OBJ_TYPE_CRITTER // check if object FID type flag is set to critter
jne end // if object not a critter leave jump condition flags
// set to skip dodge animation
test byte ptr [eax+0x44], 3 // (original code) DAM_KNOCKED_OUT or DAM_KNOCKED_DOWN
test byte ptr [eax+0x44], 0x3 // (original code) DAM_KNOCKED_OUT or DAM_KNOCKED_DOWN
jnz end
mov edx, 0x411BD2
end:
@@ -608,7 +595,6 @@ end:
}
}
static void __declspec(naked) set_new_results_hack() {
__asm {
test ah, 0x1 // DAM_KNOCKED_OUT?
@@ -695,9 +681,9 @@ found:
}
}
static void __declspec(naked) item_m_turn_off_hack() {
static void __declspec(naked) item_m_turn_off_hook() {
__asm {
and byte ptr [eax+0x25], 0xDF // Unset flag of activated items
and byte ptr [eax+0x25], 0xDF // Rest flag of used items
jmp queue_remove_this_
}
}
@@ -705,6 +691,7 @@ static void __declspec(naked) item_m_turn_off_hack() {
void BugsInit()
{
//if (GetPrivateProfileIntA("Misc", "SharpshooterFix", 1, ini)) {
dlog("Applying sharpshooter patch.", DL_INIT);
// http://www.nma-fallout.com/showthread.php?178390-FO2-Engine-Tweaks&p=4050162&viewfull=1#post4050162
// by Slider2k
@@ -714,6 +701,7 @@ void BugsInit()
// dist -= 2 * perk_level_(obj_dude, PERK_sharpshooter);
SafeWrite8(0x424527, 0xEB); // in detemine_to_hit_func_()
dlogr(" Done", DL_INIT);
//}
// Fixes for clickability issue in Pip-Boy and exploit that allows to rest in places where you shouldn't be able to rest
dlog("Applying fix for Pip-Boy rest exploit.", DL_INIT);
@@ -783,12 +771,16 @@ void BugsInit()
SafeWrite8(0x4AC377, 0x7F); // jg
dlogr(" Done.", DL_INIT);
// Fix for not counting in weight of equipped items
/*MakeCall(0x473B4E, &loot_container_hook, false);
MakeCall(0x47588A, &barter_inventory_hook, false);
// Fix for not counting in the weight of equipped items on NPC when stealing or bartering
if (GetPrivateProfileIntA("Misc", "NPCWeightFix", 1, ini)) {
dlog("Applying fix for not counting in weight of equipped items on NPC.", DL_INIT);
MakeCall(0x473B4E, &loot_container_hack, false);
MakeCall(0x47588A, &barter_inventory_hack, false);
HookCall(0x474CB8, &barter_attempt_transaction_hook);
HookCall(0x4742AD, &move_inventory_hook);
HookCall(0x4771B5, &item_add_mult_hook);*/
HookCall(0x4771B5, &item_add_mult_hook);
dlogr(" Done.", DL_INIT);
}
// Corrects "Weight of items" text element width to be 64 (and not 80), which matches container element width
SafeWrite8(0x475541, 64);
@@ -802,24 +794,29 @@ void BugsInit()
// Fix for error in player's inventory, related to IFACE_BAR_MODE=1 in f2_res.ini, and
// also for reverse order error
MakeCall(0x47114A, &inven_pickup_hack2, true);
// Fix for using only one box of ammo when the weapon is before the ammo
HookCall(0x476598, &drop_ammo_into_weapon_hook);
dlogr(" Done", DL_INIT);
}
// Fix for using only one pack of ammo, when the weapon is before the ammo
//HookCall(0x476598, &drop_ammo_into_weapon_hook);
//if (GetPrivateProfileIntA("Misc", "BlackSkilldexFix", 1, ini)) {
dlog("Applying black skilldex patch.", DL_INIT);
HookCall(0x497D0F, &PipStatus_AddHotLines_hook);
dlogr(" Done", DL_INIT);
//}
//if (GetPrivateProfileIntA("Misc", "FixWithdrawalPerkDescCrash", 1, ini)) {
dlog("Applying withdrawal perk description crash fix.", DL_INIT);
HookCall(0x47A501, &perform_withdrawal_start_display_print_hook);
dlogr(" Done", DL_INIT);
//}
//if (GetPrivateProfileIntA("Misc", "JetAntidoteFix", 1, ini)) {
dlog("Applying Jet Antidote fix.", DL_INIT);
// the original jet antidote fix
MakeCall(0x47A013, &item_d_take_drug_hack1, true);
dlogr(" Done", DL_INIT);
//}
if (GetPrivateProfileIntA("Misc", "NPCDrugAddictionFix", 1, ini)) {
dlog("Applying NPC's drug addiction fix.", DL_INIT);
@@ -829,9 +826,11 @@ void BugsInit()
dlogr(" Done.", DL_INIT);
}
//if (GetPrivateProfileInt("Misc", "ShivPatch", 1, ini)) {
dlog("Applying shiv patch.", DL_INIT);
SafeWrite8(0x477B2B, 0xEB);
dlogr(" Done", DL_INIT);
//}
//if (GetPrivateProfileIntA("Misc", "WieldObjCritterFix", 1, ini)) {
dlog("Applying wield_obj_critter fix.", DL_INIT);
@@ -840,10 +839,12 @@ void BugsInit()
dlogr(" Done", DL_INIT);
//}
//if (GetPrivateProfileIntA("Misc", "DodgyDoorsFix", 1, ini)) {
dlog("Applying Dodgy Door Fix.", DL_INIT);
MakeCall(0x4113D6, &action_melee_hack, true);
MakeCall(0x411BCC, &action_ranged_hack, true);
dlogr(" Done", DL_INIT);
//}
// Fix for "NPC turns into a container" bug
if (GetPrivateProfileIntA("Misc", "NPCTurnsIntoContainerFix", 1, ini)) {
@@ -861,7 +862,7 @@ void BugsInit()
SafeWrite8(0x478115, 0xBA);
SafeWrite8(0x478138, 0xBA);
MakeCall(0x474D22, &barter_attempt_transaction_hack, true);
HookCall(0x4798B1, &item_m_turn_off_hack);
HookCall(0x4798B1, &item_m_turn_off_hook);
dlogr(" Done", DL_INIT);
}
}
+10 -12
View File
@@ -18,8 +18,9 @@
#include "main.h"
#include "Version.h"
#include <stdio.h>
#include "FalloutEngine.h"
#include "version.h"
static DWORD InCredits=0;
static DWORD CreditsLine=0;
@@ -77,8 +78,7 @@ static void _stdcall ShowCreditsHook() {
CreditsLine=0;
__asm {
mov eax, creditsFile;
mov ebx, 0x42C860;
call ebx;
call credits_;
}
InCredits=0;
}
@@ -89,22 +89,21 @@ static DWORD _stdcall CreditsNextLine(char* buf, DWORD* font, DWORD* colour) {
if(strlen(line)) {
if(line[0]=='#') {
line++;
*font=*(DWORD*)0x56D74C;
*font=*(DWORD*)_name_font;
*colour=*(BYTE*)0x6A7F01;
} else if(line[0]=='@') {
line++;
*font=*(DWORD*)0x56D748;
*colour=*(DWORD*)0x56D750;
*font=*(DWORD*)_title_font;
*colour=*(DWORD*)_title_color;
} else {
*font=*(DWORD*)0x56D74C;
*colour=*(DWORD*)0x56D744;
*font=*(DWORD*)_name_font;
*colour=*(DWORD*)_name_color;
}
}
strcpy_s(buf, 256, line);
return 1;
}
static const DWORD _credits_get_next_line=0x42CE6C;
static void __declspec(naked) CreditsNextLineHook() {
__asm {
pushad;
@@ -113,14 +112,13 @@ static void __declspec(naked) CreditsNextLineHook() {
push eax;
call CreditsNextLine;
test eax, eax;
jz fail;
popad;
jz fail;
xor eax, eax;
inc eax;
retn;
fail:
popad;
jmp _credits_get_next_line;
jmp credits_get_next_line_;
}
}
+51 -66
View File
@@ -18,6 +18,8 @@
#include "main.h"
#include "FalloutEngine.h"
static DWORD calledflag = 0x0;
static DWORD called_quest_number = 0x0;
static DWORD total_quests = 0x0;
@@ -32,7 +34,7 @@ static void __declspec(naked) newhookpress() {
mov wait_flag, 0;
mov total_quests, 0;
pop eax;
mov edx,ds:[0x664508];
mov edx,ds:[_crnt_func];
retn;
}
}
@@ -56,7 +58,7 @@ static void __declspec(naked) newhookpress1() {
mov calledflag, 0;
mov curent_quest_page, 0;
pop eax;
sub ebx,0x1f4;
sub ebx, 0x1F4;
retn;
}
}
@@ -71,7 +73,6 @@ static void __declspec(naked) nexthookfunct() {
}
}
static const DWORD show_text_function=0x4bc6f0;
static const DWORD show_text_jump_addr = 0x498193;
static void __declspec(naked) newhooklooktext() {
@@ -85,7 +86,7 @@ jl smpfhj;
cmp wait_flag, eax;
jg smpfhj;
pop eax;
call show_text_function;
call _word_wrap_;
inc wait_flag;
add total_quests, 1;
retn;
@@ -97,22 +98,20 @@ smpfhj:
retn;
}
}
static const DWORD forresetvalue=0x497b64;
static void __declspec(naked) newhookresetvalue() {
__asm {
push eax;
mov wait_flag, 0;
pop eax;
call forresetvalue;
call pip_back_;
retn;
}
}
static const DWORD call_newbutt1=0x49720c;
static const DWORD call_newbutt2=0x497BD8;
static const DWORD call_newbutt3=0x4999c0;
static const DWORD call_newbutt4=0x4d36d4;
//static const DWORD call_newbutt1 = 0x49720C; // Unused
//static const DWORD call_newbutt2 = 0x497BD8; // Unused - PipStatus_
//static const DWORD call_newbutt3 = 0x4999C0; // Unused - NixHotLines_
//static const DWORD call_newbutt4 = 0x4D36D4; // Unused - buf_to_buf_
static void __declspec(naked) newactbpip() {
__asm {
@@ -124,27 +123,22 @@ jmphr4:
je jmphr5;
jmp jmphr3;
jmphr5:
cmp curent_quest_page, 0x0;
je jmphr1;
push eax;
sub curent_quest_page, 1;
mov wait_flag, 0;
pop eax;
mov ebx, called_quest_number;
jmphr3:
cmp ebx, 0x301;
je jmphr;
jmp jmphr1;
jmphr:
cmp calledflag, 0x1;
je jmphr2;
jmp jmphr1;
jmphr2:
push eax;
mov eax, curent_quest_page;
add eax, 1;
@@ -159,29 +153,24 @@ rtjl:
pop eax;
mov ebx, called_quest_number;
jmphr1:
cmp ebx,0x1f4;
cmp ebx, 0x1F4;
retn;
}
}
static const DWORD n_newbutt1=0x4d8260;
static const DWORD n_newbutt2=0x4d87f8;
static const DWORD n_newbutt2 = 0x4D87F8;
static const DWORD newbutt1=0x4d87f8;
static const DWORD newbutt2=0x419c88;
static const DWORD newbutt3=0x419188;
static const DWORD newbutt4=0x45e440;
static const DWORD newbutt5=0x419c88;
static const DWORD newbutt6=0x419188;
static const DWORD newbutt7=0x4d8260;
static const DWORD newbutt8=0x45e440;
static const DWORD newbutt9=0x45e440;
static const DWORD newbutt1 = 0x4D87F8;
//static const DWORD newbutt4 = 0x45E440; // Unused
//static const DWORD newbutt7 = 0x4D8260; // Unused - win_register_button_
//static const DWORD newbutt8 = 0x45E440; // Unused
//static const DWORD newbutt9 = 0x45E440; // Unused
static void __declspec(naked) newbuttonfct() {
__asm {
// recreate original 4 buttons
mov edi, 0x155;
mov ebp,0x1f4;
mov ebp, 0x1F4;
xor esi, esi;
smpj1:
cmp esi, +0x1;
@@ -195,14 +184,14 @@ smpj1:
push ebp;
push -0x1;
push -0x1;
mov ebx,ds:[0x6642e4];
mov ebx, ds:[0x6642E4];
push -0x1;
mov ecx,ds:[0x6642e0];
mov eax,ds:[0x6644c4];
mov ecx, ds:[0x6642E0];
mov eax, ds:[_pip_win];
push ebx;
mov edx, 0x35;
mov ebx, edi;
call n_newbutt1;
call win_register_button_;
cmp eax, -0x1;
jz smpj3;
mov ebx, 0x451978;
@@ -228,27 +217,26 @@ smpj4:
mov edx, 0xB5; // number from intrface.lst for button-up
mov eax, 0x6;
xor ebx, ebx;
call newbutt2;
mov ecx,0x518f28;
call art_id_;
mov ecx, 0x518F28;
xor ebx, ebx;
xor edx, edx;
call newbutt3;
mov ds:[0x59d3fc],eax; // first texture memory address
call art_ptr_lock_data_;
mov ds:[0x59D3FC], eax; // first texture memory address
push +0x0;
mov edx, 0xB6; // number from intrface.lst for button-down
mov eax, 0x6;
xor ecx, ecx;
xor ebx, ebx;
call newbutt5;
mov ecx,0x518f2c;
call art_id_;
mov ecx, 0x518F2C;
xor ebx, ebx;
xor edx, edx;
call newbutt6;
mov ds:[0x59d400],eax; // second texture memory address
call art_ptr_lock_data_;
mov ds:[0x59D400], eax; // second texture memory address
// load new texture for second (down) button
mov ebx, 0x451990;
mov edx, 0x451988;
call newbutt1;
@@ -257,31 +245,29 @@ smpj4:
mov edx, 0xC7; // number from intrface.lst for button-up
mov eax, 0x6;
xor ebx, ebx;
call newbutt2;
mov ecx,0x518f28;
call art_id_;
mov ecx, 0x518F28;
xor ebx, ebx;
xor edx, edx;
call newbutt3;
call art_ptr_lock_data_;
mov ds:[0x570514], eax; // first texture memory address
push +0x0;
mov edx, 0xC8; // number from intrface.lst for button-down
mov eax, 0x6;
xor ecx, ecx;
xor ebx, ebx;
call newbutt5;
mov ecx,0x518f2c;
call art_id_;
mov ecx, 0x518F2C;
xor ebx, ebx;
xor edx, edx;
call newbutt6;
call art_ptr_lock_data_;
mov ds:[0x570518], eax; // second texture memory address
// creating new 2 buttons
mov edi, 0x149; // y position
mov ebp, 0x300; // this number will return when button pressed
xor esi, esi;
push +0x20;
push +0x0;
mov eax, ds:[0x570518];
@@ -294,11 +280,11 @@ smpj4:
mov ebx, 0xE;
push -0x1;
mov ecx, 0xB;
mov eax,ds:[0x6644c4];
mov eax, ds:[_pip_win];
push ebx;
mov edx, 0x8B;
mov ebx, edi;
call n_newbutt1;
call win_register_button_;
cmp eax, -0x1;
jz smpj16;
mov ebx, 0x451978;
@@ -309,12 +295,11 @@ smpj16:
inc ebp;
inc esi;
add edi, +0x9;
push +0x20;
push +0x0;
mov eax,ds:[0x59d400];
mov eax, ds:[0x59D400];
push eax;
mov edx,ds:[0x59d3fc];
mov edx, ds:[0x59D3FC];
push edx;
push ebp;
push -0x1;
@@ -322,11 +307,11 @@ smpj16:
mov ebx, 0xE;
push -0x1;
mov ecx, 0xB;
mov eax,ds:[0x6644c4];
mov eax, ds:[_pip_win];
push ebx;
mov edx, 0x8B;
mov ebx, edi;
call n_newbutt1;
call win_register_button_;
cmp eax, -0x1;
jz smpj6;
mov ebx, 0x451978;
@@ -344,18 +329,18 @@ smpj6:
void QuestListInit() {
//<comments removed because they couldn't display correctly in this encoding>
SafeWrite8(0x004974df, 0xE8);
SafeWrite32(0x004974e0, ((DWORD)&newbuttonfct) - 0x004974e4);
SafeWrite8(0x004974e4, 0xE9);
SafeWrite8(0x004974DF, 0xE8);
SafeWrite32(0x004974E0, ((DWORD)&newbuttonfct) - 0x004974E4);
SafeWrite8(0x004974E4, 0xE9);
SafeWrite32(0x004974e5, 0x0000005B);
//
SafeWrite8(0x00497173, 0xE8);
SafeWrite32(0x00497174, ((DWORD)&newactbpip) - 0x00497178);
SafeWrite8(0x00497178, 0x90);
//
SafeWrite8(0x004971b2, 0xE8);
SafeWrite32(0x004971b3, ((DWORD)&newhookpress) - 0x004971b7);
SafeWrite8(0x004971b7, 0x90);
SafeWrite8(0x004971B2, 0xE8);
SafeWrite32(0x004971B3, ((DWORD)&newhookpress) - 0x004971B7);
SafeWrite8(0x004971B7, 0x90);
//
SafeWrite8(0x00497183, 0xE8);
SafeWrite32(0x00497184, ((DWORD)&newhookpress1) - 0x00497188);
@@ -367,9 +352,9 @@ void QuestListInit() {
SafeWrite8(0x004982B0, 0xE8);
SafeWrite32(0x004982B1, ((DWORD)&newhookresetvalue) - 0x004982B5);
//
SafeWrite8(0x004971d9, 0xE8);
SafeWrite32(0x004971da, ((DWORD)&nexthookfunct) - 0x004971de);
SafeWrite8(0x004971D9, 0xE8);
SafeWrite32(0x004971DA, ((DWORD)&nexthookfunct) - 0x004971DE);
//
SafeWrite8(0x00497219, 0xE8);
SafeWrite32(0x0049721a, ((DWORD)&backhookfunct) - 0x0049721e);
SafeWrite32(0x0049721A, ((DWORD)&backhookfunct) - 0x0049721E);
}