Added a missing function to prevent the player starting the game with zero or negative SPECIAL values (from Crafty)

Added a log entry for the bag/backpack fix.
This commit is contained in:
NovaRain
2017-03-12 21:02:19 +08:00
parent dd00e130a9
commit d8e2e6f1ca
+74 -50
View File
@@ -321,6 +321,72 @@ skip:
}
}
static void __declspec(naked) is_supper_bonus_hack() {
__asm {
add eax, ecx
test eax, eax
jle skip
cmp eax, 10
jle end
skip:
pop eax // Destroy the return address
xor eax, eax
inc eax
pop edx
pop ecx
pop ebx
end:
retn
}
}
static void __declspec(naked) PrintBasicStat_hack() {
__asm {
test eax, eax
jle skip
cmp eax, 10
jg end
pop ebx // Destroy the return address
push 0x434C21
retn
skip:
xor eax, eax
end:
retn
}
}
static void __declspec(naked) StatButtonUp_hook() {
__asm {
call inc_stat_
test eax, eax
jl end
test ebx, ebx
jge end
sub ds:[_character_points], esi
dec esi
mov [esp+0xC+0x4], esi
end:
retn
}
}
static void __declspec(naked) StatButtonDown_hook() {
__asm {
call stat_level_
cmp eax, 1
jg end
pop eax // Destroy the return address
xor eax, eax
inc eax
mov [esp+0xC], eax
push 0x437B41
end:
retn
}
}
static void __declspec(naked) loot_container_hack() {
__asm {
mov eax, [esp+0x114+0x4]
@@ -597,7 +663,7 @@ static void __declspec(naked) set_new_results_hack() {
inc edx // type = knockout
jmp queue_remove_this_ // Remove knockout from queue (if there is one)
end:
pop eax // Destroying return address
pop eax // Destroy the return address
push 0x424FC6
retn
}
@@ -964,56 +1030,11 @@ void __declspec(naked) ItemCountFix() {
}
}
static void __declspec(naked) PrintBasicStat_hack() {
__asm {
test eax, eax
jle skip
cmp eax, 10
jg end
pop ebx
push 0x434C21
retn
skip:
xor eax, eax
end:
retn
}
}
static void __declspec(naked) StatButtonUp_hook() {
__asm {
call inc_stat_
test eax, eax
jl end
test ebx, ebx
jge end
sub ds:[_character_points], esi
xor esi, esi
mov [esp+0xC+0x4], esi
end:
retn
}
}
static void __declspec(naked) StatButtonDown_hook() {
__asm {
call stat_level_
cmp eax, 1
jg end
pop eax
xor eax, eax
inc eax
mov [esp+0xC], eax
push 0x437B41
end:
retn
}
}
void BugsInit()
{
//if (GetPrivateProfileIntA("Misc", "SharpshooterFix", 1, ini)) {
dlog("Applying sharpshooter patch.", DL_INIT);
dlog("Applying Sharpshooter patch.", DL_INIT);
// http://www.nma-fallout.com/threads/fo2-engine-tweaks-sfall.178390/page-119#post-4050162
// by Slider2k
HookCall(0x4244AB, &SharpShooterFix); // hooks stat_level_() call in detemine_to_hit_func_()
@@ -1090,8 +1111,9 @@ void BugsInit()
SafeWrite8(0x4AC377, 0x7F); // jg
dlogr(" Done", DL_INIT);
//Fix negative value SPECIAL when creation character, when Trait influences with negative values on basic parameters SPECIAL.
dlog("Applying fix for negative values SPECIAL when creation character.", DL_INIT);
// Fix for negative SPECIAL values in character creation
dlog("Applying fix for negative SPECIAL values in character creation.", DL_INIT);
MakeCall(0x43DF6F, &is_supper_bonus_hack, false);
MakeCall(0x434BFF, &PrintBasicStat_hack, false);
HookCall(0x437AB4, &StatButtonUp_hook);
HookCall(0x437B26, &StatButtonDown_hook);
@@ -1132,7 +1154,7 @@ void BugsInit()
//}
//if (GetPrivateProfileIntA("Misc", "BlackSkilldexFix", 1, ini)) {
dlog("Applying black skilldex patch.", DL_INIT);
dlog("Applying black Skilldex patch.", DL_INIT);
HookCall(0x497D0F, &PipStatus_AddHotLines_hook);
dlogr(" Done", DL_INIT);
//}
@@ -1261,6 +1283,7 @@ void BugsInit()
//}
//if (GetPrivateProfileIntA("Misc", "BagBackpackFix", 1, ini)) {
dlog("Applying fix for bag/backpack bugs.", DL_INIT);
// Fix for items disappearing from inventory when you try to drag them to bag/backpack in the inventory list
// and are overloaded
HookCall(0x4764FC, (void*)item_add_force_);
@@ -1275,6 +1298,7 @@ void BugsInit()
SafeWrite8(0x471C1C, 0x90); // nop
// Fix crash when trying to open bag/backpack on the table in the bartering interface
MakeCall(0x473191, &inven_action_cursor_hack, false);
dlogr(" Done", DL_INIT);
//}
// Fix crash when clicking on empty space in the inventory list opened by "Use Inventory Item On" (backpack) action icon