AmProsius / gothic-1-community-patch

Gothic 1 Community Patch
Other
50 stars 4 forks source link

Heal offer dialog of Damarok inaccessible #321

Open szapp opened 2 years ago

szapp commented 2 years ago

Describe the bug The dialog of Damarok (KDF_401_Damarok) in which he offers the player healing can never the accessed. It is a simple dialog in which Damarok approaches the player. The dialog line in question is "If you are injured, I shall heal you".

Expected behavior Damarok's dialog about offering healing now correctly triggers when the player joins the fire mages.

Steps to reproduce the issue

  1. Join the fire mages
  2. Go near Damarok
  3. He does not speak to the player as would be expected

Additional context The reason for the dialog not playing is a misuse of the external engine function Npc_IsInRoutine. It is used with a daily routine schedule function, when it should be used with an AI-state function instead.

The intention might have been to not trigger the dialog right after the admission ritual (as it is an "important" dialog and would interrupt). Checking the nearest waypoint instead may not be so robust, because of similarity to his position during the ritual. An alternative might be to stick to the function Npc_IsInRoutine and to check for the AI-state ZS_PotionAlchemy. However, that would require to confirm that his original daily routine schedule is untouched.

Relevant portion of the scripts

Dialog condition that always renders false https://github.com/AmProsius/gothic-1-community-patch/blob/66e2fc2c1b10525ec27416debc509e5ceb409ff0/scriptbase/_work/Data/Scripts/Content/Story/Missions/DIA_KDF_401_Damarok.d#L62-L69

Daily routine schedule function https://github.com/AmProsius/gothic-1-community-patch/blob/66e2fc2c1b10525ec27416debc509e5ceb409ff0/scriptbase/_work/Data/Scripts/Content/Story/NPC/KDF_401_Damarok.d#L53-L57

szapp commented 2 years ago

With the recently added function G1CP_NpcIsInRoutine, the issue can be fixed like so

https://github.com/AmProsius/gothic-1-community-patch/blob/66e2fc2c1b10525ec27416debc509e5ceb409ff0/scriptbase/_work/Data/Scripts/Content/Story/Missions/DIA_KDF_401_Damarok.d#L62-L69 changed to

 FUNC int  KDF_401_Damarok_HEAL_Condition() 
 { 
     if (Npc_GetTrueGuild (hero) == GIL_KDF) 
     && (G1CP_NpcIsInRoutine(self, Rtn_START_401)) 
     { 
         return TRUE; 
     }; 
 }; 

It can be implemented using the function G1CP_ReplaceCall. Nevertheless, the context of the function call should be verified, i.e. confirm in the bytecode that the second argument is indeed Rtn_START_401.