function
main()
{
...................
while (player == null) {wait (1);}
player._health = 100;
ifdef megapower;
player._health = 300;
endif;
}
Run
yourlevel.exe to set 100 health points for the player or run "yourlevel.exe
-d megapower" (without the quotes) using a batch file to get 300 health
points.
Q:
I use the splitscreen shooter from Aum30 but the players don't have gravity.
Can you help?
A:
Replace action player_one and action player_two with the ones below:
action
player_one
{
player1 = me;
my.enable_entity = on;
my.enable_impact = on;
my.event = kill_player1;
ent_create (handgun1_mdl, nullvector, weapon1);
while (p1_alive == 1)
{
my.pan += 5 * (key_a - key_d) * time;
player1_dist.x = 15 * (key_w - key_s) * time;
player1_dist.y = 0;
vec_set (temp, my.x);
temp.z -= 1000;
trace_mode = ignore_me + ignore_passable + use_box;
player1_dist.z = -trace (my.x, temp);
move_mode = ignore_passable + glide;
ent_move (player1_dist, nullvector);
camera1.pan = my.pan;
camera1.x = my.x;
camera1.y = my.y;
camera1.z = my.z + 30;
if (key_w + key_s > 0) // if the player is moving
{
ent_cycle("run", my.skill46); // play "run" frames animation
my.skill46 += 10 * time; // "run" animation speed
my.skill46 %= 100; // loop animation
}
else // the player is standing or shooting
{
if (key_space == 1) // if this player is shooting
{
ent_cycle("attack", 100); // display the last "attack" animation frame
if (bullet1 == null)
{
wait (3);
ent_create (bullet_mdl, bullet1_coords, move_bullet1);
}
}
else
{
ent_cycle("idle", my.skill46); // play "stand" frames animation
my.skill46 += 2 * time; // "stand" animation speed
my.skill46 %= 100; // loop animation
}
}
wait (1);
}
}
action
player_two
{
player2 = me;
my.enable_entity = on;
my.enable_impact = on;
my.event = kill_player2;
ent_create (handgun2_mdl, nullvector, weapon2);
while (p2_alive == 1)
{
my.pan += 5 * (key_cul - key_cur) * time;
player2_dist.x = 15 * (key_cuu - key_cud) * time;
player2_dist.y = 0;
vec_set (temp, my.x);
temp.z -= 1000;
trace_mode = ignore_me + ignore_passable + use_box;
player2_dist.z = -trace (my.x, temp);
move_mode = ignore_passable + glide;
ent_move (player2_dist, nullvector);
camera2.pan = my.pan;
camera2.x = my.x;
camera2.y = my.y;
camera2.z = my.z + 30;
if (key_cuu + key_cud > 0) // if the player is moving
{
ent_cycle("run", my.skill46); // play "run" frames animation
my.skill46 += 10 * time; // "run" animation speed
my.skill46 %= 100; // loop animation
}
else // the player is standing or shooting
{
if (key_enter == 1) // if this player is shooting
{
ent_cycle("attack", 100); // display the last "attack" animation frame
if (bullet2 == null)
{
wait (3);
ent_create (bullet_mdl, bullet2_coords, move_bullet2);
}
}
else
{
ent_cycle("idle", my.skill46); // play "stand" frames animation
my.skill46 += 2 * time; // "stand" animation speed
my.skill46 %= 100; // loop animation
}
}
wait (1);
}
}
Q:
I use your timer.wdl from Aum11. How should I modify the code if I want
to be able to disable the bomb by clicking it again?
A:
Use the code below:
var
second_counter = 10; // explodes after 10 seconds
var
disabled = -1;
function start_timer();
sound timer_snd = <timer.wav>;
define explo_sprite = <explo+7.pcx>;
action
timer
{
my.skin = 2;
my._DAMAGE = 200; // set different damage values for different timers
my.enable_click = on;
my.event = start_timer;
}
function
start_timer()
{
disabled += 1;
while (disabled < 1)
{
second_counter -= 1;
my.skin = 2;
ent_playsound (my, timer_snd, 300);
waitt (14);
my.skin = 1;
waitt (2);
if (second_counter < 1)
{
range = my._DAMAGE * 2;
damage = my._DAMAGE;
temp.pan = 360;
temp.tilt = 180;
temp.z = range;
indicator = _EXPLODE; // not a friendly scan
scan_entity (my.x, temp);
morph (explo_sprite, me);
my.oriented = on;
my.pan = 0;
while (my.frame < 7)
{
my.frame += 3 * time;
wait (1);
}
actor_explode(); // remove the explosion sprite
}
}
my.skin = 2;
}
Q:
I'd like to have a bomb that starts ticking as soon as the level is loaded
and explodes after a specified number of seconds. Can you help me?
A:
Check Aum11 (timer.wdl) and get the modified version of the code below:
var counter = 10; // explodes after 10 seconds
sound timer_snd = <timer.wav>;
define explo_sprite = <explo+7.pcx>;
action
timer
{
my.skin = 2;
my._DAMAGE = 200; // set different damage values for different timers
while (my != null)
{
counter -= 1;
my.skin = 2;
ent_playsound (my, timer_snd, 300);
waitt (14);
my.skin = 1;
waitt (2);
if (counter < 1)
{
range = my._DAMAGE * 2;
damage = my._DAMAGE;
temp.pan = 360;
temp.tilt = 180;
temp.z = range;
indicator = _EXPLODE; // not a friendly scan
scan_entity (my.x, temp);
morph (explo_sprite, me);
my.oriented = on;
my.pan = 0;
while (my.frame < 7)
{
my.frame += 3 * time;
wait (1);
}
actor_explode(); // remove the explosion sprite
}
}
}
Q:
How can I add an action to a map entity if I want to be able to change
its angles using the four arrow keys?
A:
Use the code below:
action
platform
{
while (1)
{
if (key_cul == 1) {my.roll -= 2 * time;}
if (key_cur == 1) {my.roll += 2 * time;}
if (key_cuu == 1) {my.tilt -= 2 * time;}
if (key_cud == 1) {my.tilt += 2 * time;}
if (my.tilt < -40) {my.tilt = -40;}
if (my.tilt > 40) {my.tilt = 40;}
if (my.roll < -40) {my.roll = -40;}
if (my.roll > 40) {my.roll = 40;}
wait (1);
}
}
Q:
I'd like to be able to display a long text letter by letter, not all the
text at once. Is this possible?
A:
Yes, it is possible. Take a look at the code below:
var text_length;
string long_str = "My game will be so great! Please buy it now and I'll develop it later!";
text
my_txt
{
layer = 20;
pos_x = 15;
pos_y = 30;
string = temp_str;
font = standard_font;
flags = visible;
}
function
display_text
{
text_length = str_len(long_str);
while (text_length >= 0)
{
str_cpy (temp_str, long_str);
str_trunc (temp_str, text_length);
text_length -= 1;
sleep (0.1);
}
}
on_d = display_text;
Q:
How can I get the names of the entities, as they appear in Wed, at runtime?
A:
Use the code below:
string entity_str[20];
text
name_txt
{
layer = 10;
pos_x = 5;
pos_y = 5;
string = entity_str;
font = standard_font;
flags = visible;
}
starter
get_names()
{
while (1)
{
if (mouse_ent != null)
{
str_for_entname (entity_str, mouse_ent);
}
else
{
str_cpy (entity_str, "");
}
wait (1);
}
}
Q:
How can I have a different crosshair for each weapon please?
A:
Modify weapons.wdl as shown below:
..................................................................................................
////////////////////////////////////////////////////////////////////////
//
Cross-hair panel and functions
//
//
Use the var 'cross_pos.x' and 'cross_pos.y' you adjust the position
//of
the cross-hair on the screen
BMAP
cross_bmp, <cross.pcx>;
BMAP
cross2_bmp, <cross2.pcx>;
BMAP
cross3_bmp, <cross3.pcx>;
BMAP
cross4_bmp, <cross4.pcx>;
BMAP
cross5_bmp, <cross5.pcx>;
BMAP
cross6_bmp, <cross6.pcx>;
BMAP
cross7_bmp, <cross7.pcx>;
var cross_pos[2] = 0, 0; // position of cross-hair on screen
PANEL
cross_pan
{
bmap = cross_bmp;
layer = 1;
flags = overlay, transparent, refresh, d3d;
}
//
Desc: position the cross-hair panel at the center of the screen
//
and make it visible.
function
pan_cross_show()
{
cross_pan.pos_x = (screen_size.x / 2) + cross_pos.x;
cross_pan.pos_y = (screen_size.y / 2) + cross_pos.y;
if (weapon_number == 1) {cross_pan.bmap = cross_bmp;}
if (weapon_number == 2) {cross_pan.bmap = cross2_bmp;}
if (weapon_number == 3) {cross_pan.bmap = cross3_bmp;}
if (weapon_number == 4) {cross_pan.bmap = cross4_bmp;}
if (weapon_number == 5) {cross_pan.bmap = cross5_bmp;}
if (weapon_number == 6) {cross_pan.bmap = cross6_bmp;}
if (weapon_number == 7) {cross_pan.bmap = cross7_bmp;}
cross_pan.visible = ON;
}
starter
show_crosshair()
{
while (1)
{
pan_cross_show();
wait (1);
}
}
//
Desc: hide the cross-hair panel
function
pan_cross_hide()
{
cross_pan.visible = OFF;
}
.............................................................................................
Q:
In the game World War III you can change the graphics in the options menu
and it will tell you after 10 seconds the performance that game would play
in. How would I do something like this?
A:
Load one of the levels that will be used in your game and hide it with
a black panel (or not). Use a typical, fixed camera position, measure the
frame rate (fps) and tell it to the player.