From NWN Lexicon
Revision as of 00:35, 10 May 2021 by Jasperre (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The script attached to this event fires whenever the dialogue with another creature ends or when a shout is heard. PC's speaking can fire this, and is a good way of getting them to specifically answer a riddle or password.


The creature has been clicked on for conversation or someone has audibly spoken, or a message is passed from the engine based on SetAssociateListenPatterns.


TestStringAgainstPattern - may be useful for testing things against the string being listened to.


By default, if the creature has been clicked on for conversation, it will stop what it is doing and begin dialogue (if it can). Otherwise the script checks to see if a spoken (sometimes typed) phrase is recognizable and if the creature has been set up to recognize combat shouts. Only if the creature is listening (SetListening) will this event fire at all. Once the creature is set to listening, they will only hear things set by SetListenPattern.

The script nw_g0_conversat will fire if there is no OnConversation script supplied, and will start their conversation if it is someone clicking on them. This also applies to PC's, and you can see for yourself when they face you and speak their hello voicechat, in game, by using "Conversation" on them.

To not have a creature interrupted (eg while walking around or doing some kind of complex animation) use this code in the event (don't leave the event blank), or simply don't call BeginConversation:

// If manually clicked do nothing
if(GetListenPatternNumber() == -1)

Associate Command Remarks

There are 5 commands that are useful to add remarks on here, since they are engine controlled not player controlled. Most commands are sort of chat-commands the player does in the radials or voice menu. However these 5 have parameters that would be useful to know if you are going to make use of them. They are also called at specific times.

These two fire on the actions of the master or on some searching going on. For each associate (in order of addition) get this fired for them.

  • ASSOCIATE_COMMAND_MASTERFAILEDLOCKPICK - This fires either when OnFailToOpen fires for an object (they clicked, it's locked and they don't have a key) or when they fail a SKILL_PICK_LOCK check against the given lock value (either it never starts due to being too high, or fails due to low skill/bad roll in combat). There is no direct way to find the object the PC failed to open, Bioware just gets the nearest locked object in 10 meters and responds appropriately.
  • ASSOCIATE_COMMAND_MASTERSAWTRAP - This fires when the master sees a trap, you can get the trap with GetLastTrapDetected(GetMaster()). Obviously if two traps appear at once this can get rather interesting if the associate then decides to disarm one - the further one may be chosen, so walk over the nearer one.

These three fire in combat, and are meant to be used to make the associate react properly - however the Bioware AI doesn't always attack due to perception range issues, not going into combat and still standing around, so be aware if the object involved in attacking or being attacked by the master isn't seen it doesn't necessarily mean it's hidden/inaccessible, worth moving to it to attack.

  • ASSOCIATE_COMMAND_MASTERUNDERATTACK - Essentially fired when the masters OnPhysicalAttacked script would fire - by a melee, ranged or SKILL_ANIMAL_EMPATHY or SKILL_TAUNT check is done. This means a creature with 3 attacks will fire it 3 times per round against the master. Bioware doesn't check any values for this event (it does make sure it's not already in combat first though), but you might have success using GetLastAttacker(GetMaster()) to figure out who is doing it. However it is fired a lot of times so don't ping pong.
  • ASSOCIATE_COMMAND_MASTERATTACKEDOTHER - The alternative to MASTERUNDERATTACK, it will fire when the master is making an attack roll against an enemy and when the target's OnPhysicalAttacked will fire. It will only do so when the attack roll is made not when the object is just clicked, so it is safe to assume the player will now become visible/want action to occur if the associate is trying to also hide.
  • ASSOCIATE_COMMAND_MASTERGOINGTOBEATTACKED - This will fire when a PC clicks to attack the master, or a script uses ActionAttack against the master, but before an attack roll is done. If they have to run over to the master first, this fires as they start to run. Bioware uses GetGoingToBeAttackedBy(GetMaster()). However note that this will magically fire even if the master (or associate) can't see the threat, eg; a NPC who is invisible. Take care when responding to the shout like Bioware does.

There appears to be no event that is fired for (hostile) spells being cast by the master or at the master. The above combat shouts are squarely based around physical attacks, be they ranged or melee. This is rather annoying and is one reason henchmen may appear to not "react" if the player casts spells to initiate combat.


// When we here shout 100, we hear anything (See SetListeningPattern), 
// and we can check if they spoke the right password.
void main()
    // Get the number
    int nMatch = GetListenPatternNumber();
    // If nMatch is -1, it means we were clicked on
    if(nMatch == -1)
        SpeakString("Stop touching me!");
    // We only check for the password if nMatch is 100, IE: "**"
    else if(nMatch == 100)
        // Get string they spoke (Set up via.
        // SetListenPattern(OBJECT_SELF, "**", 100); )
        // We will get it in capitals (so not case sensitive).
        // * Note: GetMatchedSubstring will only be 1 value for **, 
        //    so we get the 0 value for it.
        string sSpoken = GetStringUpperCase(GetMatchedSubstring(0));
        // The password is "happy".
        if(FindSubString(sSpoken, "HAPPY") >= 0)
            SpeakString("You got the password correct!");

See Also


GetListenPatternNumber GetLastSpeaker TestStringAgainstPattern GetMatchedSubstring()