Jump to content

Home

I need Dialog script help


T7nowhere

Recommended Posts

What I want to do is Make it so after the PC has talked to the npc with my dialog only one sentence will be displayed of the dialog everytime the dialog is initiated.

 

Arrhg!! scripting can be SO annoying when you don't really know what your doin.

Link to comment
Share on other sites

Im useing NWtoolset for writing new dialog and editing game dialog.

 

What I want to do is when player talks to the npc for a second time all that is displayed is the first sentence of the npc's dialog and then exit out.

 

I just had a thought that it might be easyer to have the sentence I want to be displayed the second time be duplicated as a new tree with just that sentance and to have a conditional or something attatched.

 

Any ideas on how to do it would be helpful. As it is I have the NPC displaying the dialog everytime he is spoken to which is very annoying and distracting from the story.

Link to comment
Share on other sites

Yup, the way to go is to use the conditional in front of the two main trees, one for the first time talked to, and for after thats.

The conditional script will look something like this:

 

int StartingConditional()
{
    int iCheck = GetGlobalNumber("TALKED_TO");
    if (iCheck == 1)
        return TRUE;
    return FALSE;
}

 

Compile it and say, name it as "secondtime.ncs".

Using the NWN toolset, go to the beginning of the dialog tree for the dialog you want to display the second time. Then go to the tab "Text Appears When" and put in the name of the script "secondtime".

 

 

int StartingConditional()
{
    int iCheck = GetGlobalNumber("TALKED_TO");
    if (iCheck != 1)
        return TRUE;
    return FALSE;
}

 

Same thing here, but name this one "firsttime.ncs" for example. Go to the other dialog tree, the one that you want to be displayed the first time and put "firsttime" in the "text appears when".

 

One last thing.

 

void main()
{
   SetGlobalNumber("TALKED_TO", 1);
}

 

Name this one "talkedto.ncs". This script will trigger the state that the NPC has been talked to. To do this, you have to call this script from at the end of your First Time Dialog. So, go to the end your first time dialog and this time, put "talkedto" NOT in the text appears when, but in the field "Actions Taken". Another note, you have to edit the globalcat.2da to include a new line "XXXX TALKED_TO Number".

 

That should do it. Mind you I have not tried this script, I might make some typo error in it that makes the whole script not usable, but the main concept is like that. Tell me if anything is wrong.

Link to comment
Share on other sites

Thanks gameunlimited, your scripts worked perfectly.and I will add this to the scripts section of the sticky. Could be helpful to someone else.

 

one other question though,would it have been possible to use a local or something. Im still new this script **** but I read that an over use of globals can slow down the game( I think Lil' jawa said that) I still not certain on all the script lingo.

also when other people start useing globals in their scripts there will be conflicts with the globals.2da.

Link to comment
Share on other sites

Yes it is possible to use a local variable instead of a global one. However, this pose another problem. The script can't seem to create a NEW local variable. Using a previously made local variable can be done, however, that variable might be used by the game for some other purposes. So, I prefer to use a global variable instead in which I can create a new global instead of using the ones that were already there.

Link to comment
Share on other sites

:confused:

I'm confused as to the definition you're using to describe a local variable. In your script above, iCheck is a local variable is it not? But you say the script can't create a new local variable?

 

And if a variable is local isn't it by definition safe from being used elsewhere in the game?

Link to comment
Share on other sites

tk, when I say local variable, what I actually meant was variables that are stored in objects. So each different objects (such as NPCs or placables) will have their own set of variables stored within them. The command used to store into these variable holder is "SetLocalNumber" and "SetLocalBoolean" instead of "SetGlobalNumber". I think that these local variables are used for AI related things, perhaps some of them are also used for plot advancements. Not sure though, just my speculation.

Link to comment
Share on other sites

Tk, since you are doing a savegame editor as well as global editors, perhaps you have seen the node "SWVarTables" in the GIT files withing the file savegame.sav. They are also located in all placables, NPCs, etc in the item list within that GIT file too. I think this is where the game saves these local variables. I thought I should ask you since you have worked with these files more than anyone else here. Do you know what those are?

Link to comment
Share on other sites

Ah now I understand. Thanks for clearing that up for me.

 

There's also a similar field in the module.ifo file -- you are probably right in your guess in that this is the area where these local variables are storing their data. Scripts associated with the items, placeables, etc probably have their own internal definitions of how they make use of each boolean, numeric, string, and location. However, I don't believe those definitions are exposed to us outside the scripts. I'm sure each one uses the variables in that field differently, making it somewhat dangerous to tweak.

 

I'm curious to know the parameters that "SetLocalNumber" and "SetLocalBoolean" use. Is it something like ( VariablePosition, Value)?

Link to comment
Share on other sites

The usage is like this:

 

SetLocalNumber(Variable Name, object, value)

 

I forgot the exact order but those are the three parameters supplied.

 

Variable name is an integer, so the variable does not actually have a string name like how a global variable does.

 

Object is the object in which the variables are stored. Even modules can be used here too.

 

Value is value to be set.

Link to comment
Share on other sites

  • 3 weeks later...

I don't think SetLocalInt is even in the function library. There are SetLocalNumber and SetLocalBoolean however. As for the SetLocalNumber problems (as well as SetLocalBoolean), take a look at this for example:

 

void main()
{
   int nVarIndex = 50;
   int nValue = 99;
   SetLocalNumber(oAnyObject, nVarIndex, nValue);

   if (GetLocalNumber(oAnyObject, nVarIndex) == 99)
   {
       ACTIONS;    
   }
}

 

The ACTIONS above simply will not execute. The same thing happen with booleans.

 

It does work however if I change the nVarIndex to a low number. As long as it is less than 4 (or 5, can't remember), it will work just fine. So my feeling tells me that either those are about all you can use or there is another way to declare these variables before using the SetLocal function. Also, I think that those numbers that can be used have some use to the game which makes me not going to use those for modding purpose.

Link to comment
Share on other sites

I see what you mean. NWNNSSCOMP.exe returns:

Compiling: my_test.nss

my_test.nss(23): Error: Undeclared identifier "SetLocalInt"

my_test.nss(24): Error: Undeclared identifier "GetLocalInt"

Compilation aborted with errors

Total Execution time = 78 ms

Is that you determined is was not in the library or do you have another set of reference beyond NWNLexicon?

 

Also, what is the easiest way of debugging scripts -- is there a simple "one liner" action that will write a string or something to the screen? I tried using DebugSpeak but it is in the same category as above...

Link to comment
Share on other sites

I think I found the real function reference. nwscript.nss in scripts.bif

 

Here are the comments about the SetLocal_ functions:

// 680. SetLocalBoolean

// This sets a boolean flag on an object

// currently the index is a range between 0 and 63

void SetLocalBoolean( object oObject, int nIndex, int nValue );

// 682. SetLocalNumber

// This sets a number on an object

// currently the index is a range between 0 and 0

void SetLocalNumber( object oObject, int nIndex, int nValue );

So it looks like an object can only have 64 booleans and only 1 integer associated with it. Not very expansive.

 

I should have followed Messkell's advice to check that resource earlier.

Link to comment
Share on other sites

Yup, I have read that before. However, the boolean does not work as advertised, it can only have as few as 4 or 5. And the number, it can contains not just one, but up to 4 or 5 also.

 

As for LocalInt, yes that is how I tell that it is not in the library. Also that in nwscript.nss, it is not listed too. It also won't compile using the NWN tools. It is strange though, as I can find several uncompiled scripts that actually use SetLocalInt function.

 

I have been trying to find a one liner conversation too but can't seem to find one that is working. There are a bunch of conversation related functions in the nwscript.nss, I have tried quite some of them with no result.

Link to comment
Share on other sites

  • 1 year later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...