Most asked questions

Top  Previous  Next

Q: How can I create an action that will give the player some points and when it has over 100 points the player will be able to open a door?
A: Here's the code:

var points = 0; // zero points at game start

function open_over_100 () // call this function at the end of your main action
{
   while (points < 100) {wait (1);}
   key1 = 1; // opens the doors that need key1
}

action increase_points // attach this action to any model
{
   while (1)
   {
       if (vec_dist (my.x, player.x) < 200) // if the player comes close to this object, give him points
       {
           points += 10 * time;
       }
       wait (1);
   }
}

Q: How can I use your cash script in Aum9 to buy a gun?
A: Take a look at the function below:

 

function buy_me()
{
     wait (1);
     if (event_type != event_click || cash < my.skill1) {return;}
     cash -= my.skill1;
     snd_play (spentcash_snd, 70, 0);
     ent_remove (me);
}

 

To make it work you should change it this way:

string gun_mdl = <gun.mdl>;

function buy_me()
{
     wait (1);
     if (event_type != event_click || cash < my.skill1) {return;}
     cash -= my.skill1;
     snd_play (spentcash_snd, 70, 0);
     my.passable = on;
     my.invisible = on;
     ent_create(gun_mdl, my.pos, action_for_gun);
}

The action action_for_gun is an action similar to the other gun actions in the templates (weap_m16, etc).

Q: How can I put in video clip at the beginning of the game and into the loading of the second level?
A: Here's some code from one of my older projects; call the function when you need it:

function play_video ()
{
      if (movie_frame == 0)
      {
            play_moviefile "your_video.avi";
      }
      else
      {
            stop_movie;
      }
}

Q: Help! My player can't climb up the stairs!
A: The origin of your player is too low. Open Med, select the player: Edit -> Select all, check "Use frame range" and move it upwards.

 

Q: Is it possible to change the key_force to be different keys in the movement code?
A: Sure. Simply replace key_force.x with (key_w - key_s) and so on.

 

Q: When my model turns I want it to turn back with the same animation but reversed when I release the button.
A: Here's an example:

var sense; // 1 = normal animation, -1 = reversed animation

while (1)
{
   // add your movement code here
  ...................
  sense = key_cuu - key_cud; // use cursor keys for forward / backward movement
  ent_cycle("walk", my.skill10);
  my.skill10 += sense * init_speed * time;
  my.skill10 %= 100 // loop animation
  wait (1);
}

Q: Whenever I pick up my weapons, they are placed in a wrong position. What can I do?
A: Set skill1..3 for every weapon model - they control the position of the picked up weapon on x, y and z.

 

Q: How can I rotate a panel?
A: You can't rotate a panel, but you can define it as an entity - this way you will be able to rotate it by changing its roll angle:

function rotate_entity();

entity my_panel
{
    type = <panel.mdl>;
    layer = 10;
    view = camera;
    x = 25;
    y = 10;
    z = -10;
}

function rotate_entity()
{
   my_panel.visible = on;
   while (1)
   {
       my_panel.roll += 5 * time;
       wait (1);
   }
}

Q: By default the Game Studio fires a white and grey trail from the enemy weapon to the player. How do you change what the enemey fire looks like?
A: You will have to modify function particle_fadeout.