|
Most cutscenes will involve some dialogue. This is achieved using the GestaltSpeak function, which combines DelayCommand, AssignCommand, SpeakString and PlayAnimation into one easy-to-use function.
#include "in_g_cutscene"
void main()
{
// Find actors
object oPC = GetLocalObject(GetModule(),"cutsceneviewer");
// Start cutscene
GestaltStartCutscene (oPC,"mycutscene",TRUE,TRUE,TRUE,TRUE,2);
// Deliver lines
GestaltSpeak (1.0, oPC,
"Now is the winter of our discontent",
NORMAL,4.0);
GestaltSpeak (5.0, oPC,
"made glorious summer by this son of York",
NORMAL,4.0);
// End cutscene
GestaltStopCutscene (10.0, oPC);
}
Note that we've increased the length of the cutscene to 10.0 seconds to give the character plenty of time to deliver his lines. One of the most common mistakes in cutscenes is to have lines flash past so quickly that you can't read them, especially if English isn't your first language. We've gone slightly overboard here, but three seconds for each of those lines would probably be about right. Just run through the cutscene in the module and see how it looks, and remember to leave slightly longer than you need to read and understand the lines, as other players won't be as familiar with the dialogue as you are and may not speak the language you wrote the dialogue in as well as you do.
To make things a little more interesting, you might want to change the animations played by the character as he speaks the lines. For example, FORCEFUL might be good for the first half of the dialogue, and ANIMATION_FIREFORGET_VICTORY2 for the second part.
#include "in_g_cutscene"
void main()
{
// Find actors
object oPC = GetLocalObject(GetModule(),"cutsceneviewer");
// Start cutscene
GestaltStartCutscene (oPC,"mycutscene",TRUE,TRUE,TRUE,TRUE,2);
// Deliver lines
GestaltActionSpeak (1.0, oPC,
"Now is the winter of our discontent",
FORCEFUL,4.0);
GestaltActionSpeak (5.0, oPC,
"made glorious summer by this son of York",
ANIMATION_FIREFORGET_VICTORY2);
GestaltActionAnimate (5.0, oPC, NORMAL,2.0);
// End cutscene
GestaltStopCutscene (10.0, oPC);
}
As you can see, we've introduced a new function GestaltActionAnimate here. This does exactly what you would expect, telling the selected character to play an animation. In this case we're playing the NORMAL talking animation for 2.0 seconds, and because it's an Action function it won't be triggered until the previous action (the victory animation) ends.
Let's give the player an audience now. Put an NPC with the tag "mycutscene_actor" into the area about 10 metres (a tile's width) away from the player's starting position. Make sure the NPC's faction isn't Hostile to the player, or they will attack each other on sight and interrupt the performance!
#include "in_g_cutscene"
void main()
{
// Find actors
object oPC = GetLocalObject(GetModule(),"cutsceneviewer");
object oFan = GetObjectByTag("mycutscene_actor");
// Start cutscene
GestaltStartCutscene (oPC,"mycutscene",TRUE,TRUE,TRUE,TRUE,2);
// Player delivers lines, then turns to face NPC
GestaltActionSpeak (1.0, oPC,
"Now is the winter of our discontent",
FORCEFUL,4.0);
GestaltActionSpeak (5.0, oPC,
"made glorious summer by this son of York",
ANIMATION_FIREFORGET_VICTORY2);
GestaltActionAnimate (5.0, oPC, NORMAL,2.0);
GestaltFace (9.2, oPC, 0.0,2,oFan);
// Move the NPC towards the player and congratulate him
GestaltActionMove (5.0, oFan, oPC,FALSE,1.0,4.0);
GestaltActionSpeak (9.0, oFan,
"That was quite a performance!",
ANIMATION_LOOPING_GET_MID,2.0);
// End cutscene
GestaltStopCutscene (12.0, oPC);
}
The GestaltActionMove line tells the game to wait 5.0 seconds, then send oFan to oPC. The FALSE lets oFan know to walk, the 1.0 tells him to stop 1.0m away from oPC, and the 4.0 on the end tells him to take about 4.0 seconds to make the movement. Once he's there he'll reach out his hand to the player and speak his line.
|