Improved the fix in previous commit.

* now ignoring the inv capacity only happens in combat for preventing
AI inf loop. The vanilla behavior still applies outside of combat.
* added a correct message for NPC not being able to pick up an item.
This commit is contained in:
NovaRain
2019-05-18 10:55:38 +08:00
parent 58d5271d49
commit 16a0ef3bdf
2 changed files with 33 additions and 4 deletions
+1
View File
@@ -10,6 +10,7 @@ SaveSfallDataFail=ERROR saving extended savegame information! Check if other pro
PartyLvlMsg=Lvl:
PartyACMsg=AC:
PartyAddictMsg=Addict
NPCPickupFail=%s cannot pick up the item.
[AppearanceMod]
RaceText=Race
+32 -4
View File
@@ -2088,14 +2088,41 @@ bad:
static void __declspec(naked) obj_pickup_hook() {
__asm {
cmp dword ptr ds:[FO_VAR_obj_dude], edi;
cmp edi, dword ptr ds:[FO_VAR_obj_dude];
je dude;
test byte ptr ds:[FO_VAR_combat_state], 1; // in combat?
jz dude;
jmp fo::funcoffs::item_add_force_;
dude:
jmp fo::funcoffs::item_add_mult_;
}
}
static char pickupMessageBuf[65] = {0};
static const char* __fastcall GetPickupMessage(const char* name) {
if (pickupMessageBuf[0] == 0) {
Translate("sfall", "NPCPickupFail", "%s cannot pick up the item.", pickupMessageBuf, 64);
}
sprintf(textBuf, pickupMessageBuf, name);
return textBuf;
}
static void __declspec(naked) obj_pickup_hook_message() {
__asm {
cmp edi, dword ptr ds:[FO_VAR_obj_dude];
je dude;
mov eax, edi;
call fo::funcoffs::critter_name_;
mov ecx, eax;
call GetPickupMessage;
mov [esp + 0x34 - 0x28 + 4], eax;
mov eax, 1;
retn;
dude:
jmp fo::funcoffs::message_search_;
}
}
void BugFixes::init()
{
#ifndef NDEBUG
@@ -2115,7 +2142,7 @@ void BugFixes::init()
SafeWrite16(0x46A566, 0x04DB);
SafeWrite16(0x46A4E7, 0x04DB);
//if(GetConfigInt("Misc", "SpecialUnarmedAttacksFix", 1)) {
//if (GetConfigInt("Misc", "SpecialUnarmedAttacksFix", 1)) {
dlog("Applying Special Unarmed Attacks fix.", DL_INIT);
MakeJump(0x42394D, UnarmedAttacksFix);
dlogr(" Done", DL_INIT);
@@ -2651,9 +2678,10 @@ void BugFixes::init()
// Fix the argument value of dialogue_reaction function
HookCall(0x456FFA, op_dialogue_reaction_hook);
// Fix for the incorrect message being displayed and NPC stuck in a loop in combat when the NPC cannot pick up an item
// due to not enough space in the inventory
// Fix for NPC stuck in a loop of picking up items in combat and the incorrect message being displayed when the NPC cannot pick
// up an item due to not enough space in the inventory
HookCall(0x49B6E7, obj_pickup_hook);
HookCall(0x49B71C, obj_pickup_hook_message);
}
}