The only problem is that the screen size throws it off completely. If I get it worknig for a large screenshot it doesn't work for a large screen size.
I am posting my code below, maybe you can see something I missed. You can also steal it if you want :P.
Code: Select all
if((cg.predictedPlayerState.powerups[PW_SPREAD] &&
((cg.predictedPlayerState.weapon==WP_MACHINEGUN)||
(cg.predictedPlayerState.weapon==WP_RAILGUN)||
(cg.predictedPlayerState.weapon==WP_LIGHTNING)||
(cg.predictedPlayerState.weapon==WP_ROCKET_LAUNCHER)||
(cg.predictedPlayerState.weapon==WP_PLASMAGUN)||
(cg.predictedPlayerState.weapon==WP_BFG)||
(cg.predictedPlayerState.weapon==WP_SHOTGUN))))
{
trace_t tr, tr2;
float adjacent, hypothenuse, opposite, angle;// width, offset,
vec3_t forward, right, up, muzzle, endpoint, endpoint2, angles, dir, dir1, dir2;
angle = 10;
VectorCopy( cg.snap->ps.origin, muzzle );
muzzle[2] += cg.snap->ps.viewheight;
AngleVectors( cg.snap->ps.viewangles, forward, NULL, NULL );
VectorMA( muzzle, 14, forward, muzzle );
AngleVectors( cg.refdefViewAngles, forward, right, up );
VectorMA(muzzle, 8191, forward, endpoint);
CG_Trace( &tr, muzzle, NULL, NULL, endpoint, cg.clientNum, MASK_SHOT );
VectorSubtract(tr.endpos, muzzle, dir1);
adjacent = VectorLength( dir1 );
vectoangles(dir1, angles);
VectorMA(forward, 0.1, right, dir);
VectorMA(muzzle, 8191, dir, endpoint2);
CG_Trace( &tr2, muzzle, NULL, NULL, endpoint2, cg.clientNum, MASK_SHOT );
VectorSubtract(tr2.endpos, muzzle, dir2);
hypothenuse = VectorLength( dir2);
//CORNCOBMAN - trigonometry turned out to be useful afterall, *<8O)
opposite = (cg.refdef.width * cg.refdef.width) + (hypothenuse * -sin(angle));
opposite = ((opposite / (cg.refdef.width / 7.3)) / cg.refdef.fov_x) - 8;
// CG_Printf(va("opposite1: %f\n", opposite));
opposite *= cgs.screenXScale;
trap_R_DrawStretchPic( x + cg.refdef.x + opposite + 0.5 * (cg.refdef.width - d),
y + cg.refdef.y + 0.5 * (cg.refdef.height - d),
d, d, 0, 0, 1, 1, hShader );
VectorMA(forward, -0.1, right, dir);
VectorMA(muzzle, 8191, dir, endpoint2);
CG_Trace( &tr2, muzzle, NULL, NULL, endpoint2, cg.clientNum, MASK_SHOT );
VectorSubtract(tr2.endpos, muzzle, dir2);
hypothenuse = VectorLength( dir2);
opposite = (cg.refdef.width * cg.refdef.width) + (hypothenuse * -sin(angle));
opposite = ((opposite / (cg.refdef.width / 7.3)) / cg.refdef.fov_x) - 8;
opposite *= cgs.screenXScale;
trap_R_DrawStretchPic( x + cg.refdef.x - opposite + 0.5 * (cg.refdef.width - d),
y + cg.refdef.y + 0.5 * (cg.refdef.height - d),
d, d, 0, 0, 1, 1, hShader );
}
//END CORNCOBMAN