bullets thru walls

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!
Posted By: vartan_s

Re: bullets thru walls - 05/16/06 15:29

Anyone got any ideas? It's killing me!
Posted By: Cemper

Re: bullets thru walls - 05/16/06 17:24

I think, the mistake is at
Quote:

ent_create(bullethole_pcx,temp,bullet_hole);



Just write:
Code:
ent_create(bullethole.pcx,temp,bullet_hole)



Not sure if that was it, I have A5 so I don't know much about the A6-Skriptlanguage.
Posted By: vartan_s

Re: bullets thru walls - 05/16/06 18:03

nope, that isn't it... bullethole_pcx is a string with the filename, and besides it works fine the first time, its just that walls are ignored afterwards.
Posted By: testDummy

Re: bullets thru walls - 05/16/06 19:40

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.
Posted By: vartan_s

Re: bullets thru walls - 05/17/06 12:13

Wow.... I somehow, at first, suspected it was dangerous code, which is why I submitted it here. However, it's not.

It's not an error like that because the bullet would stop at the wall. This leaves passable and push. It's not passable, because the player still collides with the wall.

It's push:

When I made a shotgun code, I gave each of the bullets a push number, which if you made over 1 bullet this push went down for each.(so they couldn't collide with each other). I watched the variable that controlled push, and indeed after the first time its push became 1. I stopped this, and everything is fine now.

Just goes to show, that a bit of logical thinking can do wonders... Thanks for the contributions anyway, and I'll consider dangerous instructions more carefully in the future too.
© 2024 lite-C Forums