Conversation End Script

From NWN Lexicon
Jump to: navigation, search

A conversation Conversation End Script attached under the Current File panel of the conversation editor in the toolset.


Trigger

If the conversation ends normally (with a dialogue node containing [END DIALOGUE]) this file will trigger. It is expected this is a clean and proper exit and is meant for resuming usual animations or ambient things.

If the conversation is exited in other ways (combat starting, Escape being pressed, distance to the conversing object being too far away, various effects, and other things going on) the Conversation Abort Script plays instead. See that page for more details of the differences.


Function(s)

  • GetPCSpeaker can retrieve who is conversing with the NPC.
  • OBJECT_SELF is the NPC who is talking to the PC (if the PC is talking to themselves they will also be OBJECT_SELF).


Remarks

By default all conversations will set this event to nw_walk_wp, along side the Conversation Abort Script, meaning a NPC will go back to ambient animations/walking around immediately when a conversation ends.

Bosses who are meant to always attack a player generally get a version in both events where they will attack the PC who is conversing with them. This saves on putting the script in numerous Conversation Action Script events.


Example

// Example of a multi-use script for conversation actions.
// We will do several things to the PC speaker based on the parameters passed in. More than one can happen at once:
// * hostile = If set to anything, we attack
// * gold = we grant them this amount of gold
// * xp = we grant them this amount of xp
// * item = we create 1 of this item on them
void main()
{
    object oPC = GetPCSpeaker();
 
    // Check each parameter in turn (we could have more than one)
    string sParameter = GetScriptParam("hostile");
    if(sParameter != "")
    {
        SetIsTemporaryEnemy(oPC);
        ActionAttack(oPC);
    }
    sParameter = GetScriptParam("gold");
    if(sParameter != "")
    {
        GiveGoldToCreature(oPC, StringToInt(sParameter));
    }
    sParameter = GetScriptParam("xp");
    if(sParameter != "")
    {
        GiveXPToCreature(oPC, StringToInt(sParameter));
    }
    sParameter = GetScriptParam("item");
    if(sParameter != "")
    {
        object oItem = CreateItemOnObject(sParameter, oPC, 1);
        if(!GetIsObjectValid(oItem))
        {
            SpeakString("ERROR: Item parameter invalid: " + sParameter, TALKVOLUME_SHOUT);
        }
    }
}

See Also

functions:

GetScriptParam GetPCSpeaker