Most asked questions

Top  Previous  Next

Q: How can I add an engine sound to the car code in Aum10?
A: You have to add a few things and modify function player_to_car():

var engine_handle;

sound engine_snd = <engine.wav>;

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;
    player.__JUMP = off;
    player.__STRAFE = off;
    player.__TRIGGER = on;
    astrength.pan = 1.5;
    car_entity.visible = on;
    while (key_space == 0) // press space to switch from car to player
    {
         if (key_force.y != 0)
         {
              if (snd_playing (engine_handle) == 0)
              {
                   snd_loop (engine_snd, 40, 0);
                   engine_handle = result;
              }
         }
         else
         {
              snd_stop (engine_handle);
         }
         wait (1);
    }
    temp.x = player.x - 100 * sin(player.pan);
    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();
}

Q: How do I create a panel that says: "press any key to continue" for every level that is loaded?
A: Use this piece of code:

bmap presskey_pcx = <presskey.pcx>;

panel presskey_pan
{
bmap = presskey_pcx;
layer = 30;
pos_x = 0;
pos_y = 0;
flags = d3d, overlay, refresh;
}

action panel_trigger // place any entity with this action attached to it in every level
{
   my.invisible = on;
   my.passable = on;
   presskey_pan.visible = on;
   while (key_any == 0) {wait (1);}
   presskey_pan.visible = off;
}

Q: How do I make my player disappear when it enters a vehicle and reappear when it gets out of the vehicle?
A: Here's the car code in Aum10 modified for 3rd person player:

// include this file in your main game file
// attach action my_car to your car model

string car_mdl = <rallycar.mdl>;

function player_to_car();
function car_to_player();
function create_car();

entity car_entity
{
    type = <rallycar.mdl>;
    layer = 10;
    view = camera;
    x = 20;
    y = 0;
    z = -60;
}

action my_car
{
    person_3rd = 0.5; // force 3rd person mode
    my.enable_impact = on;
    my.event = player_to_car;
}

function player_to_car()
{
    wait (1);
    ent_remove (me);
    player.shadow = off;
    player.invisible = on;
    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)
    car_entity.visible = on;
    while (key_space == 0) // press space to switch from car to player
    {
         wait (1);
    }
    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;
    player.invisible = off;
    astrength.pan = 7; // restore the original value in move.wdl
}

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); // place the car at ground level
    my_car(); // start the action again
}

Q: I use the car code in Aum10 and I'd like to know how to make my player face the same direction as the car after entering it; now the car receives my player's pan value which doesn't look right.
A: Change function player_to_car() this way:

function player_to_car()
{
    wait (1);
    player.pan = my.pan;
    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)
    car_entity.visible = on;
    while (key_space == 0) // press space to switch from car to player
    {
         wait (1);
    }
    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();
}

Q: How do I do, that when the player picks up a gun, it actually holds the gun in the third person view?
A: Animate your gun model(s) together with the player model then save them as separate models. This piece of code does what you want:

string gun_mdl = <gun.mdl>;

function attach_player_gun();

action pick_me_up // attach it to your gun
{
   my.passable = on;
   while (player == null) {wait (1);}
   while (vec_dist (player.x, my.x) < 100) {wait (1);}
   ent_remove (me);
   ent_create(gun_mdl, nullvector, attach_player_gun); // give the player a gun
}

function attach_player_gun()
{
    proc_late();
    my.passable = on;
    my.metal = on;
    while(player != null)
    {
       vec_set(my.pos,player.pos);
       vec_set(my.pan,player.pan);
       my.frame = player.frame;
       my.next_frame = player.next_frame;
       wait(1);
    }
    ent_remove(my);
}

Q: I would like to use the keys WSAD for movement; is it possible if I am using the templates?
A: Replace these lines in movement.wdl (input.wdl if your templates are newer):

force.X = strength.X*(KEY_FORCE.Y+JOY_FORCE.Y);  // forward/back
force.Y = strength.Y*(KEY_COMMA-KEY_PERIOD);     // side to side

with these ones:

force.X = strength.X*(KEY_FORCE.Y+JOY_FORCE.Y+key_w-key_s);
force.Y = strength.Y*(KEY_COMMA-KEY_PERIOD+key_a-key_d);

Q: How can I increase or reduce player's health or armor smoothly instead of taking one big chunk of it?
A: Here's an example:

define damage skill10;

function decrease_health();

action enemy // could be an enemy, an enemy bullet, etc
{
   my.damage = 10;
   ........................
}

action player
{
   ..................................
   my.enable_impact = on;
   my.event = decrease_health;
   while (1)
   {
       ...........
       wait (1);
   }
}

function decrease_health()
{
   if (event_type == event_impact && you.damage != 0) // it is an enemy, an enemy bullet, etc
   {
       player.skill48 = player._health;
       while (player._health > player.skill48 - you.damage)
       {
           player._health -= 5 * time;
           wait (1);
       }
   }
}

Q: How do I do that when the player clicks "use" on a certain object, it moves to the next level, and restores health and armor?
A: Here's the code:

function next_level();

bmap use_pcx = <use.pcx>;
string level2_wmb = <level2.wmb>;

panel use_me // shows the usable object on the screen
{
    bmap = use_pcx;
    layer = 20;
    pos_x = 40;
    pos_y = 60;
    flags = d3d, overlay, refresh, visible;
    on_click next_level;
}

function next_level()
{
    level_load (level2_wmb);
}

Health and armor are restored automatically (set their values using skill9 and skill10 if you are using the templates).

Q: I'm trying to do a car racing game; what do I need to call the left, right, etc animation frames when I press the corresponding keys?
A: I will assume that you are using the arrow keys for movement:

action my_car
{
   while (1)
   {
       ...........
       // movement code
       ..........
       if (key_cul == 1)
       {
           ent_cycle("rotateleft", my.skill20); // name your animation frames this way
           my.skill20 += 3 * time; // animation speed
           my.skill20 %= 100; // loop the animation
       }
       if (key_cur == 1)
       {
           ent_cycle("rotateright", my.skill20); // name your animation frames this way
           my.skill20 += 3 * time; // animation speed
           my.skill20 %= 100; // loop the animation
       }
       if ((key_cul + key_cur == 0) && (key_cuu + key_cud != 0))
       {
           ent_cycle("moveforward", my.skill20); // name your animation frames this way
           my.skill20 += 3 * time; // animation speed
           my.skill20 %= 100; // loop the animation
       }
       wait (1);
   }
}