/*
===============
CalcMuzzlePoint
set muzzle location relative to pivoting eye
===============
*/
void CalcMuzzlePoint( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint )
{
VectorCopy( ent->s.pos.trBase, muzzlePoint );
muzzlePoint[ 2 ] += ent->client->ps.viewheight;
VectorMA( muzzlePoint, 1, forward, muzzlePoint );
VectorMA( muzzlePoint, 1, right, muzzlePoint );
// snap to integer coordinates for more efficient network bandwidth usage
SnapVector( muzzlePoint );
}
OK, here we have our little CalcMuzzlePoint() function.
My question is: Why does it do what it does?
This function is used in like every firing/attacking function for humans and aliens:
// set aiming directions
AngleVectors( ent->client->ps.viewangles, forward, right, up );
CalcMuzzlePoint( ent, forward, right, up, muzzle );
As far as I understand AngleVectors(), it takes your basic viewing angles, and generates 3 vectors: forward: it points to the direction you're looking, right: points to the right of you, parallel with the ground you're standing on (note: wallwalkers), and up: upward, usually to the sky (note: wallwalkers). The vectors are guaranteed to be nomalized.
After that's done, we call CalcMuzzlePoint() to calculate muzzlePoint,
our result, where we're shooting/slashing/biting from.
We copy the center of our model, and then add the viewheight to get the position of our eye. (Wallwalkers must have 0 viewheigth, or this will not work.)
Next, what the hell are
VectorMA( muzzlePoint, 1, forward, muzzlePoint );
VectorMA( muzzlePoint, 1, right, muzzlePoint );
??2?!1!
What does Quake 3 use? Well, Quake 3 uses
VectorMA( muzzlePoint, 14, forward, muzzlePoint );
to locate the end of your gun. This is only relevant to the shotgun, so that the pellets don't start widely spread when shooting a wall from up close to it, and the rocket launcher (only a bit).
If this is an attempt to facilitate the rounding to integers in the SnapVector() function, it's seriously overlooked. right and forward may be all-positive, mixed or all-negative, depending on your looking directions.
The human model is 30x30x56 in size, the dretch is 30x30x30. Moving the muzzlePoint to the forward-right direction sqrt(2) far, is not noticable, and useless. I'd say use Q3 code (warning: alien attack range += 13) or nothing, to leave exact center coordinates.
THX
// dev