Posted By: vartan_s
bullets thru walls - 05/16/06 13:20
Ok, i have a problem which is hurting my head. I've tried dissecting the code, removing parts of it, to no avail. You see, the first time I hit a wall, it removes itself and creates a bullet hole. The second time, it goes through the wall and keeps going... no bullet hole, nothing! Here's the 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){
move_mode = ignore_you;
ent_move (my.skill5, nullvector);
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);
}
ent_remove(me);
} else {
ent_remove(me);
}
} 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);
c_move(my, bullet_hole_distance, nullvector, null);
ent_create(bullethole_pcx,temp,bullet_hole);
ent_remove(me);
}
}
Even if you hit an entity first time, and a wall the 2nd time, it goes through the wall.. The beep is there for debugging purposes, and proves that the remove_bullet code isn't activated the 2nd time...
Anyway, it always hits an entity... its just the event_block... level geometry
Please help me... my head's aching! And sorry if its a noobish question!
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){
move_mode = ignore_you;
ent_move (my.skill5, nullvector);
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);
}
ent_remove(me);
} else {
ent_remove(me);
}
} 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);
c_move(my, bullet_hole_distance, nullvector, null);
ent_create(bullethole_pcx,temp,bullet_hole);
ent_remove(me);
}
}
Even if you hit an entity first time, and a wall the 2nd time, it goes through the wall.. The beep is there for debugging purposes, and proves that the remove_bullet code isn't activated the 2nd time...
Anyway, it always hits an entity... its just the event_block... level geometry
Please help me... my head's aching! And sorry if its a noobish question!