One bug I found out when I played around with the coded is the following line in the enemy his action of enemy.wdl:
Code:
// the bugs are situated in red UUB code.
ACTION enemy
{
you = player; // remove this line
my.shadow = on;
my.health = 100;
ent_create("club.mdl",my.x,attach_club);
my.enable_scan = on;
WHILE (1)
{
dying_dead();
IF (my.hit_by_player == 1)
{
my.move_x = player.move_x;
my.move_y = player.move_y;
my.move_z = player.move_z;
c_move(my,nullvector,my.move_x,use_aabb | ignore_passable | glide);
IF (player.animblend == blend || player.animblend < attack_a || my.animblend > attack_f) { my.hit_by_player = 0; }
}
IF (player.animblend >= stand && target_enemy == my && player_lock_on == 0) && (player.animblend < attack_a || player.animblend > attack_f) { target_enemy = null; }
IF (target_enemy == my && vec_dist(my.x,player.x) > 600) { target_enemy = null; }
wait(1);
while (my.health > 0) // as long as I'm alive
{
if (vec_dist (my.x, player.x) < 600)&& (player != null) // the player approaches the enemy
{
vec_set(temp, player.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
c_move(my,vector(5*time,0,0),my.move_x,use_aabb | ignore_passable | glide);
ent_animate(my,"walk", my.skill20,anm_cycle); // play walk frames animation
my.skill20 += 5 * time_step; // "walk" animation speed
if (vec_dist (my.x, player.x)< 70)&& (player != null) // if the player comes closer attack him
{
snd_play(club_snd,50,0);
my.skill21 = 0; // reset "attack" frames
while (my.skill21 < 100)&& (player != null)
{
ent_vertex(my.weapon_tip, 54); // weapon tip vertex coords - get the value in Med
ent_vertex(my.weapon_base, 244); // weapon base vertex coords - get the value in Med
c_trace (my.weapon_base, my.weapon_tip, ignore_me | ignore_passable|use_box);
if (result != 0) ///made a hit
{
player.health -= 1; // it causes an empty pointer situation if you place the you pointer so just replace it with player
hit_sound();
}
ent_animate(my,"attack", my.skill21,0); // play attack frames animation
my.skill21 += 2 * time_step; // "attack" animation speed
wait (1);
}
}
}
else // the player is farther away
{
if(player.health < 0)
{
proc_kill(4);
}
ent_animate(my,"stand", my.skill21,anm_cycle); // play stand frames animation
my.skill21 += 2 * time_step; // "stand" animation speed
}
wait (1);
}
}
}
Another bug I found out is when you're dead, the player is still able to move around and kill the rest of the enemies ^^
Btw, this version uses the extra code that JazzDude edited later.
Cheers
Frazzle