Jump to content

Home

Qui-Gon's Script Shack


Qui-Gon Glenn

Recommended Posts

  • Replies 352
  • Created
  • Last Reply
If you want to have a check wether the person has been talked to just use in-game resources.

 

k_con_talkedto checks if you've talked to a person, and k_act_talktrue makes it so that the game recognizes that you've talked to the person, basically this:

 

void main () { 
SetLocalBoolean(HAS_TALKED,0,TRUE); 
}

 

 

Anyway, I use that a lot in KotOR 1, I don't know if it works in KotOR 2.

 

Its for kotor 1 anyway, thanks guys :)

if theres k_act_talktrue, is there k_act_talkfalse?

Link to comment
Share on other sites

I don't believe so. This is the source code for k_act_talktrue:

 

 

//:: k_act_talktrue
/*
   Sets the NPC talk to state to
   true.
*/
//:: Created By: Preston Watamaniuk
//:: Copyright (c) 2002 Bioware Corp.

#include "k_inc_debug"
#include "k_inc_utility"

void main()
{
   UT_SetTalkedToBooleanFlag(OBJECT_SELF);
}

 

I wouldn't really know how to get this thing set to false again, but maybe a more experience scripter knows.

Link to comment
Share on other sites

If you want to have a check wether the person has been talked to just use in-game resources.

 

k_con_talkedto checks if you've talked to a person, and k_act_talktrue makes it so that the game recognizes that you've talked to the person, basically this:

 

void main () { 
SetLocalBoolean(HAS_TALKED,0,TRUE); 
}

 

 

Anyway, I use that a lot in KotOR 1, I don't know if it works in KotOR 2.

Would this work.

First time the npc sais a node. Run k_act_talktrue.

Second Time, run k_con_talkedto, which will open a different node.

 

Is there something I'm missing?

 

Thanks

 

-DJW

 

 

-JC-

It sais syntax error at SetLocalBoolean

SetLocalBoolean(oTarget, SW_PLOT_HAS_TALKED_TO, FALSE)

 

It sais

 

Syntax error at GiveXPToCreature

GiveXPToCreature(GetFirstPC(),500);

What do I do?

 

Same old error, it sais syntax error on CreateItemOnObject

CreateItemOnObject("g_a_jediscout", oPC);

CreateItemOnObject("g_w_lghtsbr10", oPC);

Link to comment
Share on other sites

xp.nss

GiveXPToCreature(GetFirstPC(),500);

createit.nss

CreateItemOnObject("g_a_jediscout", oPC);

CreateItemOnObject("g_w_lghtsbr10", oPC);

falseboolean.nss

SetLocalBoolean(oTarget, SW_PLOT_HAS_TALKED_TO, FALSE);

 

All the same sort of errors, the, CreateItemOnObject

Trying one of my ideas, (when it comes to scripting im a duck)

it compiled. This :

 

void main()

{

 

GiveXPToCreature(GetFirstPC(),500);

 

}

 

Why is this?

 

This sais undeclared identifyer at oPC

void main ()

 

{

CreateItemOnObject("g_a_jediscout", oPC);

CreateItemOnObject("g_w_lghtsbr10", oPC);

}

 

And the same for oTarget

Required argument missing in SetLocalBoolean

Undeclared identifier SW_PLOT_HAS_TALKED_TO

 

void main()

{

 

SetLocalBoolean(oTarget, SW_PLOT_HAS_TALKED_TO, FALSE);

 

}

 

What eelse do you need to know?

 

PS: How does the boolean script work. i want it to check if you havn't said something, and if you havn't get the option to the dialouge entry I want said only once. Will it do that?

Link to comment
Share on other sites

You haven't declared your variables.

 

For example, oPC on it's own doesn't mean anything. If you do this:

 

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

	CreateItemOnObject("g_a_jediscout", oPC);
	CreateItemOnObject("g_w_lghtsbr10", oPC);
}

 

It should work fine. Same with oTarget, you haven't said what oTarget is.

Link to comment
Share on other sites

PS: How does the boolean script work. i want it to check if you havn't said something, and if you havn't get the option to the dialouge entry I want said only once. Will it do that?

No, that would just set it so you haven't talked to the NPC, even when you have (at least, I think it should do that). If you want to check whether you have talked to an NPC yet, you need a conditional script... they work very differently. But fortunately you don't need to write your own, because the game already has one, k_con_talkedto in K1 and c_talkedto in K2. It will return true if you've never talked to the NPC before.

 

You need to put the script as a conditional script in the dialogue ("script that determines availability" or some such in K1, "Conditional #1" or "Conditional #2" in K2). If the script returns true, the node will be used. Make sure this node is the highest node in the dialogue file so that the game knows to check it first. I think there are more in depth tutorials here, too.

Link to comment
Share on other sites

Why are we using scripts for this again?

 

Just using a_local_set and a_local_reset to decide which nodes are (in)available, and use c_local_set or c_local_notset to check for them.

A little harder for KOTOR1 since it only has one conditional field and 1 script field, but unless you want to do other stuff it's the easiest way to do it...

Link to comment
Share on other sites

Those are scripts too. And they don't exist in K1. And... it's the same thing anyway. :raise:

 

The talked to scripts check a local boolean that is specifically reserved for whether the NPC has been talked to yet. Although that does remind me, at some point in the initial conversation, you'll have to fire a script that sets the boolean. k_act_talktrue in K1 and a_talktrue in K2. Forgot to mention that before.

Link to comment
Share on other sites

You haven't declared your variables.

 

For example, oPC on it's own doesn't mean anything. If you do this:

 

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

	CreateItemOnObject("g_a_jediscout", oPC);
	CreateItemOnObject("g_w_lghtsbr10", oPC);
}

 

It should work fine. Same with oTarget, you haven't said what oTarget is.

void main()

{

 

object oTarget = GetFirstNPC();

SetLocalBoolean(oTarget, SW_PLOT_HAS_TALKED_TO, FALSE);

 

}

 

This is me taking a stab at it :)

 

The erorrs are the same, but replacing oTarget with undeclared identifyer GetFirstNPC same undecalerd with SW_PLOT_HAS_TALKED_TO and the same error with SteLocalBoolean. The other script works fine thanks. :)

Link to comment
Share on other sites

Except that you don't need to write new scripts

And... I just said that. :xp:

just add/remove and check locals in the dlg-editor.

Seeing how handy it is (and often used in TSL) it's not used in KOTOR1? Ouch.

No, it's not. There are no parameters in the dialogue files, so you would need a new script for everything.

KOTOR2 is definitely a lot more modder-friendly 0_0

Yes, yes it is.

void main()

{

 

object oTarget = GetFirstNPC();

SetLocalBoolean(oTarget, SW_PLOT_HAS_TALKED_TO, FALSE);

 

}

 

This is me taking a stab at it :)

 

The erorrs are the same, but replacing oTarget with undeclared identifyer GetFirstNPC same undecalerd with SW_PLOT_HAS_TALKED_TO and the same error with SteLocalBoolean. The other script works fine thanks. :)

It's GetFirstPC, not GetFirstNPC.

 

SW_PLOT_HAS_TALKED_TO might be defined in the file I was reading... I thought it was defined in NWScript. I'll have to check that. In any case, you don't need that; just follow my above instructions.

Link to comment
Share on other sites

Dang.

So, this would work though, right? (KOTOR1 still has locals, multiple of them, right? Which could be used to check?)

void main()
{
object oTarget = GetObjectByTag( "NPC_Talking" );
SetLocalBoolean(oTarget, 51, TRUE);

}

void main() {
object oTarget = GetObjectByTag( "NPC_Talking" );

If GettLocalBoolean(oTarget, 51, TRUE) {
      return 1;
}
Else {
    return 0;
}
}

Link to comment
Share on other sites

Well, while modding in TSL, I found a minor flaw in the following script I made: the party selection screen doesn't show up regardless of how I've changed that part of the script. Any help would be appreciated.

 

// recruit.nss
// Created by Ferc Kast

void RecruitA(int iNPC, string sResRef, string sExit, int iForce)
{
int iNPC;
string sResRef;
string sExit;
int iForce;
RemoveAvailableNPC(iNPC);
AddAvailableNPCByTemplate(iNPC, sResRef);
if ( iForce == TRUE )
{
	DelayCommand(1.5,ShowPartySelectionGUI(sExit, iNPC));
}
else if ( iForce == FALSE )
{
	DelayCommand(1.5,ShowPartySelectionGUI(sExit));
}
}

void RecruitB(string sTag)
{
string sTag;
object oNPC = GetObjectByTag(sTag);
ActionPauseConversation();
SetGlobalFadeOut(1.0, 0.5);    
DelayCommand(1.0, DestroyObject(oNPC));
DelayCommand(1.0,SetGlobalFadeIn(0.7,0.0));
ActionResumeConversation();
}

Link to comment
Share on other sites

I don't see iForce ever being defined as true or false, and you told it only to fire if iForce is true or false, which I find unnecessary, but that means this looks to be only a partial fragment; I'd need to see the rest to make sure any attempt at a fix wouldn't mess with the rest of it. But for now, I can give one bit of advice. First, get rid of your if trees, just replace it with the following:

 

DelayCommand(1.5, ShowPartySelectionGUI(sExit, iNPC1, iNPC2, FALSE);

 

And when you put in the NPC ID number in the DLG, just put in -1 for when you don't want to force anyone, or change your if trees to set them to -1 for anything other than the valid NPC ID numbers. The point of all this is if trees are finicky, particularly with this engine, so it's better to not have the whole execution of the script depend on one.

Link to comment
Share on other sites

Alright, in KotOR 1, I've been attempting to make an NPC walk over to the PC and once the NPC is about 5 meters or so from the PC he initiates a conversation with the PC. This is the script I've been using:

 

void main()
{


    object oPC=GetFirstPC();

    object oNPC=GetObjectByTag("dt_comm");

 int nCurrentDistance;

 int nEvent = GetUserDefinedEventNumber();

   nCurrentDistance = GetDistanceBetween(oNPC, oPC);

 if( 
       (nEvent == 1002) &&
       (nCurrentDistance<6) &&
  	GetGlobalBoolean("DT_CHECK1") == FALSE) {

   ActionDoCommand(SetCommandable(TRUE, oNPC));

 AssignCommand (oNPC, ActionMoveToObject(oPC));

 AssignCommand (oNPC, ActionStartConversation(GetFirstPC()));

 }
}

 

I get an error trying to compile it saying that the equal sign between nCurrentDistance and GetDistanceBetween is incorrect. This is most likely due to the fact I tried to copy of a script that would make something occur once an NPC reached a certain HP level. What should I change, or redo entirely, to make this work?

 

EDIT 1: Alright, while digging through source scripts searching for functions in my other modding projects, I found something that should work:

 

#include "k_inc_debug"
void main()
{


    object oPC=GetFirstPC();

    object oNPC=GetObjectByTag("dt_comm");

 int nEvent = GetUserDefinedEventNumber();

 if( 
       (nEvent == 1002) &&
  	GetGlobalBoolean("DT_CHECK1") == FALSE) &&
       GetDistanceBetween(GetPCSpeaker(), GetFirstPC()) <= 6.00)){

   ActionDoCommand(SetCommandable(TRUE, oNPC));

int bRun=TRUE;


 AssignCommand (oNPC, ActionMoveToObject(oPC, bRun, fRange=1.0f));

 AssignCommand (oNPC, ActionStartConversation(GetFirstPC()));

 }
}

 

I'll get back if it works or not.

 

EDIT 2: Alright, now I get a syntax error at the && after GetGlobalBoolean. How would I fix this?

Link to comment
Share on other sites

I don't see iForce ever being defined as true or false, and you told it only to fire if iForce is true or false, which I find unnecessary, but that means this looks to be only a partial fragment; I'd need to see the rest to make sure any attempt at a fix wouldn't mess with the rest of it. But for now, I can give one bit of advice. First, get rid of your if trees, just replace it with the following:

 

DelayCommand(1.5, ShowPartySelectionGUI(sExit, iNPC1, iNPC2, FALSE);

 

And when you put in the NPC ID number in the DLG, just put in -1 for when you don't want to force anyone, or change your if trees to set them to -1 for anything other than the valid NPC ID numbers. The point of all this is if trees are finicky, particularly with this engine, so it's better to not have the whole execution of the script depend on one.

 

Somehow, the selection GUI still didn't show up, after changing those trees to the simply command. Though, when I checked afterwards, the party member is recruited & able to be chosen for the player's current party. :confused:

Link to comment
Share on other sites

Alright, I've managed to get my above script to compile by making it like this:

 

void main()
{


    object oPC=GetFirstPC();

    object oNPC=GetObjectByTag("dt_comm");

 int nEvent = GetUserDefinedEventNumber();

int bRun=TRUE;

 if( 
       (nEvent == 1002) &&
       GetGlobalBoolean("DT_CHECK1") == FALSE)
       {

       if(GetDistanceBetween(oNPC, oPC) <= 6.0){

   ActionDoCommand(SetCommandable(TRUE, oNPC));

 AssignCommand (oNPC, ActionMoveToObject(oPC, bRun));

 AssignCommand (oNPC, ActionStartConversation(GetFirstPC()));

   } 
 }
}

 

I'll edit this post to tell if it works in-game or not.

Link to comment
Share on other sites

Archived

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


×
×
  • Create New...