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

Atho West - Faulty series of scripts in one dialogue #342

Closed
Salk73 opened this issue Nov 10, 2019 · 6 comments
Closed

Atho West - Faulty series of scripts in one dialogue #342

Salk73 opened this issue Nov 10, 2019 · 6 comments
Labels
Minor Issue Aesthetic issue or other problem that isn't really a bug Module: Manaan Issue occurs primarily on Manaan Type: Scripting This issue is related specifically to a scripting bug/error

Comments

@Salk73
Copy link

Salk73 commented Nov 10, 2019

There are four global scripts that need replacing because they are wrong causing four entries in man26_merc01.dlg to be never spoken.

We need to replace them with the following:

k_pman_random02

int StartingConditional()
{
    int iResult;

    iResult = ((GetGlobalNumber("MAN_PLANET_PLOT") < 3) && ((GetGlobalNumber("MAN_RANDOM") == (1)) || (GetGlobalNumber("MAN_RANDOM") == (2))));
    if (iResult)
        SetGlobalNumber("MAN_RANDOM", d8());

    return iResult;
}

k_pman_random03

int StartingConditional()
{
    int iResult;

    iResult = ((GetGlobalNumber("MAN_PLANET_PLOT") < 3) && ((GetGlobalNumber("MAN_RANDOM") == (3)) || (GetGlobalNumber("MAN_RANDOM") == (4))));
    if (iResult)
        SetGlobalNumber("MAN_RANDOM", d8());

    return iResult;
}

k_pman_random04

int StartingConditional()
{
    int iResult;

    iResult = ((GetGlobalNumber("MAN_PLANET_PLOT") < 3) && ((GetGlobalNumber("MAN_RANDOM") == (5)) || (GetGlobalNumber("MAN_RANDOM") == (6))));
    if (iResult)
        SetGlobalNumber("MAN_RANDOM", d8());

    return iResult;
}

k_pman_random05

int StartingConditional()
{
    int iResult;

    iResult = ((GetGlobalNumber("MAN_PLANET_PLOT") < 3) && ((GetGlobalNumber("MAN_RANDOM") == (7)) || (GetGlobalNumber("MAN_RANDOM") == (8))));
    if (iResult)
        SetGlobalNumber("MAN_RANDOM", d8());

    return iResult;
}

It would also be appropriate to change the position of the mercenary using this .dlg file because he is currently talking with the Iridonian Mercenary and one of the lines say:

"You notice that Iridorian over there in the corner? Don't stare! It's bad enough he's here in the bar. I don't want him coming over or anything!"

@DarthParametric
Copy link
Contributor

What is the knock-on effect of these changes, given they are global scripts? There's no point changing them to fix one inconsequential background peon if that breaks something more important.

@Salk73
Copy link
Author

Salk73 commented Nov 10, 2019

Well, the problem with these scripts is in this:

(GetGlobalNumber("MAN_RANDOM") == (1 || 2))

With 1 || 2 replaced by 3 and 4, 5 and 6, 7 and 8 in three other scripts. It compiles but it is wrong coding. It is never true.

If you are worried about the scripts being global you can just add them to the Atho West module. I will keep an eye out for more instances of these scripts in other Manaan area.

@DarthParametric
Copy link
Contributor

Doing a cursory hex search through the Manaan modules, it seems like that DLG is the only one that uses those specific scripts. Which makes it odd that they are global.

Interestingly if you compile and decompile, then try to recompile DeNCS's output that doesn't compile. NWNSSCOMP spits out Error: Not all paths return a value.

What about k_pman_random17/18/19/20? Seems like they probably have the same issue.

@DarthParametric DarthParametric added Minor Issue Aesthetic issue or other problem that isn't really a bug Module: Manaan Issue occurs primarily on Manaan Type: Scripting This issue is related specifically to a scripting bug/error labels Nov 11, 2019
@JCarter426
Copy link
Contributor

JCarter426 commented Nov 11, 2019

Yikes. 1 || 2 evaluates to 1, as do3 || 4 and 5 || 6. So those scripts are always checking if GetGlobalNumber("MAN_RANDOM") == 1 on the second expression.

The "not all paths return a value" error is probably the compiler being finicky. iResult isn't initialized, but it should be assigned with something, even if the logic of that statement is wrong. That can easily be fixed by changing int iResult; to int iResult = FALSE;. I've seen it do that before with if/else branches, even when they all did have a return statement.

Looks like 17-20 have the same problem, yeah.

@DarthParametric
Copy link
Contributor

DarthParametric commented Nov 11, 2019

So 02-05 should be of the form

iResult = (GetGlobalNumber("MAN_PLANET_PLOT") < 3 && GetGlobalNumber("MAN_RANDOM") == 1 || GetGlobalNumber("MAN_PLANET_PLOT") < 3 && GetGlobalNumber("MAN_RANDOM") == 2);

rather than just

iResult = (GetGlobalNumber("MAN_PLANET_PLOT") < 3 && GetGlobalNumber("MAN_RANDOM") == 1 || GetGlobalNumber("MAN_RANDOM") == 2);

no?

Edit: Ah, brackets.

@JCarter426
Copy link
Contributor

JCarter426 commented Nov 11, 2019

I'm not entirely sure because I don't know what it's checking, but 02 looks like it should be:

	iResult = GetGlobalNumber("MAN_PLANET_PLOT") < 3 &&
			  (GetGlobalNumber("MAN_RANDOM") == 1 || GetGlobalNumber("MAN_RANDOM") == 2);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Minor Issue Aesthetic issue or other problem that isn't really a bug Module: Manaan Issue occurs primarily on Manaan Type: Scripting This issue is related specifically to a scripting bug/error
Projects
None yet
Development

No branches or pull requests

3 participants