Conversations

by @Pattentrick

Wouldn't it be neat, if all your entitys could have conversations with each other? Or if your hero could start an inspiring monologue before confronting the final boss? Or having something like a narration similar in style to a comic book? That sure would be awesome, but it sounds like lots of extra programming work, right? Good news, everyone! Impact++ has this feature already built in!

conversation1

Doing it with Weltmeister

Hit space while you are on the entities layer and select the conversation entity. Drag it to your level and change the height and width of it if needed. The conversation entity extends the trigger entity. So by default it will get triggered once it collides with the player. But you can modify it to check against characters and other certain types as well.

Conversations are build around the idea of steps. Each step is a text bubble that will appear above the speaker. To start with a basic conversation, add the following key value pairs to your conversation entity via Weltmeister:

steps.1.name: player
steps.1.text: Hi there!

If you collide now with the conversation entity, your player should say "Hi there!". To include another entity in this conversation, just add another step to your conversation entity and mention the name of the entity you want include there:

steps.1.name: player
steps.1.text: Hi there!
steps.2.name: rock
steps.2.text: Sorry mate, rocks can't speak.

By default conversation will auto advance to the next step after a given time. This time can be edited on the conversation entity like this:

durationPerLetter: 0.1

con2

If you define an advancing action to continue the conversation, you could also pause the game during a step. So conversations will just advance, if the player does hit the x key for example.

The conversation entity will also trigger talking and listening animations, on your participating entities, if you have defined them. The default name for those animations are listen and talk. Make sure you have specified them on your entity animSettings, if you want to use this feature.

animSettings: {
    idle: {
        frameTime: 1,
        sequence: [0]
    },
    listen: {
        frameTime: 1,
        sequence: [3,4,5]
    },
    talk: {
        frameTime: 1,
        sequence: [6,7,8]
    }
}

You could also apply a certain animation just for one step, which could be rather useful.

steps.2.animNameTalk: lookAngry

However, this is totally optional. You don't have to define extra animations to use the conversation entity.

Also the text bubble itself is, as everything in Impact++, highly customizable and has some more options to offer. You can edit the padding, change the font file or choose a different background colour to just name a few.

Don't want a conversation and rather need a comic book narration? Just use the narrative entity that came with Impact++. They narrative entity extends the conversation entity, because of that the usage is almost the same. But you don't have to define a speaker.

Confused? Take a look at this example:

steps.1.text: It was dangerous to go alone.
steps.2.text: So our hero stole a wooden sword from an old man.

Doing it programmatically

But what if you want to spawn a conversation independent from a collision. For example, when your player added an item to his inventory. In that case you could do it like this:

 // Kill existing conversation entities before
 // spawning new ones to avoid memory leaks

if( ig.game.getEntitiesByClass(ig.EntityConversation)[0] ){
    ig.game.getEntitiesByClass(ig.EntityConversation)[0].kill();
}

var textbubble = ig.game.spawnEntity(ig.EntityConversation, 0, 0);

textbubble.addStep( 'Hi there!', 'player', 1);
textbubble.addStep( 'Sorry mate, rocks can't speak.', 'rock', 2);

textbubble.activate();

Make sure to remove all other running conversations, before spawning a new one, to avoid memory leaks.

Learn More!

Conversation entity
Narrative entity
Trigger entity
Config file