Summary:
This NPC can be configured through a gump to respond to keywords with a number of lines of speech. Useful in quests.
Description:
This must be the first real script I ever wrote, I found it lying somewhere on my HD and figured I could share it. This should come in handy in quests, or to give players directions.
When added, the npc will appear hidden and standing still. Double click it to enter configuration mode. The first gump allows you to manage and add new speech entries.
Each entry consists of a number of keywords and a number of lines of text considered as the NPC's speech. You can specify whether the NPC will react to any keyword, or if all keywords must be present in the player's line for the NPC to react.
When the NPC reacts to the player's speech, it will perform the speech defined for the given entry. Lines of text will be spoken in the same order as they appear in the entry configuration, and the delay between the lines can be configured on the NPC props.
You can add an infinite number of entries, so you can actually get the NPC to simulate a conversation (within limits of course) when configured correctly. This works esepcially well when using it as a scared to death looking for help NPC
You can also edit entries. The interface for this is somewhat unintuitive but it was the best I could come up with at the time. You can move up and down between keywords (or speech lines) and once you select one you have buttons to modify and delete it.
The NPC can be configured by only one person at a time. Also if you get disconnected while configuring the NPC, the NPC will remain hidden and immovable, but other staff will be able to configure it.
Installation:
Place anywhere in your Scripts folder. Use [Add Speaker to add to the world.
Updates
May 30:
Implemented sequencing of entries. When the Sequence property is set to true, the player will have to match the entries in the same order as they're entered in the configuration gump.
The sequence feature has a timeout as well, accessed through the properties. If the NPC doesn't receive any matches within the timeout timespan, it will reset back to index 0 (this so that it doesn't get stuck and prevent other players from using it properly).
Also added a switch to make the NPC wait a short while (SpeechDelay seconds) before responding to a matched keyword.
New properties (All AccessLevel.GameMaster):
- Updating <readonly>: States if the NPC is being updated by a staff member
- Speaking <readonly>: States if the NPC is performing a speech entry
- SpeechIndex: The index of the next entry that must be matched if the Sequence property is set to true. Note to coders: this parameter is 1-based.
- Sequnce: specifies if the NPC should work in sequence mode, where all entries must be matched in order.
- SequenceTimeOut: this timespan specifies how long a NPC will wait for the next correct entry match in a sequence before resetting to 0.
- SpeechStartDelay: specifies if the NPC should wait before responding to a keyword match, or to start talking right away. The length of the delay is the same used between speech lines.
I have also added a link to the speaker's props in the configuration gump, and sequence numbers for each entry in the main gump.