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

Simplified the code of disabling losing unused perks.
This commit is contained in:
NovaRain
2018-09-30 16:24:15 +08:00
parent 7f8481d03a
commit f088c9bb70
3 changed files with 36 additions and 7 deletions
+4
View File
@@ -506,6 +506,10 @@ 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
+28
View File
@@ -1498,6 +1498,27 @@ fix:
}
}
static DWORD op_start_gdialog_ret = 0x456F4B;
static void __declspec(naked) op_start_gdialog_hack() {
__asm {
mov ebx, ds:[FO_VAR_dialog_target];
mov ebx, [ebx + protoId];
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 BugFixes::init()
{
@@ -1904,6 +1925,13 @@ void BugFixes::init()
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 (GetConfigInt("Misc", "StartGDialogFix", 0)) {
dlog("Applying start_gdialog argument fix.", DL_INIT);
MakeCall(0x456F03, op_start_gdialog_hack);
dlogr(" Done", DL_INIT);
}
}
}
+4 -7
View File
@@ -728,17 +728,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) {