Quote:
Originally Posted by hellmonja
What I intend to do is when a player fires a gun, 4 points forming a cross relative to his coordinates will be the origin of the emitted sound. Height is fixed by the way, just +100.0 of the players coord. All I did was duplicate the code four times with 4 different combinations of coordinates:
|
So you want a sound to match muzzle blast? In other words the opposite of Bullet Whizz which is on the receiving end.
Quote:
Originally Posted by hellmonja
So far emit_sound needs an entity to produce the sound from. I'm wondering if you can emit a sound in 3D space using just coordinates. Is there a separate function for this? Or module of sorts I don't know of?...
|
The sound doesn't need 4 more ents when you already have 1, the player there firing the weapon.
These 2 figures show what 50 looks like from the abstract from either using pev_origin or get_user_origin. Former is standing over the head while other is piggy back ride at 50.
Code:
new Float:origin[3];
pev(id,pev_origin,origin);
new Float:mins[3], Float:maxs[3]
mins[0] = origin[0] - 15.0
mins[1] = origin[1] - 15.0
mins[2] = origin[2] + 25.0
maxs[0] = origin[0] + 15.0
maxs[1] = origin[1] + 15.0
maxs[2] = origin[2] + 2.0
message_begin(0,23);
write_byte(TE_BOX);
write_coord(floatround(mins[0]));
write_coord(floatround(mins[1]));
write_coord(floatround(mins[2]));
write_coord(floatround(maxs[0]));
write_coord(floatround(maxs[1]));
write_coord(floatround(maxs[2]));
write_short(random_num(500,1000)); //(life in 0.1's)
write_byte(random_num(50,255)); //(red)
write_byte(random_num(50,255)); //(green)
write_byte(random_num(0,255)); //(blue)
message_end();

By the way 5 sounds being fired off per round may cause performance issues. Emit already emits. Quit while you are ahead. The code you are using accomplishes the same as emit_sound but it is a while lot more complex and easier to crash sending messages instead of simply using emit_sound. You are over-complicating not using emit_sound just to reinvent the wheel with this. The sound still passes through the player just a few coordinates away. So then, it is here, instead of there. The oth dimension {0,0,0} is what you see 99.9% of the code around the world over. Just a dot. Moving outside the box is not that complicated. You have your chickens to help you do that now.
Use MSG_
PAS as it will use least resources. MSG_ONE sends it to people on other side of map who can't hear it anyway as well as increase crash likelihood down the line.
__________________