Jump to content

Home

Another Script question


LiquidZoo

Recommended Posts

I want to spawn a NPC, which I'm fairly sure I can figure out how to do thanks to the tutorials, and I want them to have a dialog with me, which I'm not so sure how to do.

 

I want them to stay stationary until I initiate the conversation. I'm pretty sure I can attach the script to spawn the NPC onto one of the static dialogs, right? I will have to find an appearance for him, and figure out how to equip him with the items I want, but that shouldn't be too hard. I would also like to spawn 2 of them, on the same location. 1 if the PC is light, another if they are dark. Would something like this work? (note that I still need to get coordinates for the spawn)

 

#include "k_inc_utility" //not sure if this is necessary

void main()
{
object oPC = GetFirstPC();

if(IsDark()==TRUE){
//code to spawn DS NPC
    }

else{
//code to spawn LS NPC
    }

}

Link to comment
Share on other sites

I want them to have a dialog with me, which I'm not so sure how to do...I want them to stay stationary until I initiate the conversation.

Well that doesn't even require scripting -- you can just set the Conversation field of the speaker's .utc file to the name of the dialog you want use.

I'm pretty sure I can attach the script to spawn the NPC onto one of the static dialogs, right?
Static dialogs? Um, just use the dialog that is specified in the Conversation field above. Whether you create a dialog from scratch or you use an existing dialog doesn't matter. But yes, you will attach the spawn script to a node in the dialog.

 

I will have to find an appearance for him,
it's recommened that you specify that in the .utc file...

and figure out how to equip him with the items I want
again you can do that in the .utc file by using KT's inventory editor (or you can script them in when you spawn the utc example here)
I would also like to spawn 2 of them, on the same location. 1 if the PC is light, another if they are dark.

 

void main()
{
object oPC = GetFirstPC();
vector myVec=(14.0, 231.4, 0.0);  //or whatever coordinates you want
location myLoc=(myVec, 90.0);     // play with the rotation too
if(GetGoodEvilValue(oPC)>=50){  //PC is ight

//use the .utc files' TemplateResRef  here...
   object oNPC1=CreateObject(OBJECT_TYPE_CREATURE,"light_npc1",myLoc);
   object oNPC2=CreateObject(OBJECT_TYPE_CREATURE,"light_npc2",myLoc);
}
else{                           //PC id dark
   object oNPC1=CreateObject(OBJECT_TYPE_CREATURE,"dark_npc1",myLoc);
   object oNPC2=CreateObject(OBJECT_TYPE_CREATURE,"dark_npc2",myLoc);

    }
}

 

Hope this helps. :)

Link to comment
Share on other sites

That helps a lot, thanks.

 

you can just set the Conversation field of the speaker's .utc file to the name of the dialog you want use.

I thought so, but I wanted to be sure.

 

Static dialogs? Um, just use the dialog that is specified in the Conversation field above. Whether you create a dialog from scratch or you use an existing dialog doesn't matter. But yes, you will attach the spawn script to a node in the dialog.

 

It would be one of the dialogs you only get once, like talking to Dustil, or to the council during your jedi training. Something like that. I'd have to pick a spot where I wanted it to trigger the spawn.

 

it's recommened that you specify that in the .utc file...

 

I know. Just thinking out loud, trying to figure out what I wanted for him/her. I may go with an alien race, so I could have sound with the dialog. Haven't decided yet, but I'm leaning that way.

 

And thanks for the script example. That helps me refine my scripting down quite a bit. I still have much to learn, but I'm getting there. I will let people know when I have this done. I'm getting excited about working on it.

Link to comment
Share on other sites

Glad I could help out. :)

It would be one of the dialogs you only get once, like talking to Dustil, or to the council during your jedi training.
It might be eaiser for you to create your own Conditional script or modifiy the spawn script itself to perform the check. Take a look at the second post in this thread for info about suppressing script re-entry.
Link to comment
Share on other sites

Another question. I want to incorporate some awareness or pursuade checks into my scripts, which I have already figured out how to do by calling the pre-made scripts for these checks, but I also would like to add light or dark side points on some responses. I know the cheat code way to do this, but how would I do it in a script?

 

Edit Nevermind, just figured it out with the k_act_light/dark scripts. Is there anyway to know exactly how much the 3 of each script adds? I would like to give extreme points in one direction or the other and I'm not sure the high versions of them will give enough.

Link to comment
Share on other sites

Another question. I want to incorporate some awareness or pursuade checks into my scripts, which I have already figured out how to do by calling the pre-made scripts for these checks, but I also would like to add light or dark side points on some responses. I know the cheat code way to do this, but how would I do it in a script?

 

Edit Nevermind, just figured it out with the k_act_light/dark scripts. Is there anyway to know exactly how much the 3 of each script adds? I would like to give extreme points in one direction or the other and I'm not sure the high versions of them will give enough.

 

Regarding the skill checks, here is an example of a conditional script that checks if the PC's Awareness is greater than 15.

int StartingConditional() {
return (GetSkillRank(SKILL_AWARENESS,GetFirstPC()) > 15);
}

For Persuade, you can use something a bit more fun... KotOR has some random difficulty checks built-in to these conditional scripts: k_con_perseasy, k_con_persmed, k_con_pershigh. There's a little bit of luck involved there.

 

For the k_act_light/dark scripts, the amount of LS or DS points you get is dependent on how LS or DS you already are. Here's a table quoted from k_inc_utility showing the adjustment amounts:

                    1       2       3         4      5
                   VLight  Light   Neutral   Dark   VDark
     High Light    2       4       6         8      10
     Mid Light     1       2       4         6      8
     Low Light     1       1       2         4      6
     Low Dark      -6      -4      -2        -1     -1
     Mid Dark      -8      -6      -4        -2     -1
     High Dark     -10     -8      -6        -4     -2

The left side represents is the k_act_lighthigh to k_act_darkhigh scripts. The top is your current GoodEvil value where:

85+  VLight
61-84 Light
40-60 Neutral
15-39 Dark
14-  VDark

 

There is also an example of how to manually give LS/DS points using the AdjustAlignment function in the first post of this thread.

Link to comment
Share on other sites

Ok, I have a few scripts compiled (first ones, yay me! :cowdance )

 

Questions about them, cause I hope I did them right. Here is one of the scripts, exactly how it appears in the nss file:

 

void main()
{
AdjustAlignment( GetFirstPC(),ALIGNMENT_DARK_SIDE,100);
}

 

It's part of the design of the mod I am making to give Light or Dark mastery, depending on dialog choices (have an identical script for light side).

 

Now, I followed the tutorial in this thread and made myself a batch file:

 

nwnnsscomp -c -g 1 *.nss
pause

 

It did indeed give me the ncs files, but I also noticed in the command window that it kicked out a bunch of errors about functions and variables, presumably in the nwscript.nss file. Is this just due to the fact that I didn't have the @echo off in the batch file?

 

My next step, after I finish modifying some lightsaber uti's, is to get the waypoints and start testing the npc spawns.

 

Oh, speaking of that. I plan on using a Female Twi'lek, and probably a Rodian for the NPC's. I would like them to be wearing jedi robes (which I am also creating, so they'll be unique). I have extracted the n_twilekf.uti and n_rodian.uti files, and added a 01 to the end to make them unique. Anyone know if I'm going to experience any issues equipping them with the jedi robes, after making sure they have the force sensitive feat, of course.

Link to comment
Share on other sites

It did indeed give me the ncs files, but I also noticed in the command window that it kicked out a bunch of errors about functions and variables, presumably in the nwscript.nss file. Is this just due to the fact that I didn't have the @echo off in the batch file?

The errors you saw were nwnnsscomp trying to compile nwscript.nss as well as your .nss file. You can ignore these if you like, make your .bat file more specific (that is, change the *.nss to myscript.nsss or whatever), or just manually type the command line.

 

In regards to your script, I'd probably take into account the PC's current GoodEvil value and adjust it accordingly rather than add a fixed amount or call the SetGoodEvilValue function instead.

 

Example 1:

void main () {
object oPC=GetFirstPC();
int nAlignment=GetGoodEvilValue(oPC);
AdjustAlignment(oPC,ALIGNMENT_DARK_SIDE,nAlignment);
}

Example 2:

void main () {
SetGoodEvilValue (GetFirstPC(),0);
}

I don't believe the second example will display the "Dark Side Points Gained" popup. (?)

My next step, after I finish modifying some lightsaber uti's, is to get the waypoints and start testing the npc spawns.

Good luck with that. Start a new thread if you get stuck!
Link to comment
Share on other sites

One more quick question. For creating the items in my inventory:

 

object oItem=CreateItemOnObject( "item_template", GetFirstPC());

 

From tk102's great post.

 

On the "item_template", do I need the quotes? Same question applies to the NPC spawn, I suppose. Do I need them around the NPC template as well?

Link to comment
Share on other sites

Yes you need the quotes unless you pass a string variable that has been initialized.

void main() {
string sTemplate="my_template";
object oItem=CreateItemOnObject(sTemplate,GetFirstPC());
}

When you use quotes, you are passing the immediate string rather than a string variable, but the effect is the same.

Link to comment
Share on other sites

Thank you. One other thing I noticed when I copy/pasted the spawn script you gave me earlier:

 

void main()
{
object oPC = GetFirstPC();
vector myVec=(14.0, 231.4, 0.0);  //or whatever coordinates you want
location myLoc=(myVec, 90.0);     // play with the rotation too
if(GetGoodEvilValue(oPC)>=50){  //PC is ight
    [color=red]}[/color]
//use the .utc files' TemplateResRef  here...
   object oNPC1=CreateObject(OBJECT_TYPE_CREATURE,"light_npc1",myLoc);
   object oNPC2=CreateObject(OBJECT_TYPE_CREATURE,"light_npc2",myLoc);

else{                           //PC id dark
   object oNPC1=CreateObject(OBJECT_TYPE_CREATURE,"dark_npc1",myLoc);
   object oNPC2=CreateObject(OBJECT_TYPE_CREATURE,"dark_npc2",myLoc);

    }
}

 

I assume, following everything I know about if/then/else statements that the bracket in red is supposed to be after the light spawn codes?

Link to comment
Share on other sites

Argh...

 

Well, I was going to test the NPC's spawning, still will if I can get this script working. It is erroring on the commas on lines 3 and 4, can anyone help?

 

void main()
{
vector myVec=(52.35, 70.75, 8.76);  
location myLoc=(myVec, 0.0f);     
if(GetGoodEvilValue(oPC)>=50){  //PC is ight

   object oNPC1=CreateObject(OBJECT_TYPE_CREATURE,"n_twilekf01",myLoc);
    }

else{                           //PC id dark
   object oNPC1=CreateObject(OBJECT_TYPE_CREATURE,"n_rodian01",myLoc);

    }

ExecuteScript("k_pdan_makejedi", OBJECT_SELF);

}

Link to comment
Share on other sites

try:

void main()
{
[color=skyblue]object oPC=GetFirstPC();[/color] //oops forgot that. Thanks tk 
vector myVec=[color=skyblue]Vector[/color](52.35, 70.75, 8.76);  
location myLoc=[color=skyblue]Location[/color] (myVec, 0.0);     
if(GetGoodEvilValue(oPC)>=50){  //PC is ight

   object oNPC1=CreateObject(OBJECT_TYPE_CREATURE,"n_twilekf01",myLoc);
    }

else{                           //PC id dark
   object oNPC1=CreateObject(OBJECT_TYPE_CREATURE,"n_rodian01",myLoc);

    }

ExecuteScript("k_pdan_makejedi", OBJECT_SELF);

}

Link to comment
Share on other sites

Don't know why you're getting that error but you will need to initialize the oPC variable:

 

This script compiled for me:

void main()
{
object oPC=GetFirstPC();
vector myVec=Vector(52.35, 70.75, 8.76);  
location myLoc=Location (myVec, 0.0);     
if(GetGoodEvilValue(oPC)>=50){  //PC is ight

   object oNPC1=CreateObject(OBJECT_TYPE_CREATURE,"n_twilekf01",myLoc);
    }

else{                           //PC id dark
   object oNPC1=CreateObject(OBJECT_TYPE_CREATURE,"n_rodian01",myLoc);

    }

ExecuteScript("k_pdan_makejedi", OBJECT_SELF);

}

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...