Fixed the mood argument of start_gdialog function being ignored for talking heads (from Crafty)

Fixed the broken obj_can_hear_obj script function (from Mr.Stalin)
Simplified the code of disabling losing unused perks.
This commit is contained in:
NovaRain
2018-09-30 16:31:29 +08:00
parent 8db528330b
commit 25bbd91fc5
3 changed files with 57 additions and 7 deletions
+7
View File
@@ -502,6 +502,13 @@ QuickPocketsApCostReduction=2
;Set to 1 to allow objects seeing through other objects with their ShootThru flag set
ObjCanSeeObj_ShootThru_Fix=0
;Set to 1 to fix the broken obj_can_hear_obj script function
ObjCanHearObjFix=0
;Set to 1 to fix the mood argument of start_gdialog script function to be available for talking heads
;If the argument value is -1, the mood will be determined by the local variable 0 of the script (vanilla behavior)
StartGDialogFix=0
;Set to 1 to enable the balanced bullet distribution formula for burst attacks
ComputeSprayMod=0
+46
View File
@@ -1275,6 +1275,14 @@ end:
}
}
static void __declspec(naked) op_obj_can_hear_obj_hack() {
__asm {
mov eax, [esp + 0x28 - 0x28 + 4]; // target
mov edx, [esp + 0x28 - 0x24 + 4]; // source
retn;
}
}
static void __declspec(naked) ai_best_weapon_hook() {
__asm {
mov eax, [esp + 0xF4 - 0x10 + 4]; // prev.item
@@ -1347,6 +1355,27 @@ fix:
}
}
static DWORD op_start_gdialog_ret = 0x456F4B;
static void __declspec(naked) op_start_gdialog_hack() {
__asm {
mov ebx, ds:[_dialog_target];
mov ebx, [ebx + 0x64];
shr ebx, 0x18;
cmp ebx, OBJ_TYPE_CRITTER;
jz fix;
cmp edx, -1;
jz skip;
retn;
fix:
cmp eax, -1;
jnz skip;
retn;
skip:
add esp, 4; // Destroy the return address
jmp op_start_gdialog_ret;
}
}
void BugsInit()
{
@@ -1689,6 +1718,16 @@ void BugsInit()
MakeCall(0x456B63, op_obj_can_see_obj_hack);
SafeWrite16(0x456B76, 0x23EB); // jmp loc_456B9B (skip unused engine code)
// Fix broken op_obj_can_hear_obj_ function
if (GetPrivateProfileIntA("Misc", "ObjCanHearObjFix", 0, ini)) {
dlog("Applying obj_can_hear_obj fix.", DL_INIT);
SafeWrite8(0x4583D8, 0x3B); // jz loc_458414
SafeWrite8(0x4583DE, 0x74); // jz loc_458414
MakeCall(0x4583E0, op_obj_can_hear_obj_hack);
SafeWrite8(0x4583E5, 0x90);
dlogr(" Done", DL_INIT);
}
// Fix for AI not checking weapon perks properly when searching for the best weapon
if (GetPrivateProfileIntA("Misc", "AIBestWeaponFix", 0, ini)) {
dlog("Applying AI best weapon choice fix.", DL_INIT);
@@ -1711,4 +1750,11 @@ void BugsInit()
HookCall(0x429D7B, ai_retrieve_object_hook);
MakeCall(0x472708, inven_find_id_hack);
dlogr(" Done", DL_INIT);
// Fix for the "mood" argument of start_gdialog function being ignored for talking heads
if (GetPrivateProfileIntA("Misc", "StartGDialogFix", 0, ini)) {
dlog("Applying start_gdialog argument fix.", DL_INIT);
MakeCall(0x456F03, op_start_gdialog_hack);
dlogr(" Done", DL_INIT);
}
}
+4 -7
View File
@@ -735,17 +735,14 @@ static void PerkSetup() {
}
//perk_owed hooks
MakeCall(0x4AFB2F, LevelUpHook);//replaces 'mov edx, ds:[PlayerLevel]
MakeCall(0x4AFB2F, LevelUpHook); //replaces 'mov edx, ds:[PlayerLevel]
SafeWrite8(0x4AFB34, 0x90);
SafeWrite8(0x43C2EC, 0xEB); //skip the block of code which checks if the player has gained a perk (now handled in level up code)
SafeWrite8(0x43C362, 0xE8); //call sub_43401C, dec byte ptr ds:[0x570A29]
SafeWrite32(0x43C363, 0x43410C - 0x43C367); //replaces call sub_43401C, mov byte ptr ds:[0x570A29], 0
SafeWrite8(0x43C367, 0x3E);
SafeWrite16(0x43C368, 0x0DFE);
SafeWrite32(0x43C36A, 0x00570A29);
SafeWrite8(0x43C36e, 0x90);
//Disable losing unused perks
SafeWrite16(0x43C369, 0x0DFE); // dec byte ptr ds:_free_perk
SafeWrite8(0x43C370, 0xB1); // jmp 0x43C322
}
static int _stdcall stat_get_base_direct(DWORD statID) {
DWORD result;