Update NPC Dialog authored by Ktyal Plummer's avatar Ktyal Plummer
no way..
\ No newline at end of file
**Overview:**
The dialogue system works based on a tree structure where each node in the tree represents a dialogue option. By giving each node a `pattern`, which is the regular expression the NPC searches for in the message it receives. A `node-id` which allows nodes with the same id to be grouped together. A `target-node` which tells an NPC where to look next after receiving a response.
![bestdiagram](uploads/aa59485c5735060ab80cd7613b9dd51c/bestdiagram.png "Dialogue Tree")
By follow the messages sent in this diagram you can see how the NPC searches for the pattern in the message (highlighted in red) and where it goes after receiving that message.
**Creation:**
<details><summary>Creating the XML</summary>
The layout of the XML is fairly simple
```xml
<NPCInfo>
<DialougeTree>
<!-- Where the dialouge nodes will go -->
</DialougeTree>
</NPCInfo>
```
The `NPCInfo` tag will encompass all of the information an NPC needs
The `DialougeTree` tag is used specifically for dialogue nodes
</details>
<details><summary>Adding a new dialogue node</summary>
All dialogue nodes are surrounded by the `Dialogue` tag
Within the `Dialogue` tag is the `message` tag which holds the message to be outputted if the requirements for that node are met
```xml
<Dialogue pattern=".*pattern*." node-id="start" target-node="BranchOne">
<message>This right here is what the NPC will say</message>
</Dialogue>
```
**Attributes:**
`pattern`: the regular expression used to match a received message with this particular dialogue node
`node-id`: used to identify which grouping this dialogue node belongs to
`target-node`: used to update the `currentTarget` variable in the code so the NPC knows where to search for the next dialogue node
Adding the node to the XML:
```xml
<NPCInfo>
<DialougeTree>
<Dialogue pattern=".*pattern*." node-id="start" target-node="BranchOne">
<message>This right here is what the NPC will say</message>
</Dialogue>
</DialougeTree>
</NPCInfo>
There is no limit to how many nodes you can have within the dialogue tree
```
</details>
INFO POOL:
The dialogue portion of the XML is a series of dialogue nodes that each contain a: pattern: Is what the NPC will be listening for node-id: If current node matches node-id this will be one of the dialogue nodes that it will check when it receives a report, if not it will skip this dialogue node. This is the way "levels" of dialogue are made. target-node: This is what it will set the current node to be if the pattern matches what the player said. message: What gets put into chat if the players message matches the pattern.
The dialogue works on a "levels" system where there is a current node which holds a String representing what level you are on. When on a particular level the behavior will only check dialogue nodes with that level as its node-id. So to begin with the current node defaults to "start", so the dialogue node you wish to start with should have "start" as its node-id, and if pattern is set to "" it will run this node with whatever the player says. When the behavior runs a node it will send a chat message with the contents of "message" and then set the current node to target-node.
Each dialogue node should follow this pattern:
```java
<Dialogue pattern=".*pattern*." node-id="start" target-node="BranchOne">
<message>This right here is what the NPC will say</message>
</Dialogue>
```
Something about dialogue timeout
\ No newline at end of file