Author Topic: 2012-10-10 - Player Viper Launch Tutorial  (Read 6769 times)

0 Members and 1 Guest are viewing this topic.

Offline Ace

  • Truth of Babel
  • Moderator
  • 212
2012-10-10 - Player Viper Launch Tutorial
Player viper launches are one of the first major features players see in Diaspora. The version you see is the end result of several years of on and off mission design. The earliest versions of the tube launches now seen Karajorma developed for Beyond the Red Line, and the latest versions are work done by CooperHawkes. AI tube launches are a different animal, and will be covered in a future post.

For R2 we want to simplify this process by moving a lot of this into code, but the old method will still be supported in the mission editor.

1. Setup:
You first need a battlestar and a player fighter. In this case we'll use the Battlestar Valkyrie which will be featured in R2. But everything here applies to the Sobek class currently available.

Your battlestar can be at pretty much any angle, but you need to make sure that the player's fighter is properly aligned and centered at the back of the tube. Using the object orientation editor can help with this.

A trick to do alignments:
Set the viper docked to one of the launch tubes of the battlestar in the ships editor.
Close ships editor
Open ship editor again and undock the Viper.
The Viper's position will return to where it was, but is now perfectly aligned in the tube.

This is especially helpful if the battlestar has been rotated around.

Be sure under ship properties to set the initial velocity of your battlestar and fighter to '0' if moving you'll have collisions and the launches won't work right. You may also want to set your "does not move" flag for the fighter. There are occasions where the AI even if given orders to play dead might decide to do its own thing, so this adds an extra layer of safety to ensure that launches work properly.

The second thing you'll need is a waypoint named LaunchPath. This waypoint should be just beyond the launch tube's exit. It will be referenced in your events as a way of marking when the fighter has exited. The use of waypoints is another reason why your battlestar can't be moving during a player tube launch, since an absolute coordinate is being referenced.

Since the waypoint needs to be about 25m away from the launch tubes exit, one trick to measure distance is to add a second  waypoint, move it to the launch tubes exit, toggle use "show distances", and then delete the second waypoint when you are done.

2. Initial Events

There's a few housekeeping things to do before the actual tube launch. You'll notice that I already wrote out the dialog for the launches.

The very first thing is to put the player under ai control to lock their controls. Giving the player ai-orders to play dead means that you can't move until the launch begins.

Next is removing the sun. This is done so tube launches look good from any orientation and as long as you're not launching straight into the direction of a sun no one will notice. This way tube glowmaps light everything and there is a consistent look to all launches.

We also lock the player into first person view with lock-perspective. This means you can't enter third person or chase views while inside the tube and so you can't see clipping from the ship.

Then, we want to add the Valkyrie and the player fighter to the same collision group, to avoid any pesky collision related issues.

The very last part of this first event is fade-out. This means that the mission will start with a black screen.

For our next event we'll chain it to the previous one without a delay.

We'll add a fade-in event with a delay of 1500ms, so that when you start the mission it slowly fades in from black.

The second part for this initial event is play-sound-from-file and we reference the launch loop sound. We set this to 1 so that there is a continual loop of the engines cycling until you launch.

Now we will set up the launch messages. All viper launches have a set of checklist dialog from the Launch Officer according to the BSG series bible.

Here we just send a message, the sender has a # in front since we're not actually sending it from a ship. The actual message, seen in all of the earlier images, has a $slash so that the slash symbol can appear in game.

The next two messages in the check list have skippable dialog. If you launch early you won't have to sit through it. The events check for if a later event (FLUSH Directive Dummy) has happened yet, that event will occur when you press a key, and if the events with earlier messages in the list have triggered yet. Pretty simple  so far, but these events mean that you have all of the dialog playing for the launch sequence and it can be skipped if you launch early.

3. Launch Directive Setup

This event ensures that the launch key can't be pressed prematurely to trigger the launch. Ignore-key 0 means that the launch key won't be ignored (useful if you have a cutscene or other setup before the launch) and Key-reset-multiple means that if the player pressed the launch key earlier the game won't auto-execute a launch thinking it's already been pressed.

The directive has to be chained to the dummy event. This turns true when you press the key. The directive text and key pressed means that you will see under your Tasking Orders\Directives the order and hotkey for launching.

4. Launching

Now we get to the guts of the launch events and the trickiest part.

First, we need to create a variable InLaunchTube and set it to 1.

Then we create an event that turns true when InLaunchTube is > 0.

There are three embedded "whens" also in this event, which we will go through one at a time.

The overall event has to be chained to the directive with the key press for launch and we give it a high repeat count with an interval time of 0.

This event uses the math function = to check if the variable in LaunchTube is 1.

It plays the launch tube start sound with play-sound-from-file, sets a camera shudder with a shake value of 2000 for 10000ms. This lets the Viper shake while going through the tube.

We also set the player fighter to be mobile with this event so that other events can move the ship. (the player is still under AI control which locks things down)

Finally the variable InLaunchTube is set to 2, which indicates that the launch is in progress.

Now we need to move the player out of the tube.

To do this we need to create a new variable, TubeVelocity with an initial value of 0.

This when event checks for if InLaunchTube is set to 2, which means the first set of events are done and you are ready to move out of the tube.

We modify the variable TubeVelocity by adding 1. Since this event repeats, it adds one per each time step the event executes.

We then set-object-speed Z for the player (Red 1) and set the speed value to the variable TubeVelocity. We set the boolean value to true to use a relative coordinate system so that the player accelerates based on its own current Z axis (front) and not the overall mission Z axis. So, if you're not properly aligned in the launch tube, you'll ram the walls when moving forward.

The net result is that you keep accelerating through the tube since the tube velocity variable keeps increasing and your ship's forward speed is tied to that.

This final part is now for what triggers when you've cleared the tube.

Quite a bit is going on at this time, so it's broken down into a few pieces.

This final 'when' triggers when if LaunchTube=2 (so actively launching) and when the distance between Red 1 and waypoint path 1 is less than 25 meters.

Also, this is a good time to create a new number variable, sun1, which will hold the data for the mission's sun.

Okay, now we begin the long series of things that occur at the end of the launch.

First off we want to add the sun. The first three sets of integers are for coordinates followed by size. We then reference the variable sun1 to store the data in.

Then we play-sound-from-file and play the launchtube exit sound.

We follow this with set-camera-shudder with values of 250 and 150 which leads to a very tiny shake that marks the end of the tube launch.

Now it's time to modify the TubeVelocity variable to a value close to the Viper's top speed. This marks being outside of the influence of the magnetic catapult. First we set the variable to 110.

Then we apply that velocity setting to your ship with set-object-speed z.

We then remove your fighter from the Valkyrie collision group using remove-from-collision-group.

For the final touches we change the variable InLaunchTube to 0, this means you are now no longer considered as in the launch tube.

We set lock-perspective to false, enabling third person views since you are out of the tube.

Finally, we use player-not-use-ai which gives control back to the player.

Now you have a Viper that has fully launched from a tube and is back in full player control slowing down to regular top speed.

5. Some final touches.

Here, we add an event that you get yelled at if you've spent over a minute without launching. So if over 60 seconds have elapsed and you haven't pressed the launch key this message triggers. A second event following this could be added at the two minute mark that auto ends and aborts the mission if the player still refuses to launch.

The very last thing to add is the final part of the launch checklist. Saying good-bye.

This event triggers once you've pressed the launch key and are moving. It could be put directly into that event, but for clarity's sake here it is a separate event so that it's easier to go through all of the dialog. (That's why it's labeled Shooter: so that the mission can be parsed for messages and their senders)


That's it! If you've managed to get through this you should be able to make your own tube launches.

AI Viper launches, raider rack launches, and combat landings are also rather complex pieces of mission design. We plan on covering these at a future date.
« Last Edit: November 08, 2012, 08:13:51 pm by karajorma »
Self-plagiarism is style.
-Alfred Hitchcock