📜 ⬆️ ⬇️

Creating an editor quests and dialogues for the Unreal engine, Part 1 plugin description

image

Hello, my name is Dmitry. I create computer games on the Unreal Engine as a hobby.

At a certain stage of creating your game, it becomes necessary to write dialogues and quests. Unfortunately, the Unreal engine does not have a built-in tool for this task. Therefore, I wrote a plugin for editing quests and dialogues. As always, all sources will be provided at the end of the article.

I decided to split the article into two parts. In the first part I will describe the plugin itself and tell you how to use it. And in the second part I will talk about the technical aspects.
')
So I will go straight to the story about the plugin itself. First you need to create an asset StoryGraph. In the panel on the right you create subject objects that can be:

1) Quest - These are your quests after creating this object, it becomes possible to add a starting quest node (drag and drop is supported) to which you can already bind the phases of the quest.

2) Character - A character is an object that contains another graph within itself, this is the editor of the dialogues of this character. In addition, the character object has an external reference to an ACharecter_StoryGraph object that is a derived object from ACharecter. The character has several states: Alive (alive) and Dead (dead), these states can be considered (more on this later). ACharecter_StoryGraph switches it into these states once again. The character can receive messages from the main graph.

3) PlaceTrigger - Trigger is an interactive object that can be found on the map. It also has external references to the APlaceTrigger_StoryGraph object, which is derived from the AActor. A trigger, like a character, has a message editor inside of itself, due to which it is possible to interact with it.

The trigger has only two states active and inactive. In addition, it has several modes of operation:

UnInteractive - The trigger is inactive and you must implement the switching of its states yourself using the ChangeState Blueprint function.

Interactive - The trigger is active, when you approach it, just press the e key and it will switch to the Active state.

AdvanceInteractive - When you go to it and press e, the window for interacting with messages that are defined in the message editor opens.

Also, a trigger, like a character, can receive messages from the main graph.

4) DialogTrigger - The object I entered for the interaction of dialogs and messages with the main graph. I also have two states (Active, inactive). Switched in the character dialog editor and trigger message editor.

5) InventoryItem - Subject inventory. It may have several states that are set in properties. These states are added to the existing ones (inactive, at the level and in the inventory). The states change in the first way by selecting the subject and, in addition, they can be set in the character's dialog editor and the trigger message editor, as well as the state of the DialogTrigger. The inventory item can also receive messages.

6) Others - Items that are not related to the above, but are involved in the development of the plot. These items have no states but can receive messages and will change depending on them.

I want to note that due to the fact that the quest objects and objects that are on the map are different objects. So you can work in parallel. For example, you create a story and your friend creates a map. And when everything is ready, you can combine them.

After creating the subject matter, you can already begin to create quests. Here you need to clarify that all nodes are divided into two types, these are independent nodes that can be placed whenever you want, and dependent nodes that will appear only after creating objects that depend on them. In addition, the plugin supports drag and drop technology, so if you drag an object to the graph field, you will be prompted to create all the nodes that depend on this object.

All nodes have two types of connections: vertical and horizontal. Vertical tree is the basis of your quest, it determines its structure and order of execution. Horizontal nodes are modifiers of a specific quest phase (a phase node has both vertical and horizontal links). They can add some objects to the radar or send a message to the object, all of which will happen when a specific quest phase is activated.

So let's try to create something. First we create a quest. After that you can place the starting node of the quest. Three types of nodes can be attached to this node:

1) AddQuestPhase - Noda adds a new phase to the quest when activated.
2) GetObjectState - This node is activated when a particular subject object goes to a specific stage specified in the properties of the node. If the node is activated, it activates the node located behind it. Imagine a pipeline that originates from the starting node, then the GetObjectState node will be a valve that is closed until a certain time and does not allow water to flow further, but if it opens, the water will continue.
3) GameOver - From the name it is clear that as soon as this node is activated, the game ends.

Once you have created a “vertical” tree. You can add horizontal nodes to it, here’s their description:

1) Activate / deactivate dialog (message) - Activates or deactivates a branch of a dialog or message.
2) Active / deactive object - Activates or deactivates the object. It means that when de-activated, the object will simply disappear from the game. For example, you no longer need any object you can get rid of it, or vice versa the object will be needed at some stage of the game and that the character would not find it ahead of time, you can also activate it.
3) Cancel quest - Cancel the quest, for example, if the quests contradict each other and the character starts to perform one of them, then the other can be canceled.
4) Send Message - Send a message to the subject so that it somehow changes. The change itself is defined in Blueprinte. All external objects have an event GetMessegeFromStoryGraph that is triggered when this node is activated.
5) Add Screen Message - Display a message that the player will see.
6) Add to radar - Add an object to the radar. The object will be displayed on the radar until the quest phase to which the node is attached will be active.
7) Print quest phase on screen - Display the contents of a specific phase of the quest on the screen. It may be useful, for example, at the beginning of the game, show the character that you want from him.
8) Send message to level blueprint - Same as Send Message but sends message to blueprin level. To make this node work, you need to change the base class for level blueprint from ALevelScriptActor to ALevelScriptActor_StoryGraph.

How to change the base class of blueprints:
image

By the way, to create new levels with the required level blueprint, you can change the project settings: ProgectSettings → GeneralSettings → LevelScriptActorClass.

9) Print string - this node stands apart because it has both vertical and horizontal links. It displays a debug message so that you can test your script.

In addition to the chief editor in which quests are created, there are also auxiliary ones. This is a character editor for dialogs and a trigger editor for messages. Here is a description of the nodes used in these editors. Since they are similar, I will give a description for both of them.

1) New dialog (message) brunch - Create a new conversation thread or a new message. Each dialogue should begin with this node. It can be active and then this branch will be displayed immediately or inactive and then it will need to be activated from the beginning.
2) Dialog (message) node - The nodes of which the branch of the dialog consists of one input and several outputs (depending on the number of responses).
3) Dialog (message) end - If after the branch of the dialogue has passed to the end, it is no longer needed. Set at the end of this node, the branch de is activated and will not appear again.
4) Dialog (message) exit - Exits the dialog window.
5) Set dialog trigger - Sets the dialog trigger value.
6) Activate trigger - Noda is present only in the trigger message editor. She as you can guess activates the trigger itself.

After everything is done, you will start the game and nothing will happen, in order for the plot to start working you need to drag the StoryGraph object to the level or use the corresponding context menu item.

I want to note that at the level you can place several different StoryGraph objects. Let's say in one place all the main quests, and in the other all additional or even each quest to put in a separate object.

In the next article I will talk about the technical aspects, and about the problems that I had while creating a plug-in.

The second part of:
Creating an editor quest and dialogs for the Unreal engine: Part 2 technical aspects

→ Here are the sources

And if you want to just play the demo (its plot can be seen in the first picture), then you can download it here .

Control in the game is standard:

i - inventory
j-journal
f - view switching


PS A little not obvious point: the quest becomes active when the first phase is added to it. And if the execution reaches the end of one of the branches, then the quest is considered completed.

PPS The ability to save and load has been added to the project (keys [- save,] - load).

Update: Added export to XML file and import from XML.

Source: https://habr.com/ru/post/318366/


All Articles