NPC text speech automatism

This is something that is a complete pain in the arse to do in construct2. And if you look at their forum- it has been requested many many times but none of the solutions is really useable for a serious project. They are all hacked in solutions with huge disadvantages.

For that reason they are lacking a bit in action rpg games or adventure games. In general it is hard to do any story games there. :unamused:

So without further adeu, I wish gamedevelop had a way to easily create speech text boxes that can be triggered by a mouse click/hover (for adventure games) or by standing next npc (rpg NPCs). They can be controlled via the event sheet logic, used in the object properties as automatism to load external text files for each individual NPC.

How would that be designed? I am not sure.
They could load an external text file (good for localization!)
It would be nice to be able to tell it to change speech avatar (optionally) and even depend on some sort of variables what the npc says.

-Text object type could be made more complex- with the ability to contain avatar data, skin data, variable condition (much like how rpg maker does it).

  • it could be an automatism, which lets you quickly gain fine control over the speech bubble with absolute minimum code.
  • the automatism could allow you to load the text from a text file that is an external resource (localization). The text file could contain some basic syntax that the automatism can understand right away. The syntax could borrow from AGS or RMXP ideas- to determine when to change to next text slide during conversation, when to show an avatar from an animated sequence, when to put text in bod or italics, when add an icon symbol to cheaply show emotion, etc etc. All the stuff that rmxp can do extremely easily.
  • As a final extra- a special editor can help the user not have to learn the syntax.
  • Where do you store the automatism? similar to rpg maker , it makes sense to store it in the object that triggers the event. Or it can be stored inside the text object type. Or it can be a new object type instead of an automatism.

One could look at how it is done in
AGS (for adventure games)
RPG maker (for rpg games) - probably the best place to look for inspiration- as that feature is the engine’s bread and butter

What are the advantages of story games:

  • it is easier to create an entertainment value through story- the reason why so many beginners start with rpg maker.
  • action adventure games are not that easy to do- especially for html5 atm. This can be a niche where GD can carve a nice cosy place for itself. :smiley:

What are the existing issues in text speech

  • The biggest issue is the amount of code that you must write to make one. Then reusing it. The entry level experience you must have to do it properly is pretty high. I have not seen anyone implement a dialogue system properly there or in any other html5 exporting engine that has action oriented 2d game support.
  • Localization- keeping all the npc text in external file(s) that are easy to translate/edit.
  • Ugly solutions to simple problems. For example how do you draw an avatar image next to the text. You have to hard code it in the event sheet. How do you reuse the same code for many dialogues between the player and many many different npcs or story events? it’s tough


I think it’s a great idea… but… should be hard to develop. If nobody did this, there must be a reason.

But of course, the 1st soft to have this feature, stable… should gain a lot of users :slight_smile:

It wouldn’t be hard to develop. I’ve did such thing on events in like few minutes, but I left out more advanced stuff found in RPG Maker (like pausing, changing speed of text/text color, etc.), only letter-by-letter typing.

I’d love some advanced text object that support basic markup (color, size and bold/italic/underline) along with automatism that accepts RM tags (\v[VariableName] would put variable’s value in place of it, \c[#RRGGBB] would change color, \p[frames] would pause text writing for “frames” number of frames, \s[delaybetweenletters] would change general speed of typing by changing delay between letters (in frames), etc.).

It is also important to mention that a full featured NPC system should also include:

-ability to add choices which trigger non linear path for the dialogue
-dialogue that is triggered being affected by a variable condition.

Possible design approach to this
So in the speech syntax you need to be able to write more than one potential dialogues you can have with that npc and trigger one of the dialogs depending on the NPC’s automatism instance variable “dialog ID”.

The dialogID variable can then be controlled via two routes:

in the event sheet (for global life changing story events)
in the actual dialog syntax (so you can have the npc say another thing when you trigger conversation for the second time or have choices affect dialogue)

If dialogID=0, then that conversation is disabled completely
If dialogID=1, then npc triggers conversation in block 1 of the npc text file
If dialogID=2, then npc triggers conversation in block 2 of the npc text file
and so on. The dialogID variable can be used to control dialogue flow based on player choices. For example in the speech syntax you can say

“what would you answer?”
“-yes” <goto.dialogID=3>
“-no” <goto.dialogID=4>

It can also be used as a condition in the event sheet- to check the “mental” state of a specific npc and affect special events, such as it’s movement, unlocking doors, giving special items, or teleporting the player to a new area.

So to sum it up, the theoretical workflow is as follows:

  1. Attach “NPC text” automatism to the sprite you want to use as an npc (be it an item in the game to check out, a speaking character, or anything that triggers text to appear)
  2. In the event sheet- define how the player triggers the NPC automatism- you can also be more specific and have more than one ways to trigger it based on which object group the sprite is put in.
  3. In the Object properties automatism you get at least these 2 things to define:
    -the speech text (external) resource it is going to use. Ask to create a new one if none is defined.
    -dialogID variable- defining the current text block (for debugging) and the initial text block.

4.Finally you select the npc.speech text resource from the project management panel- you can open to edit it (with any text editor)
When you open a vanilla one, you get information as to how the syntax works in a code uncommented field
//This file defines conversation data. Different conversation interactions are stored in individual blocks. The syntax is as follows
//<set.dialogID> sets the dialog block that the player will take with the npc on next interaction. (use at the end of conversations)
//<goto.dialogID> triggers a new conversation block during current conversation (use for choices like yes and no)
//the | symbol splits conversation into speech slides. Use it to logically define when the text box refreshes it’s contents.If you dont use it,
//the automatism will split it automatically.
// ==dialogID1== or ==dialogID2== (and so on) defines a new conversation block start and it’s trigger dialogID number.
// ==== ends it.
…and so on. Look at syntax in other engines for examples.

I know this is just theory, but if I had better skills and understood the code- thats how I would have done it. :smiley:

If writing syntax is an ugly solution, you could make a dedicated “story editor” that lets you edit “*.npc” project resource text files without having to know the syntax. But you can also open them in any external text editor- for translators who don’t have the engine.

Other possible new adopters of gamedevelop
There is currently a big demand for rpg maker clone that is
a) free
b) can run on linux and/or compile games for linux and other devices

Just google this … e&ie=UTF-8
You’d get a lot of request threads at the rpg maker forums, a lot of non-functional or half-functional rpg maker clones.
There is big demand that is not met.

Granted, this engine will probably never be completely suited for a traditional jrpg system, but having at least the “story” tools to enable these users- gamedevelop will fit nicely with another potential client group that is hungry at the moment. It will enable them to tell stories as part of a more flexible gameplay. Making this engine perfect for action adventure/rpg games.

Sorry I am bumping this again.
For some reason the thought of researching how it can be done in different engines won’t let me.

One of the Indie humble bundles got me a multimedia fusion 2 license for very cheap. So I have been playing with it. And found out a very interesting and easy way to do basic NPC dialogue in an engine that is not specifically designed for that.

here is a video (not by me)

and here is the source file (not by me)

Now if you dont have MMF2 lying around, here is how it can be copied from the example:

1- define the global logic of how dialgue is triggered and controlled in the event sheet (how do you start it, what button do you press to trigger the next string of text to fill the box, what happens to the player while the dialogue is on-get the ID number of the string that is currently displayed)

  1. Store the NPC dialogue in an automatism that can be attached to any event (npc). The automatism allows you to attach to it any number of specialized string variables.

So to sum up - here is a simpler system than the previously proposed one!

NPC Actions:
Set NPC string ID to Use this action to control the NPC automatism logic. It is set to 0 (off) by default. Setting it to 1 starts the Automatism and sets it to the first string of dialogue. You can also add 1 to this variable each time a button is pressed- in order to let the player trigger the next text message after being done reading the first one.

Set text object to NPC active string - The NPC automatism doesn’t have to take care of displaying it’s active string value. Instead use this command to make any text object display the currently active text string from the NPC automatism.

NPC Conditions:
NPC string ID= - 0(off - the npc is currently inactive), 1(string 1 is currently displayed), 2(string 2 is currently displayed) and so on.
Having the ability to test the currently displayed npc string would allow you to do things to the player or the npc, or the game in general while the a specific string of text from the automatism is displayed.

The NPC string is in the core of this automatism.
After attaching the NPC automatism to any object, the programmer can add any number of “npc strings” to it.
Each string he/she adds holds a number (1,2,3,4,5- depending on it’s creation order) and text ( the actual dialogue to be parsed ).
Here is how the NPC automatism properties can look like:

(edited a screenshot from MMF2)
For debug purposes, there should also be the “active NPC string” value visible in the properties of the automatism.

This should allow choices, actions in the game while having the conversation- for cut scenes, full control on how it is triggered and displayed.
You can even add an “avatar” value to NPC string rows too- but that is an extra feature.
For the npc to work, you will need another condition block - “NPC avatar” in order to control in the event sheet how this avatar looks like and is rendered.

This really looks like a mini array, doesnt it :smiley:

Cheers, that is the best I can think of for now