gothic-1-community-patch icon indicating copy to clipboard operation
gothic-1-community-patch copied to clipboard

NPCs continue to warn the player character to sheath his weapon

Open AmProsius opened this issue 3 years ago • 1 comments

Describe the bug Sometimes NPCs don't realize that the player character already sheathed his weapon and continue to warn him.

Expected behavior NPCs now correctly realize if the player character sheathed his weapon.

Additional context Bug provided by Blubbler.

AmProsius avatar Mar 31 '21 11:03 AmProsius

It would be nice to know the exact context when that happens, i.e. a reliable way to reproduce the issue. Without that, it will be impossible to test if the fix worked (similar to #13).

As for fixing the issue, I assume it would help to check again if the player is in any kind of fight mode in ZS_AssessFighter_Loop and in ZS_AssessFighterWait_Loop:

https://github.com/AmProsius/gothic-1-community-patch/blob/f386ca443496783307a91437f00772b92802a4dd/scriptbase/_work/Data/Scripts/Content/AI/ZS_Human/ZS_AssessFighter.d#L87-L96 changed to

func int ZS_AssessFighter_Loop ()
{
    if (Npc_IsInFightMode(other, FMODE_NONE)) || (Npc_IsInFightMode(other, FMODE_FIST)) {
        return LOOP_END;
    };

    PrintDebugNpc       (PD_ZS_LOOP,    "ZS_AssessFighter_Loop");

    //######## SC in Nahkampfdistanz ! ########
    if (Npc_GetDistToNpc(self,other) < HAI_DIST_ABORT_MELEE)
    {
        PrintDebugNpc       (PD_ZS_CHECK,   "...SC ist in Nahkampfdistanz!");

        //---- Passender Kommentar ! ----

and https://github.com/AmProsius/gothic-1-community-patch/blob/f386ca443496783307a91437f00772b92802a4dd/scriptbase/_work/Data/Scripts/Content/AI/ZS_Human/ZS_AssessFighter.d#L185-L196 changed to

func int ZS_AssessFighterWait_Loop  ()
{
    if (Npc_IsInFightMode(other, FMODE_NONE)) || (Npc_IsInFightMode(other, FMODE_FIST)) {
        return LOOP_END;
    };

    PrintDebugNpc           (PD_ZS_LOOP,    "ZS_AssessFighterWait_Loop" );

    //-------- Hat sich der SC mittlerweile entfernt ? --------
    if (Npc_GetDistToNpc(self,other) > HAI_DIST_ABORT_MELEE)
    {
        PrintDebugNpc       (PD_ZS_CHECK, "...SC ist außerhalb Nahkampfreichweite!");
        B_AssessRemoveWeapon();
    };

    //-------- Ist die Wartezeit abgelaufen ?  --------

Both of these changes are easily implemented by hooking before the respective functions and only continue into them given the added conditions.

szapp avatar May 14 '21 09:05 szapp