mohaa-spearhead-sdk/tutorials/driving_tutorial1.html
2003-02-06 00:00:00 +00:00

148 lines
No EOL
5.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html>
<head>
<title>MOHAA - SDK</title>
</head>
<body>
<u><b>Driving a Tank</b></u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<u><b>Part I</b></u>
<br>
THE MAP FILE
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This tutorial will teach you how to attach the player to a tank and drive it around freely through your level.
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;First you need to create a brush or terrain for your ground and apply a texture. Next, make your skybox and then we are ready to add the tank.
</p>
<p align = center>
<b><font size = -1>
Diagram 1-1 (MohRadiant)
</font></b>
<img src="driving_tutorial1/1-1.jpg">
</P>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create a brush, any size, and hit “n” to bring up your “Entity” window. Select from the list “addon_vehicle_Russian_T34”. Double click on it and your brush will turn into that entity. To rotate the starting direction of your vehicle, select the vehicle and open your “Entity” window. At the bottom of your “Entity” window you will see buttons with 90, 45, 360, etc… Press the corresponding direction that you would like your vehicle to be facing (90 = north, 180 = west, etc…).
<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Now we have to give the vehicle a targetname. In the entity window, with the vehicle selected, enter the following values into the Key and Value fields at the bottom of the entity window.
<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Key: targetname
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Value: playertank
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;To give your tank collision you have to target a bounding box. Instead of creating your own bounding box, copy the one from “test_VehicleDrive.map” in the SDK. To do so, open the map file and select one of the pieces from the bounding box and then press (crtl + e) to select all pieces of the bounding box. With the bounding box selected open your map. When is asks copy selection, click yes. This will bring the bounding box of the tank into your map. Deselect the tank mask and select the T34 tank image. Open the “Entity” window and enter the following into the Key and Value fields.
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Key: target
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Value: player_t34
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This will connect your tank to the tank mask and give it collision. The Collision mask/bounding box can be placed anywhere on your map. Try to place it somewhere the player will never be but still inside of your skybox. Placing it under the terrain is as good as any.
<br>
</p>
<p align = center>
<b><font size = -1>
Diagram 1-2 (Front View)
</font></b>
<img src="driving_tutorial1/1-2.jpg">
</P>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Finally we have to add the player start point to the map. To do so, right click on the grid and select “info” -> “player” -> “start”. Place it anywhere in the map because in the script we are going to connect it to the tank. You just have to have the start point it doesnt matter where. It is best to keep it next to your tank to make it clear that the player will start in that tank. We are finished with the map file all that is left is the script file.
</p>
THE SCRIPT FILE
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create a file with the same name as your map file and the extension .scr. For now copy and paste the script below or from “test_VehicleDrive.scr”. If you take it from “test_VehicleDrive.scr” make sure you change the targetnames and file name to match the ones in your map.
</p>
<pre>
<i><font color=blue>
level waittill prespawn
level waittill spawn
main:
$playertank.collisionent = $playertank.target
level.playertanktarget = $player
$player holster
$player takeall
$player physics_off
$playertank waitthread global/vehicles_thinkers.scr::players_tank
$playertank vehiclespeed 200
end
</font>
</i>
</pre>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Your vehicle should drive around with this script but here is what is going on in each line of the .scr.
</p>
<pre>
<i><font color=blue>
$playertank.collisionent = $playertank.target
level.playertanktarget = $player
</font>
</i>
</pre>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The first line gives the tank collision. The second line tells enemy tanks what to target at.
</p>
<pre>
<i><font color=blue>
$player holster
$player takeall
$player physics_off
</font>
</i>
</pre>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;These three lines holster the players weapon, take away the players weapons, and remove the physics of the player b/c we are now using the tanks physics.
</p>
<pre>
<i><font color=blue>
$playertank waitthread global/vehicles_thinkers.scr::players_tank
$playertank vehiclespeed 200
</font>
</i>
</pre>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The first line is the most important; it attaches the player to the tank. The second line sets the speed of the tank.
<br>
<br>
Save your file as a .scr and you are ready to drive your tank.
</p>
</body>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</p>
<pre>
<i><font color=blue>
</font>
</i>
</pre>