RDNWiki: DOWMissionEditor/Tutorials/RdnTutorialNisAndIe ...

RDN Wiki Home | Page Index | Recent Changes | Recently Commented | Users | Registration | Login:  Password:  

NIS an IE Tutorial


Contents

Introduction

In this tutorial we will add some non-interactive (NISes) and IE (intel events) to the missions that we've been working on. While we’ve setup the functions already, we haven’t filled them in. The purpose of this tutorial is to get you familiar with the system, how it works and how you can use it. As before we’ll be following the SCAR template document when it comes to formatting this .nis files. This means that
The first thing that you should note is that the NIS/IE system is based on the idea of linear progression. That is one action following another. The control scheme that allows this is a controller table called CTRL. While the details of how this works are unimportant, just keep in mind that NIS/IE scripting is slightly different from mission scripting.

NISes and IEs


Non Interactive Sequences

Non-Interactive Sequences (NISes), along with the pre-mission briefings are the medium through which the single-player story is told. As you have seen setting up the pre-mission briefings is a fairly simple process. Working with NISes and getting making them work perfectly, is a little bit more complicated.


A word of warning before we start, the NISes use the internal commands of the game, and the game engine itself to tell the story, they thus heavily rely on similar commands that you use when you play the game. Many of these commands are non-deterministic, meaning that when creating your you may encounter times when the plays slightly differently then the previous iteration you saw, this is normal, however, it may sometimes lead to headaches and long hours spent trying to force the system to do what you want it to do. Basically creating NISes is all about twisting the arm of the game engine. Often while you may have a vision of an event and want it to happen in a certain way, the chances of that occurring exactlty as you had envisioned it is unlikely. Since the game engine is used, random chance, unit statiics, all play a part in how the plays out each sequence playout will be different. So all this is to say, be prepared to make sacrifices that you may not initially like. You have been warned.


Alright, now that that is all out of the way, let's get started. The sequences themselves use, as mentioned, the SCAR scripting system. However, mainly to keep the mission scar file clean they are kept within their own file with the .nis extension file. As in the SCAR template file, the first thing that we declare is the Events table:


EVENTS = {}

Which defines the EVENTS table where the NISes and IEs are stored.


In the most general way a or IE is defined as follows:


EVENTS.<nameOfNis> = function ()
{
  --  content goes here.
}

For instance, for the opening we want:


EVENTS.NIS_Opening = function()
{

-- to be filled in later in this tutorial.
}

Whenever starting an it's usually a good idea to turn off the fog of war. Thus, one of the first thing you'll do is call the FOW_RevealAll() function. It's also a relatively good idea to display the mission title at the beginning of a mission which you can accomplish with Util_MissionTitle(<missionName>). However, before you do this it's a good idea to enter letterboxed format and fade out your screen. This, is actually accomplished in the SCAR script, before starting the .


It is the following functions, that you’ve already seen in the previous tutorial that accomplish the blacking out of the screen:


EventCue_Enable(false)
Fade_Start( 0, false )
W40k_Letterbox( true, 0 )
Util_StartNIS( EVENTS.NIS_Opening )

EventCue_Enable(false) simply disables the event cue, along with all AI and vocalization features associated with events (events are such things as units under attack,etc). The second line fades the screen to black without any delay. The next command turns on letterbox mode, and the final command starts our .


Now that that's done we'll go ahead and add that FOW_Reveal command to our opening. Also, we'll disable the FOW_ReavealAll call, as well as the letterbox near the end of the. Here's what you NIS_Opening script should look like:


EVENTS.NIS_Opening = function()

FOW_RevealAll()

-- LOCATION 1 – ADDED LATER

CTRL.Event_Delay( 4 )
Util_MissionTitle("Moo")
CTRL.WAIT()

Fade_Start(1, true)

FOW_Reset()
CTRL.Event_Delay( 1 )
CTRL.WAIT()

-- LOCATION 2 – ADDED LATER

-- end 
CTRL.W40k_Letterbox( false, 2 )-- Goodbye letterbox
CTRL.WAIT()

end

But wait you say, what's with this CTRL thing. Well CTRL allows you to play a set of events in sequence. Basically whenever you call CTRL and then CTRL.WAIT(), the game will wait for the control to end before starting again. So for instance we could have something like this:


print("Yo")
CTRL.Event_Delay(3)
print("This will show up right after Yo, it will not wait for 3 seconds")
CTRL.Event_Delay(2)
CTRL.WAIT() -- execution will now delay for 5 seconds (waiting for controllers)
print("Yo, 5 seconds later")

So what's basically happening in the above script is, we're removing the fog. We're delaying the game for 4 seconds, but in the mean time we're showing our mission title. After 4 seconds, we begin to fade in. At this point we reset the fog of war, wait a second, and then end the. These are the beginnings of most NIS'es. Now it's time to fill in the middle part.


So, now that we have an opening and ending sequence we'll setup a level flythrough to give the player an idea of what kind of forces he is facing, having already placed these forces in the previous tutorial. We can create a flyby through them. This can be any type of flyby you want, but a backward flyby works quite well, and can be used in combination with the pov command to give the effect that's show in the final mission included with this tutorial.


Go ahead and place down your path now.


This is done in the mission editor. Select the icon that looks like an “n” and then create a “Camera” type path. Click on the display to drop points. You also need to name some of the keyframes. To do this, select Keyframe 0 and drag the properties area so you can see more options below (it took me hours to figure out you could even do that). Then name this frame “start”. Select the last keyframe and name it “end”. You will have to do that with all the paths you create in this tutorial because they are set to run from “start” to “end”.


Having completed the path, let's set it up in the file, add these command between at the location that states — LOCATION 1:


CPath_Start( "canim_test1", "start", "end" )
CPath_CutToPoint("canim_test1", "start");

You would of course rename canim_test1 to whatever animation named you used.


As you might have noticed, single player missions consists typically of opening NISes, mid-game NISes and Intel Events (IE), and closing NISes. We will take the mission that we previously worked on and modify it to add these elements to the gameplay. What exactly are we doing? Well, the camera starts at a default position in the world when you start the mission. If we're doing an introductory NIS, chances are that the first thing we'll want to do is to have a camera path start at a certain location and move along a path, giving us a view of the battlefield or certain units. Since the scar system doesn't really support jumping the camera to a certain point we use a little trick to achieve the same effect. First you start the camera path (before fade in), then you cut the camera to the start point of your path (your camera is now facing the starting position of your path), now that's that done, you simply cut to the path starting position, and you're done. While this is a somewhat round about way of doing things it works like a charm.


So now, at — LOCATION 2 we add the following command:


CTRL.CPath_CutToPath("canim_test1", "start", "end", true)
CTRL.WAIT()
CTRL.CPath_Blendout();

The first command cuts to the path and plays it from beginning to end, the second command will wait for the camera to stop animating, and the third command blends out the camera.


Now, go ahead and play the game. You should have a nice fly-by introductory NIS.


While nice, there's certainly not a lot going on in that NIS, but soon we're going to change that.


First thing we'll do is add some speech, along with an entity being tracked by a camera path. We're going to track the Farseer as she moves, and talks, while moving toward her forces. Note that there are two ways of tracking an entity, each of which we will show in this tutorial. The first way gives you a lot more control, but is a little more difficult to setup, the second is easier to setup but lacks the control of the first method.


So, let's begin with the first method which involves setting up two paths, one for the entity, the other for the camera. What you want to do is first set down the path of the entity. Like so :



This is the path that our Farseer will move along. Now, setup a second path, the camera path, that will follow along the Farseer's path. The best way to do this is to setup the camera path with the same number of points as the Farseer path, and move the camera at the same speed as the camera path, while pointing it specifically at the appropriate points in the Farseer path and using the pov command.


Doing this we end up with something like the following:



Where the active (yellow) path (the camera path) follows the Farseer path (blue path). With a bit of tweaking you can get the camera look perfectly at where you want it to look, so now you ask, how do I make it work in the scar file? It's fairly easy.


What you need to do is something similar to what was done in the first place with the camera, but this time around we'll be skipping the jump to point call. You may however, want to add a fade it and fade out in the scene if you think the jump from the previous camera path is too harsh to the next camera path.


CTRL.CPath_CutToPath("canim_followFarseer", "start", "end", true)

SPath_Start("manim_farseer", "start", "end", SGroup_FromName("sg_Farseer"))

CTRL.WAIT()
CPath_Blendout()
SPath_Finish("manim_farseer")

Everything in the above lines should be fairly familiar except Spath. SPaths are quite similar to Cpaths, but obviously you have multiple SPaths that are possible, and while the Cpath has one camera associated with it, the SPath can potentially have more then one entity associated with it. That's why it needs a last argument, which is the ID of the entity/group that will be moving along the path during this time. This does indeed mean that you can reuse paths for different entitles.


Note that whenever the player hits the escape key during a NIS the world will return to the state that it's currently at. This means that if an entity hasn't completed a path it's on, or hasn't moved where it's supposed to, it won't instantaneously appear at the right position when the player returns to games. There are ways to ensure that entities appear where they should be, such as checking if a entity is at a certain position and if not moving them there, or killing them and then re-creating them there, but in general there's no one easy fix or way to make sure that the states after a NIS is where it's where you want it to be, and thus this is something that must be kept in mind.


IE 


Intel Events (IE) are similar to NISes in many ways, they need to be defined in the EVENTS table, but are typically much simpler and consist mainly of revealing a marker, focusing on a certain unit or area of the map, and playing some speech events. We can fire off a IE after the player kills the FC centered around the mk_relicPt marker. This intel event would looks as follows:


EVENTS.IE_CaptureRelic = function()
Util_SetIE( true )


FOW_RevealMarker( "mk_relicPt", -1 ) 
Camera_FocusOnTargetMarker("mk_relicPt", 2)
CTRL.Actor_PlaySpeech( ACT.Gabriel, 242110 )
CTRL.WAIT()

CTRL.Actor_PlaySpeech( ACT.Gabriel, 242112 )
CTRL.WAIT()


CTRL.Actor_PlaySpeech( ACT.Gabriel, 242114 )
CTRL.WAIT()

Util_SetIE( false )
CTRL.WAIT()

end

The Util_setIE functions just sets up the sound properly for the Intel events, the rest of the above script should be fairly self-explanatory. We reveal the maker, focus the camera on it, and play some speech, we then reset the sound to non-intel events levels.


More on Paths


Looking through the scar documentation you might have noticed that there is one more type of path, the Epath, this is similar to the Spath, and is used in a similar way, but for entities. It could potentially be used to simulate a thunderhawk flying in and dropping something onto the map, or perhaps simulate a crashing thunderhawk that plows through a bunch of trees. (see Impossible Creatures for inspiration)


A final word of warning, camera paths, and NISes in general are hard to get perfect the first time around, or even the second time, or even the third time. While getting the basic setup isn't the problem, getting the NIS “just right”, take a lot of time and a lot of tweaking.


Conclusions


This basically completes our set of tutorials, as we will no longer work on the mission in further detail. The following tutorials in this series will teach you how to debug SCAR applications, as well as how to beautify maps.


You are however encouraged to expand on the given tutorials and create and expand the mission as you see fit. We look forward to seeing what the mod community will create.

Links


ME Tutorials
Mission Editor
RDN Wiki Home

End of Page

Referring pages: DOWMissionEditor/Tutorials

There are no files on this page. [Display files/form]
There is no comment on this page. [Display comments/form]