Jump to content

Home

Question about dialog conditional: If I have something


Recommended Posts

How can I make a certain node in a dialog become avaliable if I have something. Like if you have 15 in persuade you will get acces to this node:

 

"[Persuade] Life sucks, go kill yourself."

 

Or if you have 25 credits you will get acces to this node:

 

"Here, take 25 credits and buy some food."

 

It's for K1

Link to comment
Share on other sites

You could do that through a script, maybe like this:

 

// This can be used to only say a line in a conversation if the
// speaker has 25 credits or more.

int StartingConditional()
{
  int iResult;

  iResult = (GetGold(GetPCSpeaker()) >= 25);
  return iResult;
}

 

Now once you have this compiled you would put the name of what you called the script (without the .ncs extension) on the dialog node in the "Script that determines availability" Box in TK102's dlg editor, then the option of saying "Here, take 25 credits and buy some food." will only become available if the PC has 25cr or more.

Link to comment
Share on other sites

I Think This Is Kind Of The Same Kind Of Question So I'll Ask It:

 

How Wouldd I Make The Game Spawn An NPC With A Specific Dialog After A Certain Event Has Happened? Such As After You Have Completed The Main Dantooine Quest And Are About To Get On The Ebon Hawk To Search For The Star Maps?

Link to comment
Share on other sites

You could do that through a script, maybe like this:

 

// This can be used to only say a line in a conversation if the
// speaker has 25 credits or more.

int StartingConditional()
{
  int iResult;

  iResult = (GetGold(GetPCSpeaker()) >= 25);
  return iResult;
}

 

Now once you have this compiled you would put the name of what you called the script (without the .ncs extension) on the dialog node in the "Script that determines availability" Box in TK102's dlg editor, then the option of saying "Here, take 25 credits and buy some food." will only become available if the PC has 25cr or more.

 

 

What if I want to give an item?

Link to comment
Share on other sites

What if I want to give an item?

 

void main() {
   CreateItemOnObject("[color=Yellow]ItemName[/color]", GetFirstPC(), 1);	
}

 

Where ItemName should be set to the name of the UTI file with the item template (without the .uti extension).

 

You should have a look at the scripting tutorials forum at the top of Holowan, many of these kinds of less complex scripting questions have already been answered there. :)

Link to comment
Share on other sites

But that gives me an item. I want to give someone else an item.

 

Then that might be a detail that's worth mentioning when asking. :nutz3:

 

void main() {
   CreateItemOnObject("[color=Yellow]ItemName[/color]", GetObjectByTag("[color=Red]SomeOneElse[/color]"), 1);	
}

 

Set ItemName to the name of the UTI template, and SomeOneElse to the tag of the NPC to give the item to.

 

Or, if you want give away an item the player already have, you could do like:

void main() {
   object oItem = GetItemPossessedBy(GetFirstPC(), "[color=PaleGreen]ItemTag[/color]");
   if (GetIsObjectValid(oItem)) {
       CreateItemOnObject("[color=Yellow]ItemName[/color]", GetObjectByTag("[color=Red]SomeOneElse[/color]"), 1);  
       DestroyObject(oItem);
   }
}

 

Where ItemTag should be changed to the tag of the item to give away.

 

If it's done in a dialog where the player and the NPC is standing right next to one another, and the NPC is the dialalog owner, this might also work:

 

void main() {
   object oPC = GetFirstPC();
   object oItem = GetItemPossessedBy(oPC, "[color=PaleGreen]ItemTag[/color]");
   if (GetIsObjectValid(oItem)) {
       ActionPauseConversation(); 
       ActionTakeItem(oItem, oPC);
       ActionResumeConversation();
   }
}

Link to comment
Share on other sites

But that gives me an item. I want to give someone else an item.

 

Well then it should be a simple switch to make:

 

void main() 
{

   object oNPC = GetObjectByTag("FooBar");
   CreateItemOnObject("ItemName", oNPC, 1);	

}

 

Edit: Meh... stoffe beat me to it :p.

 

Edit: Unless you want the NPC to actually do something with the datapad at a later date it's probably easier to just destroy the item.

Link to comment
Share on other sites

Stoffe, thank you for showing me how to give something. But my real question was how to acces a node only when you have an item.

 

Something like this:

blablabla()
{

if PC has object ("MYITEM")

}

 

And then you put that in "script that determines availability".

 

 

I know, I suck scripting :smash:

Link to comment
Share on other sites

Stoffe, thank you for showing me how to give something. But my real question was how to acces a node only when you have an item.

 

Something like this:

blablabla()
{

if PC has object ("MYITEM")

}

 

And then you put that in "script that determines availability".

 

 

I know, I suck scripting :smash:

 

That is very similar to the script i said in the beginning, the script would be like this:

 

int StartingConditional()
{

       // Make sure the PC speaker has these items in their inventory
       if(!CheckPartyForItem(GetPCSpeaker(), "[color=red]Your_Item_Name[/color]"))
       return FALSE;
       if(!CheckPartyForItem(GetPCSpeaker(), "[color=red]Your_Item_Name[/color]"))
       return FALSE;

       return TRUE;
}

 

And remember not to put the .UTI extension after Your_Item_Name

 

Now compile that script and place it on the node you only want available if you have the item in the "script that determines availability" box.

Link to comment
Share on other sites

That is very similar to the script i said in the beginning, the script would be like this:

 

if(!CheckPartyForItem(GetPCSpeaker(), "Your_Item_Name"))

 

CheckPartyForItem() is not a standard function in NWScript. For that script to compile you'll either need to create the function, or use an include file that holds it.

 

Or you could just do the check directly, like:

int StartingConditional() {
   return GetIsObjectValid(GetItemPossessedBy(GetFirstPC(), "[color=red]Your_Item_Tag[/color]"));
}

...where Your_Item_Tag should be changed to the tag of the item, as set in in the UTI file.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...