Talking and Messages
See also:
These are the options:
- talking
- when you bump into a char
- as a looping event (a la Zelda telling you she is in the Castle)
- messages
- when you bump into object/item
- bump into a sign
- visit area – e.g it happens automatically…
- particular events
- on a looping timer
Talking and messages
see also Talking and messages – two approaches
The system allows for bumping into a person, then pressing enter to talk – they will also say different things depending on the circumstances – e.g. if you have completed a task, they will say something that reflects/responds to that…
Scenarios
The scripts can have multiple ‘scenarios’, based around the story flag system (see Story Flag system)
The list of story flags to check can be as long as you want – e.g. multiple conditions need to be met…
required: ["TALKED_TO_ERIO"],
For testing the game, you can set a bunch to true, so it saves running through too much of the game, you can just get to where you want quickly…
Parameters:
- type – required to choose the correct event type
- text – what to say – this is what will comfortably fit in a box. More need to be made if there is more to say.
- faceHero – npc will face hero when triggered
The data:
from OverworldMap.js
{type: "textMessage", text:"I'm busy...", faceHero: "npcA"}
from Overworld.js
{type: "textMessage", text:"This is the very first message!" }
The code:
in OverWorldEvent.js
textMessage(resolve){
if(this.event.faceHero) {
const obj = this.map.gameObjects[this.event.faceHero];
obj.direction = utils.oppositeDirection(this.map.gameObjects["hero"].direction);
}
const message = new TextMessage({
text: this.event.text,
onComplete: () => resolve()
})
message.init( document.querySelector(".game-container") )
}
Talking and messages – two approaches
See also Talking and messages
Creating Pizzas for the Lineup! Pizza RPG Ep. 14 (5:22)
OPTION 1 – from within OverworldMap.js
The way where there is a lot configured, and lots of flexibility (in the OverWorldMap.js)
This offers the greater level of individuality to characters etc… – I think this is the better solution – then can bring in flavour for each location as well…
talking: [
{
events: [
{type: "textMessage", text:"Bahaha!", faceHero: "npcB"},
{type: "addStoryFlag", flag: "TALKED_TO_ERIO"}
//{type: "battle", enemyId:"erio" }
]
}
]
OPTION 2- from within the custom object class file (PizzaStone.js)
Where all instances of the item are the same (like the pizza stone – in PizzaStone.js
This is supposed to be the easier way – but I am not sure where, in my game, I would have EVERY instance have the same message…
this.talking = [
{
required: [this.storyFlag],
events: [
{ type: "textMessage", text: "You have already used this."},
]
},
{
events: [
{ type: "textMessage", text: "Approaching the legendary pizza stone..."},
{ type: "addStoryFlag", flag: this.storyFlag}
]
}
]