OnConversation)
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.
Trigger
The creature has been clicked on for conversation or someone has audibly spoken.
Function(s)
- GetListenPatternNumber() - The numeric ID of the listening pattern that triggered the evnet. -1 if creature is being clicked on / ActionStartConversation or BeginConversation is used. It usually is further negative values if it is in the in built associate shouts/commands. Set patterns to listen to with SetListenPattern.
- GetLastSpeaker() - The object speaking, or clicking to initiate conversation
- GetMatchedSubstring(int nString) will return a string heard, or part of the string heard that triggered the event (If you use * in the setup).
TestStringAgainstPattern - may be useful for testing things against the string being listened to.
Remarks
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.
Example
// 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
functions: |
GetListenPatternNumber GetLastSpeaker TestStringAgainstPattern GetMatchedSubstring() |