Gamestudio Links
Zorro Links
Newest Posts
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Ayumi, howardR), 499 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
bullets thru walls #74333
05/16/06 13:20
05/16/06 13:20
Joined: Apr 2006
Posts: 265
V
vartan_s Offline OP
Member
vartan_s  Offline OP
Member
V

Joined: Apr 2006
Posts: 265
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!

Last edited by vartan_s; 05/16/06 13:22.
Re: bullets thru walls [Re: vartan_s] #74334
05/16/06 15:29
05/16/06 15:29
Joined: Apr 2006
Posts: 265
V
vartan_s Offline OP
Member
vartan_s  Offline OP
Member
V

Joined: Apr 2006
Posts: 265
Anyone got any ideas? It's killing me!

Re: bullets thru walls [Re: vartan_s] #74335
05/16/06 17:24
05/16/06 17:24
Joined: Jan 2006
Posts: 179
Cemper Offline
Member
Cemper  Offline
Member

Joined: Jan 2006
Posts: 179
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.


Was nie begonnen, kann auch nie scheitern. (Mit anderen Worten: Leg dich aufs Sofa und sieh fern )
Re: bullets thru walls [Re: Cemper] #74336
05/16/06 18:03
05/16/06 18:03
Joined: Apr 2006
Posts: 265
V
vartan_s Offline OP
Member
vartan_s  Offline OP
Member
V

Joined: Apr 2006
Posts: 265
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.

Re: bullets thru walls [Re: vartan_s] #74337
05/16/06 19:40
05/16/06 19:40
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
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.

Re: bullets thru walls [Re: testDummy] #74338
05/17/06 12:13
05/17/06 12:13
Joined: Apr 2006
Posts: 265
V
vartan_s Offline OP
Member
vartan_s  Offline OP
Member
V

Joined: Apr 2006
Posts: 265
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.


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1