Sunday, June 01, 2008

Conversations

Yes, I'm still here! Things have slowed a little now I've been concentrating on a conversation file, so I thought that would be as good a subject as any to post some tips here and convince you all that work was still taking place.
A thing I see often asked is how to make an NPC know if they've been spoken to before. While it's a fairly simple process to just set a variable and check for it, if you apply this to every conversation you have you'll soon be drowning in scripts and variables. Fortunately there is a way round this that can have the same scripts work for any conversation. It's a very useful method but for the life of me I can't remember where I saw it originally applied, so if these scripts were your invention, drop me a line and I'll give you full credit for them.
Basically there are 2 scripts that both need to be attached to the very first line of conversation possible with any given NPC, so for example, the first time a player converses with a shop keeper, the opening line might be "Can I help you?", whereas a second visit might earn the response "Oh hello again sir/madam. Couldn't keep you away eh?". To achieve this, the following script needs to be attached to the "Text Appears When" event:

//SCRIPT TO PUT ON TEXT APPEARS WHEN OF
//THE FIRST LINE
//- THE ONE THAT SHOULD ONLY BE SPOKEN
//ONCE
//NOTE, THAT LINE MUST HAVE A REPLY, IF ONLY
//AN END DIALOG!
int StartingConditional()
{
object oPC=GetPCSpeaker();
string sTag=GetTag(OBJECT_SELF);
return (GetLocalInt(oPC, sTag)==0);
//only returns true when variable is 0
}

Using the same line of conversation, the following script is attached to the "Actions Taken" event:

//PUT THIS ON ACTION TAKEN OF THE SAME LINE
void main()
{
object oPC=GetPCSpeaker();
string sTag=GetTag(OBJECT_SELF);
SetLocalInt(oPC, sTag, 1);
}


That's it! The same two scripts can be used for all your conversations with no need to create new ones for every NPC.
It's worth noting that there are other methods of controlling what lines of conversation get displayed when activated. The "Text Appears When" tab can be used for pretty much any conditional you care to think of. If for example you want an opening line that says "I'm sorry, you'll have to put your weapon away if you expect me to talk to you", then all you need is a script that checks to see if the speaker is armed. The following script does exactly that:

#include "x2_inc_itemprop"
int StartingConditional()
{
object oPlayer = GetPCSpeaker();
object WeaponRH = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPlayer);
object WeaponLH = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPlayer);
if(IPGetIsMeleeWeapon(WeaponRH) == TRUE GetWeaponRanged(WeaponRH) == TRUE IPGetIsMeleeWeapon(WeaponLH) == TRUE GetWeaponRanged(WeaponLH) == TRUE){return TRUE;
}
return FALSE;
}

Journal entries can also be used as conditionals. The following script checks to see if the journal entry has been started (ie-is set to 1 or greater). If it has, then the line of conversation is ignored, if not, then it is used:

int StartingConditional()
{
object oPC = GetPCSpeaker();
int nInt;
nInt=GetLocalInt(oPC, "NW_JOURNAL_ENTRYyour_journal_name_here");
if (nInt >= 1) return FALSE;
return TRUE;
}


For a conversation to come across as more polished, there are a couple of other tricks you can use which don't even rely on scripts. The first method is to study the lines you've used and consider if an animation would help portray what is being said. If you look under the "Other Actions" tab you'll see a pull down menu with various animation options.
The other method involves a lot more work but can be very satisfying when used well, and that's using the addition of sound. You'll find the sound options under the same tab as the animation options. It does require a little work on your behalf however as you'll need to figure out what the various sound files for the voiceset of your NPC are called. Fortunately life is made a little easier in this respect thanks to some community work over on Neverwinter Vault, where you can find a descriptive list of the various voice sets available. You can use this list to find the file names of the voicesets you have assigned to your NPC, and once you know the filename you should be able to find different responses you can use in the required voice, such as laughter or a simple "Yes". Sometimes, if you're really lucky, you might even find a line of speech from the official campaigns that suits your needs, or even inspires you to take a plot in a new direction.

That's all I'm going to cover for now. Before I go however I'm pleased to announce that I have acquired some webspace, so hope to have my old roleplay related site back online soon. I'm currently contemplating how to lay it out, as some of the old content will be made redundant by what this blog covers.

Bye for now and happy building! :)