Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gorn can't be asked about after talking to Lares #228

Merged
merged 2 commits into from May 9, 2021
Merged

Conversation

AmProsius
Copy link
Owner

@AmProsius AmProsius commented May 9, 2021

Describe the bug
Because of an incorrect assignment, Gorn can't be asked about in ambient dialogs after Lares talks of his existence.

Expected behavior
Gorn can now correctly be asked about in ambient dialogs after the player talked to Lares.

Additional context
Bug and fix provided by N1kX94.

@AmProsius AmProsius added the validation: required This issue needs validation from one of the validators. label Apr 4, 2021
@AmProsius
Copy link
Owner Author

FUNC VOID ORG_801_Lares_BringListAnteil_Info()
{
AI_Output (other, self,"ORG_801_Lares_BringListAnteil_15_00"); //They've already mugged the convoy? Where's my share?
AI_Output (self, other,"ORG_801_Lares_BringListAnteil_11_01"); //Go to see Gorn. He'll give you something.
var C_NPC gorn; gorn = Hlp_GetNpc(PC_Fighter);
if (gorn.aivar[AIV_FINDABLE]==TRUE)
{
AI_Output (other, self,"ORG_801_Lares_BringListAnteil_15_02"); //I know Gorn. He's no member of the gang. He's a mercenary who works for the mages.
AI_Output (self, other,"ORG_801_Lares_BringListAnteil_11_03"); //Yeah, that's right.
AI_Output (other, self,"ORG_801_Lares_BringListAnteil_15_04"); //Was he involved in this business?
AI_Output (self, other,"ORG_801_Lares_BringListAnteil_11_05"); //Knowing too much isn't good for you. Just go to see him and collect your share.
};
B_LogEntry(CH1_JoinNC,"Gorn, the mercenary, participated in the raid on the convoy in a mysterious way. I'll get my share from him.");
gorn.aivar[AIV_FINDABLE]==TRUE;
};

changed to

FUNC VOID ORG_801_Lares_BringListAnteil_Info()
{
    AI_Output (other, self,"ORG_801_Lares_BringListAnteil_15_00"); //They've already mugged the convoy? Where's my share?
    AI_Output (self, other,"ORG_801_Lares_BringListAnteil_11_01"); //Go to see Gorn. He'll give you something.
    var C_NPC gorn; gorn = Hlp_GetNpc(PC_Fighter);
    if (gorn.aivar[AIV_FINDABLE]==TRUE)
    {
        AI_Output (other, self,"ORG_801_Lares_BringListAnteil_15_02"); //I know Gorn. He's no member of the gang. He's a mercenary who works for the mages.
        AI_Output (self, other,"ORG_801_Lares_BringListAnteil_11_03"); //Yeah, that's right.
        AI_Output (other, self,"ORG_801_Lares_BringListAnteil_15_04"); //Was he involved in this business?
        AI_Output (self, other,"ORG_801_Lares_BringListAnteil_11_05"); //Knowing too much isn't good for you. Just go to see him and collect your share.
    };
    B_LogEntry(CH1_JoinNC,"Gorn, the mercenary, participated in the raid on the convoy in a mysterious way. I'll get my share from him.");
    gorn.aivar[AIV_FINDABLE] = TRUE;
};

@AmProsius AmProsius added the provided fix This issue has a fix provided in the comments. label Apr 4, 2021
@szapp
Copy link
Collaborator

szapp commented Apr 5, 2021

We might have to adjust the wording in the changelog. The player can "find" Gorn regardless. This AI variable records whether the player has heard of Gorn and can be asked for in the "Where can I find ..." ambient dialogs.

VAR C_NPC Gorn; Gorn = Hlp_GetNpc(PC_Fighter);
if (Gorn.aivar[AIV_FINDABLE] == TRUE)
{
Info_AddChoice(Info_FindNPC_NC,"...Gorn?", Info_FindNPC_NC_Gorn);
};

The simplest way to fix this issue is by hooking the function and setting the AI variable afterwards. Alternatively, the comparison (==) can be exchanged for an assignment (=) in the byte code of the function. This would be more elegant and would correct the data stack (the comparison leaves the resulting truth value on the stack). If I get to it, I will do that. If not, the hook-approach should suffice, too.

@szapp szapp self-assigned this Apr 5, 2021
@szapp szapp added compatibility: difficult This issue is difficult to make compatible. impl: modify/analyze script func This issue requires analyzing and/or modifying the bytecode of script functions. type: session fix The fix for this issues is persistent across a session. labels Apr 5, 2021
@AmProsius AmProsius changed the title Gorn is not findable after talking to Lares Gorn can't be asked about after talking to Lares Apr 5, 2021
@szapp szapp added this to Dialog: Info function in Fix templates Apr 5, 2021
@szapp szapp removed their assignment Apr 7, 2021
@szapp szapp added compatibility: easy This issue is easy to make compatible. impl: hook script func This issue requires hooking script functions. and removed compatibility: difficult This issue is difficult to make compatible. impl: modify/analyze script func This issue requires analyzing and/or modifying the bytecode of script functions. labels Apr 7, 2021
@szapp
Copy link
Collaborator

szapp commented Apr 7, 2021

I think, the easy route may suffice:

  1. Check for necessary symbols and hook the function ORG_801_Lares_BringListAnteil_Info
/*
 * #228 Gorn can't be asked about after talking to Lares
 */
func int G1CP_228_LaresDialogFindGorn() {
    if (G1CP_IsFunc("ORG_801_Lares_BringListAnteil_Info", "void|none"))
    && (G1CP_IsIntConst("AIV_FINDABLE", 0))
    && (G1CP_IsNpcInst("PC_Fighter")) {
        HookDaedalusFuncS("ORG_801_Lares_BringListAnteil_Info", "G1CP_228_LaresDialogFindGorn_Hook");
        return TRUE;
    } else {
        return FALSE;
    };
};
  1. First call the original function, then just set the AI variable of Gorn:
/*
 * This function intercepts the dialog to add actions afterwards
 */
func void G1CP_228_LaresDialogFindGorn_Hook() {
    G1CP_ReportFuncToSpy();

    // Call the original function first
    ContinueCall();

    // Set Gorn to be "findable"
    G1CP_NpcIDSetAIVar(MEM_GetSymbolIndex("PC_Fighter"), "AIV_FINDABLE", TRUE);
};

@szapp szapp added provided implementation This issue has a full or partial implementation provided in the comments. and removed provided fix This issue has a fix provided in the comments. labels Apr 12, 2021
@AmProsius AmProsius self-assigned this Apr 17, 2021
@AmProsius AmProsius added this to To Do in v1.2.0 Apr 17, 2021
@AmProsius AmProsius added this to the v1.2.0 milestone Apr 18, 2021
@AmProsius AmProsius requested a review from szapp May 9, 2021 10:48
@AmProsius AmProsius removed their assignment May 9, 2021
@AmProsius AmProsius merged commit d15364e into master May 9, 2021
v1.2.0 automation moved this from To Do to Done May 9, 2021
@AmProsius AmProsius deleted the bug228 branch May 9, 2021 12:16
Copy link
Collaborator

@szapp szapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better late than never ;) Some minor fixes and suggestions.

src/Ninja/G1CP/Content/Tests/test228.d Show resolved Hide resolved
src/Ninja/G1CP/Content/Tests/test228.d Show resolved Hide resolved
src/Ninja/G1CP/Content/Tests/test228.d Show resolved Hide resolved
src/Ninja/G1CP/Content/Tests/test228.d Show resolved Hide resolved
src/Ninja/G1CP/Content/Tests/test228.d Show resolved Hide resolved
AmProsius added a commit that referenced this pull request May 9, 2021
@szapp szapp removed the validation: required This issue needs validation from one of the validators. label May 14, 2021
@szapp szapp moved this from Modify dialog function to Extend dialog function in Fix templates Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility: easy This issue is easy to make compatible. impl: hook script func This issue requires hooking script functions. provided implementation This issue has a full or partial implementation provided in the comments. type: session fix The fix for this issues is persistent across a session.
Projects
Fix templates
Extend dialog function
v1.2.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants