Cutscenes: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
No edit summary
Line 29: Line 29:
''The Map''
''The Map''


Download the test map snitch1.pk4. This provides a dressed set, the two actors, a player start near some handy buttons, and a script to run the scene.
Download the file snitch1.zip. This provides a dressed set, the two actors, a player start near some handy buttons, and a script to run the scene. Extract the file contents to your




Line 37: Line 37:
[[Image:Camera1.jpg|200px|thumb|right|Camera1]]
[[Image:Camera1.jpg|200px|thumb|right|Camera1]]


Let's add the first of four cameras. Create the entity ''darkmod->func->func_cameraview'' and move it so its origin is 32 units over the top of the bush in the SE corner. ''func_cameraview'' is the camera. Give it the following key/value pairs:
Let's add the first of four cameras. Create the entity ''darkmod/func/func_cameraview'' and move it so its origin is 32 units over the top of the bush in the SE corner. ''func_cameraview'' is the camera. Give it the following key/value pairs:


"name" "Camera1"
"name" "Camera1"
Line 52: Line 52:
[[Image:target_null_1.jpg|200px|thumb|right|target_null_1]]
[[Image:target_null_1.jpg|200px|thumb|right|target_null_1]]


Camera1 needs to be told where to look. To give it a focal point, create the entity ''darkmod->base->target_null'' and place it near the center of the billboard. Give it the following key/value pairs:
Camera1 needs to be told where to look. To give it a focal point, create the entity ''darkmod/base/target_null'' and place it near the center of the billboard. Give it the following key/value pairs:


"name" "target_null_1"
"name" "target_null_1"
Line 123: Line 123:


''$Camera1.activate($player1)'' deactivates the camera, returns control to the player, and paints the screen with the player's POV.
''$Camera1.activate($player1)'' deactivates the camera, returns control to the player, and paints the screen with the player's POV.
[[Image:target_callscriptfunction.jpg|200px|thumb|right|Roll1]]
Now, how do we run this function? Find the ''info_player_start'' in the SW corner of the map. Next to it you'll see three buttons with three yellow cubes above them. Each cube is a ''darkmod/targets/atdm:target_callscriptfunction'' entity. Each button is targeted to activate one of these entities, which, in turn, calls a function in the script file.
The leftmost ''target_callscriptfunction'' has these key/value pairs:
"name" "Roll1"
"call" "Roll1"
So when you push the leftmost button, it triggers Roll1, which calls Roll1().
''Looking at the results''
We're ready to try this out.
Save the map, build it, and run it.
When the map starts, both actors will begin walking toward the billboard. Once they've reached it, press the leftmost button on the wall to your right. Camera1 should take over and paint your Master Shot on the screen for 13 seconds. When it's finished, control returns to you. Pressing the other two button will do nothing at this point.

Revision as of 18:19, 1 September 2010

Intro

This article discusses the use of cameras and conversations to create map cutscenes.

Though information on these topics already exists (see Resources below), there isn't a single place that shows you how to create a scene using these technologies.

Hopefully, the following will fill in that gap.

The information is presented in 5 parts:

Part 1 - Camera creation, pointing the camera, starting and ending a shot, changing cameras, and the infamous "cinematic" spawnflag

Part 2 - Splines, camera movement

Part 3 - Conversation, vocals, camera position, lighting, where to place the player

Part 4 - Animation, triggers, sound effects, objectives

Part 5 - A step-by-step breakdown of the Somewhere Above the City cutscene

Each part includes a (small) map which you can edit to test things.

The Scene

In the scene we'll be creating, a City Watch guard is meeting an informant to hear about an upcoming bank heist. The script is simple: the two actors walk onstage, talk, and depart. The map is called Snitch.

Part 1

The Map

Download the file snitch1.zip. This provides a dressed set, the two actors, a player start near some handy buttons, and a script to run the scene. Extract the file contents to your


Camera Creation

Open the map snitch1.map in Dark Radiant. In this map, center stage is the billboard on the north wall (+Y direction) of the courtyard. The two actors wait offstage, the guard at the end of a hallway to the NE, the informant on a porch to the West.

Camera1

Let's add the first of four cameras. Create the entity darkmod/func/func_cameraview and move it so its origin is 32 units over the top of the bush in the SE corner. func_cameraview is the camera. Give it the following key/value pairs:

"name" "Camera1"

"trigger" "1" (this camera will work when triggered)

"cinematic" "1" (this entity will move during filming)


When setting up any scene, you should first present a Master Shot to give the player a sense of where the scene is taking place. Is it in a dining room, in an alley, on the roof of a Builder cathedral? Camera1 will be our Master Shot camera, pulled back enough to present the courtyard and show where our scene is taking place.


Pointing the Camera

target_null_1

Camera1 needs to be told where to look. To give it a focal point, create the entity darkmod/base/target_null and place it near the center of the billboard. Give it the following key/value pairs:

"name" "target_null_1"

It's a good habit to use matching numbers in your camera/target pairs if you'll be using multiple cameras in a scene.

To point the camera at its target, give Camera1 the following key/value pair:

"target" "target_null_1"

For a standing shot, this is all you need to do on your map.


Starting and ending a shot

Camera control is done through scripting. Let's look at the script that controls Camera1. Open snitch1.script, which sits alongside snitch1.map in the maps folder.

If you haven't worked with scripts before, here's an overview of the file:

#ifndef __SNITCH_SCRIPT__
#define __SNITCH_SCRIPT__

void Roll1()
{
   ...
}

void Roll2()
{
   ...
}

...

void main()
{
}

#endif /* __SNITCH_SCRIPT__ */

The #ifndef, #define, and #endif directives prevent this script from being included more than once.

main() is a function (program, routine) executed once at the start of your map. Use it to initialize script-based activities.

Each RollN() is a function to be executed at some point as the player plays your map.

For snitch, we'll be controlling each camera with a seperate script function in this file.

So, Camera1 will be controlled by the function Roll1():

void Roll1()
{
   sys.println("Roll1 running"); // debug

   $Camera1.activate($player1);  // Switch view
   sys.wait(13);		 // duration of view

   $Camera1.activate($player1);  // Return control to player
}

sys.println() prints a text line to the console. This is useful when you're unsure whether a particular function is executing or not.

$Camera1.activate($player1) triggers Camera1. $Camera1 is the name of the entitiy, activate is what you want it to do (in this case, trigger), and $player1 is the name of the entity triggering it. Triggering a camera removes control from the player and paints the screen with whatever the camera is looking at.

sys.wait(13) says to wait 13 seconds. So our shot is 13 seconds long.

$Camera1.activate($player1) deactivates the camera, returns control to the player, and paints the screen with the player's POV.

Roll1

Now, how do we run this function? Find the info_player_start in the SW corner of the map. Next to it you'll see three buttons with three yellow cubes above them. Each cube is a darkmod/targets/atdm:target_callscriptfunction entity. Each button is targeted to activate one of these entities, which, in turn, calls a function in the script file.

The leftmost target_callscriptfunction has these key/value pairs:

"name" "Roll1"

"call" "Roll1"

So when you push the leftmost button, it triggers Roll1, which calls Roll1().


Looking at the results

We're ready to try this out.

Save the map, build it, and run it.

When the map starts, both actors will begin walking toward the billboard. Once they've reached it, press the leftmost button on the wall to your right. Camera1 should take over and paint your Master Shot on the screen for 13 seconds. When it's finished, control returns to you. Pressing the other two button will do nothing at this point.