Scripting Cheatsheet

Revision as of 17:01, 28 June 2024 by Frostbyte (talk | contribs) (Add to tutorials category)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is a cheat sheet of some of the most common actions and effects for actors to perform in a cutscene. Some of the things explained in this page include: how to make an actor move, how to make them talk, how to make them emote, change animation, etc.

If you want to test this yourself, make sure that you copy ALL of the lines required. For example, if you wish to change the animation of a character, you need the with statement, and the SetAnimation code, as well as the line underneath it. You also cannot put multiple actions in a with statement. You must put a new with statement for every command that requires it.

All these actions should go inside a def statement, like so:

def 0 {
    // Code goes here...
}

Dialogue

Format: ACTOR, Emotion, position of the portrait. Standard position is bottom left.

message_SetFace(ACTOR_PLAYER, FACE_SURPRISED, FACE_POS_STANDARD);
message_Talk({
	english=" Make sure you copy all 4 lines!",
});

When you are having dialogue between multiple characters, make sure you put this code at the end of each character's dialogue! It is not necessary if one character is saying multiple lines, only when the speaker changes.

CallCommon(CORO_MESSAGE_CLOSE_WAIT_FUNC);

Additionally, message_close() is also a good tool. It will not allow the game to progress until you close the text box. The only difference between this and CallCommon(CORO_MESSAGE_CLOSE_WAIT_FUNC); is that the CallCommon code has a built in wait function, where the game won't progress for a few frames after you clear the text box, message_Close(); does not have this wait inside it.

message_SetFace(ACTOR_PLAYER, FACE_SURPRISED, FACE_POS_STANDARD);
message_Talk({
	english=" Make sure you copy all 4 lines!",
});   
message_Close();

IMPORTANT: You must use either one of these codes if you are having some sort of action after a character speaks. For example:

// Here, the character will not move until you clear the text box
message_SetFace(ACTOR_PLAYER, FACE_SURPRISED, FACE_POS_STANDARD);
message_Talk({
	english=" Make sure you copy all 4 lines!",
}); 
message_Close();  
with (actor ACTOR_PLAYER) {
	MovePositionMark(1, Position<'m0', 31.5, 28>);
}

// Here, immediately when the dialogue ends, the character will move WITHOUT closing
// the textbox and it will look very strange. include message_Close() when you are
// having actions at the end of a dialogue!
message_SetFace(ACTOR_PLAYER, FACE_SURPRISED, FACE_POS_STANDARD);
message_Talk({
	english=" Make sure you copy all 4 lines!",
});   
with (actor ACTOR_PLAYER) {
	MovePositionMark(1, Position<'m0', 31.5, 28>);
}

Keep in mind if the actor, emotion, and position is the same for multiple lines of dialogue, you do not need to put another message_SetFace.

message_SetFace(ACTOR_PLAYER, FACE_SURPRISED, FACE_POS_STANDARD);
message_Talk({
	english=" Make sure you copy all 4 lines!",
});
message_Talk({
	english=" Otherwise it wont work!",
});
CallCommon(CORO_MESSAGE_CLOSE_WAIT_FUNC);
message_SetFace(ACTOR_ATTENDANT1, FACE_INSPIRED, FACE_POS_BOTTOM_R_FACEINW);
message_Talk({
	english=" Understood! I will!",
});
CallCommon(CORO_MESSAGE_CLOSE_WAIT_FUNC);

Misc. Dialogue functions

[W:30] Will make the dialogue pause for 30 frames (half a seoond) until continuing on its own.

The value can be any amount of time you want! 60 frames is one second.

[K] will pause dialogue until player makes an input. Good for multiple sentences in one text box!

message_CloseEnforce(); Will force the text box to close when it is completed. You can put a [W:30] at the end of your dialogue too! This way the dialogue will complete, then give the player a short window to read the dialogue until it closes on it's own.

To put dialogue on a new line, use /n. Let's put it all together!

message_SetFace(ACTOR_PLAYER, FACE_HAPPY, FACE_POS_STANDARD);
message_Talk({
	english=" Make sure you copy all 4 lines! [K]\nIt\'s important to get them all! [W:45]",
});    
message_CloseEnforce();
// Some scary sound effect. Will cut off the dialogue due to message_CloseEnforce.
Wait(30);
message_SetFace(ACTOR_PLAYER, FACE_SURPRISED, FACE_POS_STANDARD);
message_Talk({
	english=" Wahh!!! [W:20]What was that?!",
});        
CallCommon(CORO_MESSAGE_CLOSE_WAIT_FUNC);
// Here, the game will stop at [K] until you hit an input, then say the second sentence, then
// wait for 45 frames after it completes. It will then immediately close the text box. 
// Then it will wait 30 more frames, before playing the second dialogue.

What if I want no portrait? Easy! Just use message_SetActor()! This will remove the portrait and only show the speaker name.

message_SetActor(ACTOR_PLAYER);
message_Talk({
	english=" You can\'t see me!",
});

What if I want NOTHING?  

For an unknown speaker, use message_ResetActor()! This will include no portrait and no name.

This is great for an unseen speaker!

message_ResetActor();
message_Talk({
	english=" You don\'t know me!",
});

Movement

There are two types of movement codes. MovePositionMark, and MovePositionOffset. Mark will make the character walk to the position on the map stated, while offset will make the actor walk a certain distance from where they are currently standing.

For example, this code will make the player move to X: 31.5, Y: 28. While not required you should have m0 increase by one everytime you use this code. m0, m1, m2, etc.

1 is the speed of the walking. Increase it to increase the speed.

with (actor ACTOR_PLAYER) {
	MovePositionMark(1, Position<'m0', 31.5, 28>);
}

MovePositionOffset is better when you want an actor to walk a certain distance from where they currently are in the cutscene. Keep in mind, this is done through pixels, not units.

A unit is 8 pixels.

In this code, PLAYER will walk one unit to the left (X), and two units down (Y). 1 is speed.

with (actor ACTOR_PLAYER) {
	MovePositionOffset(1, -8, 16);
}

Lastly, if you want the character to move without changing direction, you can slide! SlidePosition is great if you want a character to take a step back, side step, etc. since they will remain facing the same direction while they move.

with (actor ACTOR_PLAYER) {
	SlidePositionMark(1, Position<'m0', 12, 45>);
}

with (actor ACTOR_PLAYER) {
	SlidePositionOffset(1, 36, -24);
}

One last VERY important thing to learn is WaitExecuteLives. This code will not progress the game, until the character in question completes their action. Whether that be moving, animating, rotating, etc.

// Here, the game will not continue to the next dialogue UNTIL Player finishes moving.
with (actor ACTOR_PLAYER) {
	MovePositionMark(1, Position<'m0', 12, 45>);
}
WaitExecuteLives(ACTOR_PLAYER);
message_SetFace(ACTOR_PLAYER, FACE_HAPPY, FACE_POS_STANDARD);
message_Talk({
	english=" I\'ll wait until I\'m done walking\nto talk!",
});

Rotation

Value 1 is the speed, 4 is generally the normal speed.

Value 2 is the turning direction. 10 will turn the actor the direction that is the shortest to get to the desired direction.

0 will always turn the character clockwise, 1, will always turn them counter=clockwise

Third value is DIR_DOWNRIGHT, DIR_UP, DIR_UPLEFT, etc. Whichever direction you want.

with (actor ACTOR_PLAYER) {
	Turn2Direction(4, 10, DIR_DOWN);
}

You can also use Turn2DirectionLives to make an actor turn and look at another actor!

with (actor ACTOR_ATTENDANT1) {
	Turn2DirectionLives(4, 10, ACTOR_PLAYER);
}

Effects

These should be self explanatory. Just use the code listed to make the character have a question mark above their head, sweat, shocked, etc. These codes will also halt the game from continuing until the effect is completed. Sound effects are included as well!

// Question Mark?
se_Play(8962);
with (actor ACTOR_ATTENDANT1) {
	SetEffect(EFFECT_QUESTION_MARK, 3);
}
with (actor ACTOR_ATTENDANT1) {
	WaitEffect();
}
WaitExecuteLives(ACTOR_ATTENDANT1);

// SHOCKED
se_Play(8968);
with (actor ACTOR_ATTENDANT1) {
	SetEffect(EFFECT_SHOCKED, 3);
}
with (actor ACTOR_ATTENDANT1) {
	WaitEffect();
}
WaitExecuteLives(ACTOR_ATTENDANT1);
    
// Two arrows
se_Play(8978);
with (actor ACTOR_ATTENDANT1) {
	SetEffect(EFFECT_TWO_ARROWS_AT_SIDE_LEFT, 3);
}
with (actor ACTOR_ATTENDANT1) {
	WaitEffect();
}
WaitExecuteLives(ACTOR_ATTENDANT1);

// Exclamation Mark!
se_Play(8974);
with (actor ACTOR_ATTENDANT1) {
	SetEffect(EFFECT_EXCLAMATION_MARK, 3);
}
with (actor ACTOR_ATTENDANT1) {
	WaitEffect();
}
WaitExecuteLives(ACTOR_ATTENDANT1);
    
// Sweat Drops both sides
se_Play(8972);
with (actor ACTOR_ATTENDANT1) {
	SetEffect(EFFECT_SWEAT_DROPS_FROM_BOTH_SIDES_MEDIUM, 3);
}
with (actor ACTOR_ATTENDANT1) {
	WaitEffect();
}
WaitExecuteLives(ACTOR_ATTENDANT1);
    
// Tear drop
se_Play(8961);
with (actor ACTOR_ATTENDANT1) {
	SetEffect(EFFECT_SWEAT_DROP, 3);
}
with (actor ACTOR_ATTENDANT1) {
	WaitEffect();
}
WaitExecuteLives(ACTOR_ATTENDANT1);

These next ones are special as they will remain until you turn them off. The others above will disappear after they are done. So make sure you turn these off when you want them to using the code below! Note: Laughing and Joyous do not use sound effects.

// Anger
se_Play(8971);
with (actor ACTOR_PLAYER) {
	SetEffect(EFFECT_ANGRY, 3);
}
    
// Joyous
with (actor ACTOR_PLAYER) {
	SetEffect(EFFECT_JOYOUS, 3);
}

// Laughing
with (actor ACTOR_PLAYER) {
	SetEffect(EFFECT_LAUGHING, 3);
}

// Turn off/No effect
with (actor ACTOR_PLAYER) {
	SetEffect(EFFECT_NONE, 3);
}

Music

Very simple. The codes you will use most is the bgm_PlayFadeIn and bgm_FadeOut.

/First value is the song name.

Second value is the amount of frames you want the game to take to fully fade in the song.

Remember, 60 frames per second! If the value is 0, it will play the song at full volume immediately without fading at all.

Third value is the volume. This should pretty much always be 256 which is the max.

bgm_PlayFadeIn(BGM_THROUGH_THE_SEA_OF_TIME, 0, 256);

To stop the music, you can fadeout the music, or stop it immediately.

bgm_Stop(); //Immediate stop
bgm_FadeOut(60); //Will fade out for a durration of 1 second

Camera movement

To move the camera, use this code. Works the same as moving an actor.

with (performer 0) {
	MovePositionMark(33152, Position<'m3', 31.5, 32>);
}