Ask Tell Dynamic Dialog

Ask/Tell Dynamic Dialog and Dynamic Behaviour have been made free! I now feel like these assets are more of a coding style than anything else, something that needs to be taught not bought.

I will also be posting some tutorials and an article all about this style of programming, which is applying Scriptable Object Architecture to conditionals.

This allows easy implementation of fuzzy pattern matching, dynamic and fuzzy state machines and behaviours, separation of data and logic, extendable Ai and allows behaviours to be created and implemented right in the game engine, even by non programmer users.

This is the Ask Tell Dynamic Dialog Asset for unity, it is for creating dynamic dialog in your games.
This is a treeless dialog system, dialog is selected during run time based on a best match approach. the input is based on an Ask/Tell input system. I made the replies all condition based like the bark system in left4dead. Combining those two systems creates a simple to use dialog system you can add to your games. This system uses a simple fuzzy pattern matching system involving conditions, conditions have a verify method that returns a bool, so they can be almost anything. For example if you want characters to say something different depending on if it's day or night, you would create an IsDay condition script, then you create a scriptable obejct instance of it by right clicking and selecting it in the create menu. After creating the instance you add the IsDay condition to the list of conditions on the dialog you want it to affect. That dialog will not be selected unless it's day, to make an IsNight condition you just create another instance of the IsDay script and just check the inverted checkbox. if you want them to say stuff based on if you said something else before you can make that a condition. A lot of conditions and good writing could lead to dynamic, lifelike NPCs. There are a lot of conditions defined already to get you started but you can extend and add in any condtion you could need.
Running the demo project will show you it in action while teaching you more about it.

Conditions

Condition is an abstract class inheriting from ScriptableObject, this means that all conditions are scriptable objects. Conditions have two boolean variables isTrue and inverted, and one method bool Verify(GameObject p_gameObject). You can make a condition for having low health or possessing a particular item, make one for the time of day or anything relavant to your game.

Create Condition Script

To make your own custom conditions you need to make a new script that inherits from condition and the virtual Verify method must be overridden, that is where you code your condition.
To create a new condition script you make a new C# script and change it from inheriting from MonoBehaviour to Condition. This makes it a Condition and also a Scriptable Object. You must add a create asset menu header to allow you to create an scriptable object instance.
[CreateAssetMenu(fileName = "new Condition", menuName = "ScriptableObjects/Conditions/YourConditionName")]
where YourCondtionName is the name you want to use to select this condition from the create menu.

The Condition must override the the virtual method bool Verify(GameObject p_gameObject) in this method is where you put your code for varifying the condition, setting the isTrue bool, and it must return isTrue.

To allow conditions to be inverted you must add in the lines: if(inverted) isTrue=!isTrue; right before you return isTrue. That will allow you to set the inverted bool in the inspector to invert your conditions so you do not need to make opposite conditions.

Create Condition ScriptableObject instance

To make a new condition from an existing script just navigate to the folder you want to keep your scriptable objects in, then right click right click in the project window and select Create, then ScriptableObject, then Condition, then pick the condition you want to create from the list, then you just need to name it. You can invert the condition by selecting inverted in the inspector.

Drag Condition into Condition List
Dialogs all have condition lists attached to them. Go in the inspector and expand Conditions if needed you select how many conditions you want then drag and drop the conditions in the slots.


Dialogues

Dialog is an abstract class that inherits from ScriptableObject and contains a string used for a line of dialog. Dialogs are for player input and come in two types questions and statements.
Questions are for asking and Statements are for telling. To make a new question or statement just right click in the project window and select ScriptableOject from the menu and then Dialog and then Question or Statement. Then you just need to name it and fill in the text. They can both generate a reply.

Question
Questions inherit from Dialog. You can make an instance of Question and add to your player's Questions list.

Statement
Statments inherit from Dialog. You can make an instance of Statement and add to your player's Statements list.


CoversationAgent
This is the MonoBehaviour used to house all the componants. A ConversationAgent has a list of Replies a list for short term memory and long term memory. It also contains a few methods for managing it all.

Short Term and Long Term Memory
Short term and long term memory are both just a list of dialogs. Short term memory takes care of the current conversation and long term memory is where short term memories are sent after conversations. Using conditions you can make use them to create interesting conversations.. like you could have an npc say one reply when asked a question, and another reply if asked the same question for a second time, or if they made a particular statement earlier in that conversation.

Replies
Reply is an abstract class that inherits from ScriptableObject and contains a string used for a line of dialog. Dialogs are for NPC output in repsonse to player input, or lack of input if using timebased input. You can make an instance of Reply and add to your NPC's Replies list.
Replies have a list of conditions which must be met to for the reply to be selected. The list of replies is sorted by the most conditions to ensure the most appropriate reply is selected.
To make a new reply just right click in the project window and select ScriptableOject from the menu and then Reply. Then you just need to name it, fill in the text and the conditions. All replies should have at least one condition except for one default reply, if needed.

GetReply
GetReply is the method that selects the appropriate reply by comparing each conditions of a reply and executing the 1st successful match.