3 registered members (TedMar, Ayumi, kzhao),
1,359
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
bullets thru walls
#74333
05/16/06 13:20
05/16/06 13:20
|
Joined: Apr 2006
Posts: 265
vartan_s
OP
Member
|
OP
Member
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]
#74335
05/16/06 17:24
05/16/06 17:24
|
Joined: Jan 2006
Posts: 179
Cemper
Member
|
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: vartan_s]
#74337
05/16/06 19:40
05/16/06 19:40
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
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
vartan_s
OP
Member
|
OP
Member
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.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|