Hello, I've coded something that might be interesting. It adds a white blip on the alien radar when wallwalking, which indicates the direction of the ground. Add the following snippets of code in the CG_AlienSense function in cgame/cg_scanner.c:
vec3_t drawOrigin;
vec3_t normal, noZnormal;
vec3_t view, antiview;
vec3_t ground = {0.0f, 0.0f, -1.0f}, noZground;
vec4_t ground_color = { 1.0f, 1.0f, 1.0f, 0.7f };
vec3_t up = { 0.0f, 0.0f, 1.0f };
vec3_t top = { 0.0f, -1.0f, 0.0f };
float product, angle;
playerState_t *ps = &cg.snap->ps;
after the declaration of variables, and
if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBING )
{
if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING )
VectorSet( normal, 0.0f, 0.0f, -1.0f );
else
VectorCopy( ps->grapplePoint, normal );
AngleVectors( entityPositions.vangles, view, NULL, NULL );
ProjectPointOnPlane( noZnormal, normal, view );
VectorNormalize( noZnormal );
ProjectPointOnPlane( noZground, ground, view );
VectorNormalize( noZground );
product = DotProduct( noZground, noZnormal );
if (product < -1.0f)
angle = -180.0f;
else if (product > 1.0f) angle = 0.0f;
else
{
angle = RAD2DEG(acos(product));
CrossProduct( noZnormal, noZground, antiview );
VectorNormalize( antiview );
if (DotProduct(view, antiview) > 0.0f)
angle = 360.0f - angle;
}
RotatePointAroundVector( drawOrigin, up, top, angle );
trap_R_SetColor( ground_color );
CG_DrawPic( rect->x + ( rect->w / 2 ) - ( BLIPX2 / 2 ) - drawOrigin[ 0 ] * ( rect->w / 2 ),
rect->y + ( rect->h / 2 ) - ( BLIPY2 / 2 ) + drawOrigin[ 1 ] * ( rect->h / 2 ),
BLIPX2, BLIPY2, cgs.media.scannerBlipShader );
trap_R_SetColor( NULL );
}
at the end of the function.
EDIT: I had to edit this post with BBCode disabled because it was screwing up my code.