Code:
function shoot_bullet() // activated when you click your mouse
{
my.push = push_factor_change;
if (push_factor_change == -10-weapon_in_play_pellets)
{
push_factor_change = -10;
}
my.enable_entity = on;
my.enable_block = on;
my.skill4 = weapon_in_play_damage;
my.skill5 = weapon_in_play_bullet_speed;
randomize();
my.pan = camera.pan + random(weapon_in_play_acc_change) - random(weapon_in_play_acc_change);
my.tilt = camera.tilt + random(weapon_in_play_acc_change) - random(weapon_in_play_acc_change);
my.event = remove_bullet;
while(1){ // Bad form. Exit the while loop when the bullet makes a hit and remove it after the loop.
move_mode = ignore_you;
ent_move (my.skill5, nullvector);
wait(1);
}
}
// Dangerous instructions 101. No mutator methods in events without wait(1).
function remove_bullet()
{
beep();
my.enable_entity = off;
my.enable_block = off;
if (EVENT_TYPE == EVENT_ENTITY)
{
if (you.skill1 == 1)
{
you.skill2 -= my.skill4;
if (you.skill2 <= 0)
{
ent_remove(you); // no remove in event without wait(1)
}
ent_remove(me); // no remove in event without wait(1)
} else {
ent_remove(me); // no remove in event without wait(1)
}
} else {
vec_set (temp, my.x);
temp.x = my.x + 1000;
trace_mode = ignore_passable + ignore_me + ignore_push;
bullet_hole_distance = trace (my.x, temp);
vec_set(temp.x,normal.x);
Do you really want collision for bullet holes? I wouldn't use c_move for bullet holes.
c_move(my, bullet_hole_distance, nullvector, null); // no move in event without wait(1)
ent_create(bullethole_pcx,temp,bullet_hole); // no create in event without wait(1)
ent_remove(me); // Could you fit any more mutator methods in this event? NO remove without wait(1)
}
Maybe you should try to search for the term "Dangerous Instruction" in the manual.