Garages in GTA 2 Coding
This entire guide will detail on how to create an entire garage system, from how to make the garage in the map editor, doors and how to make it used in missions.
Parking
If you want to know how to make a garage actually take a car in for a mission, this is how to set it up:
PARK ( car_name , door_name )
Set the car_name to a previously declared car, and the door_name to a previously made door (see below). An example:
PARK ( enemy_limo , zaibatsu_garage )
In your map, you'll need enough space for the car to go in nicely. If you have a single door, you'll need one block on either side of the door and three blocks depth for long vehicles (a 3×3 area). If you have a double door, you need two blocks on either side of the door and again three blocks depth for long vehicles (a 6×3 cube area). You must have these sizes (or larger) or else you might end up with an error. Once the car has entered, the car is effectively destroyed along with any other passengers. The player simply runs out of the garage.
The entrance must have nothing there, as the door is created in the script. An example:
You can then do a simple check in an IF statement to see if the parking is complete, returns TRUE if it has finished:
HAS_PARK_FINISHED ()
Doors
To make a fully working garage, you'll need a door for it. Since you (should) have made the garage area in the map editor (see above), you just need to add the code before the LEVELSTART command.
DECLARE_DOOR_INFO ( start-frame , end-frame , speed )
The start and end frames are the tile numbers in the map editor, so in the bil.gmp map, the first tile would be 928, whilst the last frame is 935. The speed is then set to 2 which is reasonably fast. So for the above, the code would be:
DECLARE_DOOR_INFO ( 928 , 935 , 2 )
Next up, we tell the game where the door will be placed. The code for this is:
DOOR_DATA name = Style ( int X , int Y , int Z ) ( float check X , check Y , check Z , check width , check height ) face gr_id open_type close_type delay flip reverse somename
What the settings mean:
| Range | Description | |
|---|---|---|
style
| SINGLE
| One cube wide. |
DOUBLE
| 2 cubes wide. Second cube is added on the clockwise side. | |
int X
| 0 to 255 | Integer values of where to place the door. |
int Y
| ||
int Z
| ||
float check X
| 0.0 to 255.99 | Float values describing where the door check area will be. |
float check Y
| ||
float check Z
| ||
check width
| Float value of the trigger position for when he door opens. | |
check height
| ||
face
| TOP
| North |
BOTTOM
| South | |
LEFT
| West | |
RIGHT
| East | |
gr_id
| 0 to ? | Integer describing which DOOR_INFO to use for this door.
|
open_type
| ANY_PLAYER
| All human characters. |
ANY_CAR
| All vehicles. | |
ONE_CAR
| Use somename for the name of car.
| |
ONE_MODEL
| Use somename for the car type.
| |
ONE_CHAR_ON_FOOT
| Use somename for the name of character.
| |
ANY_PLAYER_ONE_CAR
| Use somename for the name of car.
| |
close_type
| CLOSE_NEVER
| Does not shut after being opened. |
CLOSE_TIME_DELAY
| Waits according to the value for delay.
| |
CLOSE_WHEN_CLEAR
| Shuts when nothing will get trapped. | |
CLOSE_WHEN_OPEN_RULE_FAILS
| Shuts when the open_type rule is not being fulfilled.
| |
delay
| 0 to 255 | An integer value to wait before the door closes. |
flip
| FLIP_RIGHT
| The right hand door images is graphically flipped. |
NOT_FLIPPED
| Default display. | |
reverse
| REVERSED
| For when two separate doors are on one block. |
NOT_REVERSED.
| ||
somename
| Used when open_type is neither ANY_CAR nor ANY_PLAYER.
|
An example would be:
DOOR_DATA door_1 = DOUBLE ( 238 , 112 , 2 ) ( 238.0 , 112.0 , 2.0 , 4.0 , 2.0 ) LEFT 0 ANY_PLAYER_ONE_CAR CLOSE_WHEN_OPEN_RULE_FAILS 0 FLIP_RIGHT NOT_REVERSED
Quite long for a door command, but it has to be done! If you want to open the door yourself, you have various commands at your dispsoal. Firstly, tell it the name of the door to make manual.
MAKE_DOOR_MANUAL ( doorname )
Open the selected door:
OPEN_DOOR ( doorname )
Close the selected door:
CLOSE_DOOR ( doorname )
Or you can make the door back to being computer controlled with the commands above. This is the default state for all doors:
MAKE_DOOR_AUTOMATIC ( doorname )
(Originally written by Chris “Pyro” Hockley and formatted by Ben “Cerbera” Millard with full permission.)