Q: When the player clicks a certain door, instead of opening it he will pass to the next level. How do i do that?
A: Here's the code:
string level2_wmb = <level2.wmb>;
function next_level();
action click_me
{
my.enable_click = on;
my.event = next_level;
}
function next_level
{
level_load(level2_wmb);
}
Q: I would like to see a panel with the weapons I've got so far when I press Ctrl. Can I do that?
A: Here's an example that works with 3 weapons; use this piece of code with the templates:
function show_weapons(); // call it from main()
bmap weapon1_pcx = <weapon1.pcx>; // pictures of weapon1...3
bmap weapon2_pcx = <weapon2.pcx>;
bmap weapon3_pcx = <weapon3.pcx>;
panel weapon1_pan
{
bmap = weapon1_pcx;
layer = 30;
pos_x = 10;
pos_y = 0;
flags = d3d, overlay, refresh;
}
panel weapon2_pan
{
bmap = weapon2_pcx;
layer = 30;
pos_x = 50;
pos_y = 0;
flags = d3d, overlay, refresh;
}
panel weapon3_pan
{
bmap = weapon3_pcx;
layer = 30;
pos_x = 90;
pos_y = 0;
flags = d3d, overlay, refresh;
}
function show_weapons() // call it from main()
{
while (1)
{
if (key_ctrl == 1)
{
if (weapon_1 == 1) // if we have the 1st weapon
{
weapon1_pan.visible = on;
}
if (weapon_2 == 1) // if we have the 2nd weapon
{
weapon2_pan.visible = on;
}
if (weapon_3 == 1) // if we have the 3rd weapon
{
weapon3_pan.visible = on;
}
}
else
{
weapon1_pan.visible = off;
weapon2_pan.visible = off;
weapon3_pan.visible = off;
}
wait (1);
}
}
Q: I have a train model and tracks in mdl; does any one know how to set it to follow the track?
A: Here's some of my code - it moves an entity on a path created in Wed:
var chtarget_pos;
var chinit_speed;
var chcurrent_speed;
var chacc_speed;
var ch_dist;
action move_tank
{
chinit_speed = 3; // speed
ent_path("tankpath"); // walk on this path
ent_waypoint(chtarget_pos, 1);
while (1)
{
temp.x = chtarget_pos.x - my.x;
temp.y = chtarget_pos.y - my.y;
temp.z = 0;
if (vec_to_angle (my_angle, temp) < 20)
{
ent_nextpoint(chtarget_pos);
}
my.z += 0.1 * (chtarget_pos.z - my.z) * time;
chcurrent_speed = chinit_speed;
my_angle.pan = ang(my_angle.pan - my.pan);
if (abs(my_angle.pan > 10))
{
temp = sign(my_angle.pan) * chcurrent_speed * 0.1;
}
else
{
temp = chcurrent_speed * my_angle * 0.01;
}
my.pan += temp * min(1, time);
chacc_speed = chacc_speed * max ((1 - time * 0.03), 0) + 0.2 * chcurrent_speed * time;
ch_dist = chacc_speed * time;
you = null;
move_mode = ignore_you + ignore_push + activate_trigger + glide;
ent_move(ch_dist, nullskill);
wait(1);
}
}
Q: Is there a way to place an object in Wed and have the camera follow the player from that specific point?
A: Sure it is, take a look:
action init_camera
{
my.invisible = on;
while (player == null) {wait (1);}
vec_set (camera.pos, my.pos);
while (1)
{
vec_set (temp.x, player.x);
vec_sub (temp.x, my.x);
vec_to_angle (camera.pan, temp); // follow the player
wait (1);
}
}
Q: I am getting a syntax error when I try to do enemy1[0].y = 0; but it works ok when I remove the array: enemy1.y = 0. Why can't I use an entity property with an array?
A: A regular var is practically an array with 3 elements, so you can use entity1.x or color.red, etc for it. If you use a "real" array its elements aren't vars with 3 elements so color[2].y gives errors.
Q: How do you use the push value if you want the player to move through an entity but not another entity?
A: Here's the code:
action player_action // the action attached to the player
{
my.push = 2;
..................
}
action pass_through
{
my.push = 3;
}
action cant_pass_through
{
my.push = 1;
}
Q: When a gun model emits a bullet model, does A5 automatically angle the emitting object's front position according to the main model?
A: No, you have to set the angles in bullet's function this way:
function bullets()
{
my.pan = you.pan; // you is the gun
my.tilt = you.tilt;
my.enable_entity = on;
my.enable_block = on;
my.event = remove_bullets;
..........................
}
Q: Is there a way to manipulate the robot2 action so that the distance of the shots isn't very far as if to use a sword?
A: You have to change a line inside war.wdl in function attack_fire():
if((fire_mode & MODE_DAMAGE) == DAMAGE_SHOOT)
{
shot_speed.X = 500; // replace 500 with 50
}
Q: I want to make a (player) health bar that gets bigger with 5% with every new level.
A: Create a regular health bar and simply increase player's health with 5% at the beginning of every new level - its health bar will grow automatically.
vbar 20, 30, 150, healthbar_map, 1, player._health;
vbar position_on_x, position_on_y, height_in_pixels, vbar_bitmap, multiplication_factor, variable_that_changes_vbar;
|