Aller au contenu

Photo

Looking for scripting help regarding defined flags


  • Veuillez vous connecter pour répondre
22 réponses à ce sujet

#1
Nitro9a

Nitro9a
  • Members
  • 107 messages
I am editing several of the main dialogues for a project I'm working on- http://social.biowar...m/project/1436/

I didn't want to have to alter any of the scripts but it seems I am going to have to now because the section of Zevran's dialogue that I am editing utilizes several defined flags. I only have a little experience with scripting so far and since I need to alter a script rather than writing a new one I'm worried about seriously messing something up so I'm looking for help.

There is a branch of selected dialogue in Zevran's tree that looks like this:

You wish to talk?  Ah, good. I have a question for you.

The plot is genpt_zevran_defined and the flag that triggers this conversation is ZEVRAN_DEFINED_ADORE_AND_NOT_TALKED_ABOUT_ADORE (defined) which means if Zevran is at adore and hasn't talked about it OR if other followers are at adore.

If any of the followers are at adore this will trigger a conversation about them, eventually forcing you to choose between Zevran and your other lover.  After you have gone though any possible conversations of this type it will trigger a conversation about Antivan poetry and the flag ZEVRAN_MAIN_TALKED_ABOUT_ADORE will be set.

After talking about another lover with Zevran either Zevran or that other lover will no longer be at adore.  If Zevran is still at adore he will talk to the pc about poetry and then the line "You wish to talk...?" will never come up again.  So here's my problem-  The additions to the conversations I have made make it possible to have both Zevran and the other love interests at adore at the end of the conversation.  If you choose the options that allow that to happen, he will then talk about poetry and the next time you talk to him the "You wish to talk..." line comes up and then the conversation ends since there are followers still at adore but you've already talked to him about them.  This makes any future conversation with Zevran impossible.

The script that defines this is as follows:

 case ZEVRAN_DEFINED_ADORE_AND_NOT_TALKED_ABOUT_ADORE:
            {
int nAdore = WR_GetPlotFlag(PLT_GENPT_APP_ZEVRAN, APP_ZEVRAN_IS_ADORE, TRUE);
int nAlistairAdore = WR_GetPlotFlag(PLT_GENPT_APP_ALISTAIR, APP_ALISTAIR_IS_ADORE, TRUE);
int nLelianaAdore = WR_GetPlotFlag(PLT_GENPT_APP_LELIANA, APP_LELIANA_IS_ADORE, TRUE);
int nMorriganAdore = WR_GetPlotFlag(PLT_GENPT_APP_MORRIGAN, APP_MORRIGAN_IS_ADORE, TRUE);
int nTalked = WR_GetPlotFlag(PLT_GENPT_ZEVRAN_MAIN, ZEVRAN_MAIN_TALKED_ABOUT_ADORE);
                if(nAdore == TRUE)
                {
                    if((nAlistairAdore == TRUE) || (nLelianaAdore == TRUE) || (nMorriganAdore == TRUE) || (nTalked == FALSE))
                    {
                        nResult = TRUE;
                    }
                }
                break;

Does anyone have an idea how to stop the "You wish to talk..." line from being triggered even if followers are still at adore?

Thanks in advance for any help and also just for reading my very lengthly issue. :)

#2
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
[dascript]
...
if( ((nAlistairAdore == TRUE) || (nLelianaAdore == TRUE) || (nMorriganAdore == TRUE)) && (nTalked == FALSE))
...
[/dascript]
Hope I read it right.

#3
Nitro9a

Nitro9a
  • Members
  • 107 messages
Thanks for responding. I can see how that should work, I think, but nothing changed.

#4
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
ZEVRAN_MAIN_TALKED_ABOUT_ADORE must not be getting set after he talks about it.

#5
Nitro9a

Nitro9a
  • Members
  • 107 messages
The flag ZEVRAN_MAIN_TALKED_ABOUT_ADORE is set with the line "How well-versed are you in poetry." Is there any reason it wouldn't get set?

#6
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
Not sure. I'm just saying that reading the code there, with that change I proposed made, it appears the only time the result can get set to TRUE is when that flag is NOT set. Therefore it must not be set if you're getting a TRUE result when you check it. Unless maybe the changed script isn't getting used or called for some reason.


There is a line in there somewhere that returns nResult right?

Modifié par Axe_Murderer, 10 janvier 2010 - 09:21 .


#7
Nitro9a

Nitro9a
  • Members
  • 107 messages
Yes, I believe what you suggested should work though, like I said, my experience is limited. The script is getting dumped in Single player /override/toolsetexport since this mod makes changes to the single player campaign. Do you know if there's somewhere else it should go? I'm going to try putting it in moduleID/override/toolsetexport but I'll have to get back to this later tonight. There is a line that returns nResult, though I'm not sure exactly what that means. Thanks again for the help. :)

#8
Nitro9a

Nitro9a
  • Members
  • 107 messages
No luck changing the location of the script. Anyone have any ideas?

#9
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
It's easy to test. Just put a debug output in there somewhere. If you did everything right it should appear then at least you'll know you have your script integrated correctly and it is getting called.



Try putting

Warning( "Yup it works" );

just before the return nResult line.


#10
Nitro9a

Nitro9a
  • Members
  • 107 messages
Do you know when exactly that message should appear?

#11
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
Whenever the defined flag is checked. On the line(s) that uses ZEVRAN_DEFINED_ADORE_AND_NOT_TALKED_ABOUT_ADORE.


#12
Nitro9a

Nitro9a
  • Members
  • 107 messages
Never received the warning. Don't know why the script isn't getting called though.

#13
Lady Olivia

Lady Olivia
  • Members
  • 374 messages
Hey, I wanted to ask about something similar. You're always a step ahead of me, Nitro. :)

Like you, I'm changing original dialog. I had made my own plot and the associated plot-script, and declared/handled all my flags there. But none of it ever made it into the game, no matter what I tried. Saving/compiling went without errors, and the dialog that used my plot didn't complain in the toolset.

It seemed exactly like the game wasn't aware of the existence of my plot&script.

Perhaps it's necessary to declare new plots/scripts somehow, so that the game will use them?

Anyhow, I gave up on that and went on to change the existing scripts; my mod will be heavily incompatible in any case. 

#14
Nitro9a

Nitro9a
  • Members
  • 107 messages
What do you mean by declare? Like maybe there's some spreadsheet where you have to list your new scripts? I've written a few scripts for another mod and never had to do anything like that but none of those scripts involved plot flags. Well I guess the short of it is that I have no idea.



In my case, I'm not creating a new script, just altering one that already exists, but other than that it seems like the same thing is happening to the both of us. Maybe the scripts aren't getting put in the right place?

#15
Lady Olivia

Lady Olivia
  • Members
  • 374 messages

What do you mean by declare? Like maybe there's some spreadsheet where you have to list your new scripts? I've written a few scripts for another mod and never had to do anything like that but none of those scripts involved plot flags.


Hmm. Perhaps it's the plot that needs to be "declared" somewhere, have the same name as something, be associated with some area or... I don't know, I'm running out of ideas. I'm completely sure the game simply didn't register my newly added plot and its script.

Which is to say - it's not the same problem that you have, I misread your first post and thought you were also adding new scripts.

I changed several existing scripts (chances are, some are the same as the ones you're working on - romance_triangles, to name one), and that worked well.

Maybe the scripts aren't getting put in the right place?


If your exported files are anywhere in modules/[yourmod]/override or modules/single player/override, the game should see them fine.

#16
Lady Olivia

Lady Olivia
  • Members
  • 374 messages
Now that I have read everything carefully (and looked at it in the toolset), I'm sure Axe gave you the right answer; but if you just changed that last || into && in the original script, it might fail because of operator precedence. So just to make sure, try rewriting it as:

if(nAdore == TRUE)
{
    if(nTalked == FALSE)
    {
        if((nAlistairAdore == TRUE) || (nLelianaAdore == TRUE) || (nMorriganAdore == TRUE))
        {
            nResult = TRUE;
        }
    }
}

Which should definitely return FALSE after the TALKED flag is set.

#17
Nitro9a

Nitro9a
  • Members
  • 107 messages
Okay, that's definitely progress, thanks!



What's happening with this change (and since something is happening at least I know the script is being called) is that he has one of the conversations and then goes back to his normal responses, i.e., "You call?"



In this particular case both Leliana and Alistair are at adore. The conversation about Alistair is triggered but not the conversation about Leliana or the one about poetry. I'm not sure why, since the TALKED flag shouldn't be triggered until he talks about poetry.



Another thing I've been thinking about is the possibility that, even with everything working correctly as I hope it eventually will, if you happen to have the conversation about poetry before other followers are at adore you will never get the conversations about the followers. Maybe there is another solution...

#18
Nitro9a

Nitro9a
  • Members
  • 107 messages
About your issue, I noticed that when I export a script there is a list of plot defines that also get exported, like in this instance when I export genpt_zevran_defined.nss I also get a plt_genpt_zevran_defined.nss which lists all the flags in genpt_zevran_defined.nss. Is anything like that getting exported for your custom plots?

#19
Lady Olivia

Lady Olivia
  • Members
  • 374 messages
Ah, but the TALKED flag does get triggered in all the conversations, together with the ROMANCE_ZEVRAN_DISCUSSES_[COMPANION] flag. You can see this in the genpt_romance_triangle script.

If you want to control where the TALKED flag is set from the conversation, you can comment out the GetPlotFlag call there. That's what I did for Alistair and his jealousy dialog. It's pretty tangled. 

#20
Nitro9a

Nitro9a
  • Members
  • 107 messages
Okay, I see what you mean now but am still unsure how to make it work. I believe the dialogues should run properly if the TALKED_ABOUT_ADORE flag is only set once he talks about poetry. Can you please explain what you mean by "you can comment out the GetPlotFlag call there". I don't quite get you, sorry. I have very little experience with scripting.

#21
Lady Olivia

Lady Olivia
  • Members
  • 374 messages
No problem. In genpt_romance_triangles, you have a series of such blocks:

case ROMANCE_ZEVRAN_DISCUSSES_ALISTAIR:
{
    //So you won't get the 'generic' adore dialogue if you have one of these
    //as there is some cross over

    WR_SetPlotFlag(PLT_GENPT_ZEVRAN_MAIN,ZEVRAN_MAIN_TALKED_ABOUT_ADORE,TRUE);

    break;
}

To "comment out" a line means to turn it into a comment (the green text in the toolset script editor), which doesn't execute. You do this by adding "//" at the start of the line. Like so:
 
case ROMANCE_ZEVRAN_DISCUSSES_ALISTAIR:
{
    //So you won't get the 'generic' adore dialogue if you have one of these
    //as there is some cross over

    // WR_SetPlotFlag(PLT_GENPT_ZEVRAN_MAIN,ZEVRAN_MAIN_TALKED_ABOUT_ADORE,TRUE);

    break;
}

Now the WR_SetPlotFlag will no longer execute, and the TALKED flag won't be set here. You will probably want to do this for all the combinations of companions... but take it step by step.

#22
Nitro9a

Nitro9a
  • Members
  • 107 messages
Lady Olivia, you're my hero. ;)



Thanks, that did the trick. Everything seems to be working properly now.



One last thing, do you have any suggestions for where I might go to learn a little more about scripting?

#23
Lady Olivia

Lady Olivia
  • Members
  • 374 messages
Thanks, I'm glad I could help. :)

Nitro9a wrote...

About your issue, I noticed that when I export a script there is a list of plot defines that also get exported, like in this instance when I export genpt_zevran_defined.nss I also get a plt_genpt_zevran_defined.nss which lists all the flags in genpt_zevran_defined.nss. Is anything like that getting exported for your custom plots?

Yes. Everything was exported properly. I should really go and make a thread of my own about it... but right now I'm kind of lazy, since I decided to go for the existing scripts after all.

Nitro9a wrote...

One last thing, do you have any suggestions for where I might go to learn a little more about scripting?

Don't know what to tell you, really. I suppose there are tutorials on the builder wiki and other community sites.