Most asked questions

Top  Previous  Next

Q: How can I create a script to allow me to click an object in 3D space to select it?

A: Use ACTION select_object for your objects that can be selected:

 

function select_me()
{
       IF (EVENT_TYPE == EVENT_CLICK)
       {
               MY.LIGHTRANGE = 100; // highlight the selected object
               // your stuff here
       }
       ELSE
       {
               MY.LIGHTRANGE = 0;
       }
}

ACTION select_object
{
       MY.ENABLE_CLICK = ON;
       MY.EVENT = select_me;
}
 

 
Q: I like the laser code in AUM1, but when I use it in outdoor areas, the frame rate decreases a lot. What should I do?

A: You have to add a single line to the laser code to make it work fine in outdoor areas:

 

IF (RESULT !=0)
{
       IF (RESULT > 2000) {RESULT = 2000;} // add this line
       laser_temp.X=(RESULT)*COS(player.PAN)*COS(CAMERA.TILT)+player.X;
       laser_temp.Y=(RESULT)*SIN(player.PAN)*COS(CAMERA.TILT)+player.Y;
       laser_temp.Z=(RESULT)*SIN(CAMERA.TILT)+player.Z;
}

Play with 2000 - it adjusts laser's length.
 

 
Q: How can I create a script to pull up a panel (like a browser) to display information such as text, images, animations, etc.

A: Here's an example for a panel that appears in the upper left corner and shifts to the lower right corner (define your_pan panel):

var camera_switch = 0;

ON_F2 show_camera;

function show_camera()
{
       IF (camera_switch == 0)
       {
               your_pan.POS_X = -250; // get your_pan out of the visible screen
               your_pan.POS_Y = -250;
               camera_switch = 1;
               PLAY_SOUND cameraon_snd, 20;
               WHILE (your_pan.POS_X < 0) // the panel slides
               {
                       your_pan.POS_X += 20 * TIME;
                       IF (your_pan.POS_X > 0) {your_pan.POS_X = 0;}
                               your_pan.POS_Y += 20 * TIME;
                       IF (your_pan.POS_Y > 0) {your_pan.POS_Y = 0;}
                       WAIT (1);
               }
       }
       ELSE
       {
               WHILE (your_pan.POS_X > -250) // slide back
               {
                       your_pan.POS_X -= 20 * TIME;
                       IF (your_pan.POS_X < -250) {your_pan.POS_X = -250;}
                               your_pan.POS_Y -= 20 * TIME;
                       IF (your_pan.POS_Y < -250) {your_pan.POS_Y = -250;}
                       WAIT (1);
               }
               camera_switch = 0;
       }
}
 

Q: Is there a way to change the control or movement so that the up key is forward from the view? Where left and right were not turning or strafing, the player model faced the direction pressed and went and the camera followed accordingly. This is in a 3rd person view.

A: Heres a wdl snippet that will solve the problem:

var camera_dist = 300; // play with this value

VIEW topview // set for 800x600 pixels
{
       POS_X 0;
       POS_y 0;
       SIZE_X 800;
       SIZE_Y 600;
       LAYER 2;
       DIAMETER 0; // move through walls
}

function use_topview
{
       topview.VISIBLE = ON;
       topview.TILT = -90; // look down
       WHILE (1)
       {
               topview.X = player.X;
               topview.Y = player.Y;
               topview.Z = player.Z + camera_dist;
               topview.PAN = player.PAN;
               WAIT (1);
       }
}
 

Q: I have given an action to an enemy (i.e player_attack); there is a patrol function in the templates, but I want my actor to patrol until it sees the enemy. Now if he sees the player then he should attack.

A: Please take a look at action robot1 in templates:

ACTION robot1
{
       MY._FORCE = 0.7;
       MY._FIREMODE = DAMAGE_EXPLODE+FIRE_BALL+HIT_EXPLO+BULLET_SMOKETRAIL+0.20;
       MY._HITMODE = 0;
       MY._WALKSOUND = _SOUND_ROBOT;
       anim_init();
       drop_shadow(); // attach shadow to robot
       actor_fight();
       if(MY.FLAG4 == ON) { CALL patrol; }
}

You have to check actor's FLAG4 and it will start patroling (if it finds a path nearby) and fight the player if it sees or gets shot by the player.
 
 

Q: is it possible to play a wav file as the music instead of midi?
A: Yes, I have successfully tested 30MB wav files with the A5 engine.
 

 

Q: How can I decrease player's health during time. I'd like to decrease the health value when time goes on.

A: Use something like this:

function decrease_health() // call this in main
{
       WHILE (1)
       {
               IF (PLAYER._HEALTH > 50) // limit the health decrease
               {
                       PLAYER._HEALTH -= TIME;
               }
               WAIT (1);
       }
}
 

Q: I am working on an adventure game, just using the elevator, door and key actions. It really disturbs me that I can only define 4 keys. Maybe some of the WDL-Gurus can help me.

A: The newest templates have 8 keys. Update your doors.wdl file.
 

 

Q: Has anyone scripted a mouse sensitivity routine?

A: Look in movement.wdl, there's a var named mouseview that can change the sensitivity. Use a hslider or vslider that changes mouseview.
 

 

Q: I just upgraded to A5 and now the particles that used to look really cool with the MY_FLARE flag set to "ON", now look really lame. Does anyone know why this might be?

A: A5 has a better particle system; the new MY_ALPHA skill gives the transparency for the particles. Use MY_ALPHA = x; (x = 0..100) in your particle action and you'll get your good looking particles back.

 

 

Q: How do I modify the range for the weapons?

A: The _bulletspeed (skill5) gives the speed of the bullet AND its range (twice the bullet speed).

 

 

Q: I would like to record all the actors movements (triggered by some start/stop keys) into a file. Any suggestions? What about performance, when continuously (lets say every 100 ms) writing x/y/z/rotation coordinates into a file?

A: I would create an array that holds player's coordinates; when the game stops (just before the engine shuts down) write the array content in a file on disk.

 
 
Q: How do I use muzzle_vert?

A: Muzzle_vert is used for enemies and allows them to shoot with any vertex of their bodies. Open your mdl actor in med, click on the desired vertex and read the vertex number at the bottom of the screen, then add MY.SKILL32 = your_vertex_number; in actor's action (robot1 or so).