here's the code:
string car_mdl = <rally.mdl>;
entity car_entity
{
type = <rally.mdl>;
layer = 10;
view = camera;
x = 0;
y = 0;
z = -30;//-60;
}
function create_car()
{
wait (1);
vec_set(temp, my.x);
my.pan = player.pan;
temp.z -= 2000; // trace 2000 quants below the car
trace_mode = ignore_me + ignore_passable + ignore_models + ignore_sprites;
my.z -= trace (my.x, temp) - 20; // place the car at ground level
my_car(); // start the action again
}
function player_to_car()
{
wait (1);
ent_remove (me);
player.shadow = off;
player._MOVEMODE = _MODE_DRIVING;
player._FORCE = 1.5;
player._BANKING = 0.1;
player.__SLOPES = on;
player.__WHEELS = on; // rotate only when moving
player.__JUMP = off; // the car can't jump
player.__STRAFE = off; // can't strafe
player.__TRIGGER = on;
astrength.pan = 1.5; // decrease rotation speed (pan)
ent_morph (my, car_mdl);
car_entity.visible = on;
while (key_space == 0) {wait (1);} // press space to switch from car to player
temp.x = player.x - 100 * sin(player.pan); // check to see if there is an empty space (near the car door) to deploy the player
temp.y = player.y + 100 * cos(player.pan) ;
temp.z = player.z;
ent_create (car_mdl, player.pos, create_car);
vec_set (player.pos, temp);
car_entity.visible = off;
car_to_player();
}
function car_to_player()
{
player._MOVEMODE = _MODE_WALKING;
player._FORCE = 0.75;
player._BANKING = -0.1;
player.__SLOPES = off;
player.__WHEELS = off;
player.__JUMP = on;
player.__DUCK = on;
player.__STRAFE = on;
player.__BOB = on;
player.__TRIGGER = on;
astrength.pan = 7; // restore the original value in move.wdl
}
function key_to_car()
{
if (key_f)
{
my.event = player_to_car;
}
}
action my_car
{
my.enable_impact = on;
my.event = key_to_car;
//my.event = player_to_car;
}