PDA

View Full Version : Question about dialog conditional: If I have something


Mindtwistah
05-19-2007, 08:14 PM
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

Master Zionosis
05-19-2007, 09:57 PM
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.

Marius Fett
05-20-2007, 05:19 AM
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?

Mindtwistah
05-20-2007, 06:23 AM
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?

stoffe
05-20-2007, 08:02 AM
What if I want to give an item?


void main() {
CreateItemOnObject("ItemName", 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 (http://www.lucasforums.com/forumdisplay.php?f=597) at the top of Holowan, many of these kinds of less complex scripting questions have already been answered there. :)

Mindtwistah
05-20-2007, 08:05 AM
But that gives me an item. I want to give someone else an item.

For example:

-Can you find my datapad? [NPC]

-Sure! [PC]

You find the datapad and go back

-Can you find my datapad? [NPC]

-Already found it. Here! [NPC]

stoffe
05-20-2007, 08:08 AM
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("ItemName", GetObjectByTag("SomeOneElse"), 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(), "ItemTag");
if (GetIsObjectValid(oItem)) {
CreateItemOnObject("ItemName", GetObjectByTag("SomeOneElse"), 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, "ItemTag");
if (GetIsObjectValid(oItem)) {
ActionPauseConversation();
ActionTakeItem(oItem, oPC);
ActionResumeConversation();
}
}

Pavlos
05-20-2007, 08:08 AM
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.

Mindtwistah
05-20-2007, 01:12 PM
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:

Master Zionosis
05-20-2007, 01:30 PM
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(), "Your_Item_Name"))
return FALSE;
if(!CheckPartyForItem(GetPCSpeaker(), "Your_Item_Name"))
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.

Mindtwistah
05-20-2007, 01:37 PM
EDIT: When I compiled it, I got this error message:

Error: undeclared identifier "CheckPartyForItem"

stoffe
05-20-2007, 01:43 PM
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(), "Your_Item_Tag"));
}

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

Master Zionosis
05-20-2007, 01:46 PM
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.

Ahh that would be because i used an old NWN script assuming it would work, grrr, sorry.