Most asked questions

Top  Previous  Next

Q: I have two arch doors on a gatehouse and I want them to open both at the same time going inside in. How can I do that?

A: You can use the standard door action. Create two wmb entities and attach them the door action; set skill5 to a negative value for a door and a positive value for the other door.

 

Q: I was making a roallercoaster thing but when I tried to get in to that special designed box I made where I should sit, I could not get in and enjoy the ride.

A: Here's an example:

entity* roller_pnt;

action roller
{
    roller_pnt = me;
}

action player_stuff
{
.......................................
  while (close to the rollercoaster)
  {
      player.x = roller_pnt.x;
      player.x = roller_pnt.x;
      player.x = roller_pnt.x;
      wait (1);
  }
}

This code will keep the player in the center of your box. You can look around by changing player's pan, tilt and roll.

 

Q: I'm making a tv in my level and when you press space an invisible sprite apears and plays an animation. Please help me.

A: You should check the distance between the player and the tv first - use something like this:

tvsprite.invisible = on;
while (1)
{
  if (vec_dist(player.x, tv_pnt.x) > 200) {return;}
  if (key_space == 1)
  {
       while (key_space == 1) {wait (1);}
       tvsprite.visible = on;
       while (tvsprite.frame < 30)
       {
              tvsprite.frame += 2 * time;
       }
...............................................................
}

Q: How can i make the enemies run instead of walking?

A: There are a few ways to do that; change one or more of these in animate.wdl

STRING anim_walk_str,"walk";
STRING anim_run_str,"run";
var anim_walk_dist = 1;  // dist per model width per walk cycle
var anim_run_dist = 1.5; // dist per model width per run cycle

 

Q: I want to have a reload action in my game. The player has to press a key (like "r" on the keyboard), then the weapon should be reloaded.

A: You should add a simple function to weapons.wdl (the code works for weapon1):

function reload_weapon1()
{
   while (1)
   {
       if (key_r == 1 && ammo1 < 1)
       {
            ammo1 = 10; // add 10 bullets
       }
       wait (1);
   }
}

Q: I need to know how to program an image that moves on a panel. Can you help?

A: The easiest method would be to create two panels. Use the panel with the higher layer as your "panel" and the panel with the lower layer value for the "image". You can move the "image" by changing its pos_x and pos_y parameters.

 

Q: In the AUM magazines, why do you put "* time" after all of your calculations?  What does this do?

A: This (multiplying by time) helps me keep the same running speed on all the computers. Let's say that one of my customers has a computer that can deliver 16 fps and my computer has 80 fps in the same spot. If I write an action for an enemy that moves 5 quants every frame:

while (1)
{
  move_5_quants;
  wait (1);
}

 

it is clear that the enemy will walk 16 fps * 5 quants = 80 quants on his PC and for 80 fps * 5 quants = 400 quants on my computer in a second. Time is small when the frame rate is big (time = 1 for 16 fps, time = 0.5 for 32 fps, as a general rule time * fps_number = 16). Let's rewrite the movement code:

 

while (1)
{
  move_5_quants * time;
  wait (1);
}

You can see that the enemy runs 16 fps * 5 quants * 1 = 80 quants on my client's computer and 80 fps * 5 quants * 0.2 = 80 quants on my computer.

 

Q: I have been racking my brain trying to think of a way of making buildings and people cost gold or money that people or peseants gain with deposits. Could you help me with a script that would accomplish that?

A: If you are using code from Stratego as a base, you can write something like that:

function create_building1()
{
   ......................................................................
   if (gold > building1_cost)
   {
       create (<build1.wmb>, build1_pos, build1_action);
       gold -= building1_cost;
   }
}

Q: I was experimenting with the code for thief-like sneaking ability for characters. Do you have an ALARM action? What is the best way to write the function?

A: The code for the alarm function should play an alarm wave file, increase the scanning range for the actors in function state_wait() from 1000 to 3000 and so on.