|
Ever notice how in Unreal Tournament you can have a centered gun without having it hidden? Let's hack the same thing into Quake 2! Open cl_ents.c, look for CL_AddViewWeapon. Before it, add this: // RIOT - Centered gun extern cvar_t *hand; In the CL_AddViewWeapon function, look for the block:
for (i=0 ; i<3 ; i++)
{
gun.origin[i] = cl.refdef.vieworg[i] + ops->gunoffset[i]
+ cl.lerpfrac * (ps->gunoffset[i] - ops->gunoffset[i]);
gun.angles[i] = cl.refdef.viewangles[i] + LerpAngle (ops->gunangles[i],
ps->gunangles[i], cl.lerpfrac);
}
After it, add this:
// RIOT - Centered gun
if(hand->value == 2.0f)
{
// Get the movement
AngleVectors(gun.angles, NULL, anglemove, anglemove2);
// Move the gun
VectorScale(anglemove, -8.0f, anglemove);
VectorScale(anglemove2, -5.0f, anglemove2);
VectorAdd(gun.origin, anglemove, gun.origin);
VectorAdd(gun.origin, anglemove2, gun.origin);
}
Okay, now to add support for it in the rendering code. For software mode, open r_alias.c, look for this block of code in R_AliasDrawModel:
if ( currententity->flags & RF_WEAPONMODEL )
{
if ( r_lefthand->value == 1.0F )
aliasxscale = -aliasxscale;
else if ( r_lefthand->value == 2.0F )
return;
}
Change that to:
if ( currententity->flags & RF_WEAPONMODEL )
{
if ( r_lefthand->value == 1.0F )
aliasxscale = -aliasxscale;
// RIOT - Centered gun
//else if ( r_lefthand->value == 2.0F )
// return;
}
For OpenGL mode, open gl_mesh.c, and in R_DrawAliasModel, look for the block:
if ( e->flags & RF_WEAPONMODEL )
{
if ( r_lefthand->value == 2 )
return;
}
Comment that out. And that's all! Enjoy Q2 with a centered gun! |