Can this be done?
Moderators: Forum moderators, developers
Can this be done?
Making the reticles for the mortar transparent so that azimuth is visible? I have no clue how to code or any ability/ means to, but I was looking at the cg_draw file in the source code trying to see if maybe they left a unfinished portion but being the coding idiot I am, I have no clue what I'm looking at. Is it anyway possible to get this to work since I know the previous firing coords show up on the mortar reticle?
- mortis
- Posts: 360
- Joined: Tue Jul 06, 2004 11:57 pm
- Location: at the center of the e-universe
- Contact:
I'm pretty sure that it COULD be done, if there is some way to reference the firing coordinates at the time the mortar is fired. The you would have to superimpose an icon on the GUI of the mortar azimuth of the last shot fired. My skill is not sufficient to code such things, but maybe some of the people around these parts might have a more informed answer...
it can be done but it sux
I got used to use the left side of the vertical bar to aim. works as well as using the middle, just different values to remember.
Alternatively the values could be displayed in another little box (fpscounterstyle) => H62,5:V56,8
but this is kind of making it too easy for mortars to aim. so it will probably never be realized
No,it is just done clientside, but the files need to be updated on the server as well in order to use it.
Code: Select all
/*
==============
CG_DrawMortarReticle
==============
*/
static void CG_DrawMortarReticle( void ) {
vec4_t color = { 1.f, 1.f, 1.f, .5f };
vec4_t color_back = { 0.f, 0.f, 0.f, .25f };
vec4_t color_extends = { .77f, .73f, .1f, 1.f };
vec4_t color_lastfire = { .77f, .1f, .1f, 1.f };
//vec4_t color_firerequest = { .23f, 1.f, .23f, 1.f };
vec4_t color_firerequest = { 1.f, 1.f, 1.f, 1.f };
float offset, localOffset;
int i, min, majorOffset, val, printval, fadeTime;
char *s;
float angle, angleMin, angleMax;
qboolean hasRightTarget, hasLeftTarget;
// Deus start
float x, y;
int w;
vec4_t mortarBackground = { 0.16f, 0.2f, 0.17f, 0.8f };
vec4_t mortarBorder = { 0.5f, 0.5f, 0.5f, 0.5f };
vec4_t mclr = { 0.625f, 0.625f, 0.6f, 1.0f };
// Deus end
// Background
CG_FillRect( 136, 236, 154, 38, color_back );
CG_FillRect( 290, 160, 60, 208, color_back );
CG_FillRect( 350, 236, 154, 38, color_back );
// Horizontal bar
// bottom
//Deus start
// CG_FillRect( 140, 264, 150, 1, color); // left
// CG_FillRect( 350, 264, 150, 1, color); // right
CG_FillRect( 140, 264, 360, 1, color); // left + middle + right
CG_FillRect( 320, 230, 2, 16, color); // a center line to know where center is ;)
// Deus end
// 10 units - 5 degrees
// total of 360 units
// nothing displayed between 150 and 210 units
// 360 / 10 = 36 bits, means 36 * 5 = 180 degrees
// that means left is cg.predictedPlayerState.viewangles[YAW] - .5f * 180
angle = 360 - AngleNormalize360(cg.predictedPlayerState.viewangles[YAW] - 90.f);
// Deus start
x = angle; // copy angle to x
// Deus end
offset = (5.f / 65536) * ((int)(angle * (65536 / 5.f)) & 65535);
min = (int)(AngleNormalize360(angle - .5f * 180) / 15.f) * 15;
majorOffset = (int)(floor((int)floor(AngleNormalize360(angle - .5f * 180)) % 15) / 5.f );
for( val = i = 0; i < 36; i++ ) {
localOffset = i * 10.f + (offset * 2.f);
// Deus start
// if( localOffset >= 150 && localOffset <= 210 ) { // Disabled to display the whole
// if( i % 3 == majorOffset)
// val++;
// continue;
// }
// Deus end
if( i % 3 == majorOffset) {
printval = min - val * 15 + 180;
// rain - old tertiary abuse was nasty and had undefined result
if (printval < 0)
printval += 360;
else if (printval >= 360)
printval -= 360;
s = va( "%i", printval );
//CG_Text_Paint_Ext( 140 + localOffset - .5f * CG_Text_Width_Ext( s, .15f, 0, &cgs.media.limboFont1 ), 244, .15f, .15f, color, s, 0, 0, 0, &cgs.media.limboFont1 );
//CG_FillRect( 140 + localOffset, 248, 1, 16, color);
CG_Text_Paint_Ext( 500 - localOffset - .5f * CG_Text_Width_Ext( s, .15f, 0, &cgs.media.limboFont1 ), 244, .15f, .15f, color, s, 0, 0, 0, &cgs.media.limboFont1 );
CG_FillRect( 500 - localOffset, 248, 1, 16, color);
val++;
} else {
//CG_FillRect( 140 + localOffset, 256, 1, 8, color);
CG_FillRect( 500 - localOffset, 256, 1, 8, color);
}
}
// the extremes
// 30 degrees plus a 15 degree border
angleMin = AngleNormalize360(360 - (cg.pmext.mountedWeaponAngles[YAW] - 90.f) - (30.f + 15.f));
angleMax = AngleNormalize360(360 - (cg.pmext.mountedWeaponAngles[YAW] - 90.f) + (30.f + 15.f));
// right
localOffset = (AngleNormalize360(angle - angleMin) / 5.f ) * 10.f;
//CG_FillRect( 320 + localOffset, 252, 2, 18, color_extends);
CG_FillRect( 320 - localOffset, 252, 2, 18, color_extends);
// left
localOffset = (AngleNormalize360(angleMax - angle) / 5.f ) * 10.f;
//CG_FillRect( 320 - localOffset, 252, 2, 18, color_extends);
CG_FillRect( 320 + localOffset, 252, 2, 18, color_extends);
// last fire pos
fadeTime = 0;
if( cg.lastFiredWeapon == WP_MORTAR_SET && cg.mortarImpactTime >= -1 ) {
fadeTime = cg.time - (cg.predictedPlayerEntity.muzzleFlashTime + 5000);
if( fadeTime < 3000 ) {
float lastfireAngle;
if( fadeTime > 0 ) {
color_lastfire[3] = 1.f - (fadeTime/3000.f);
}
lastfireAngle = AngleNormalize360(360 - (cg.mortarFireAngles[YAW] - 90.f));
localOffset = ( ( AngleSubtract( angle, lastfireAngle ) ) / 5.f ) * 10.f;
//CG_FillRect( 320 + localOffset, 252, 2, 18, color_lastfire);
CG_FillRect( 320 - localOffset, 252, 2, 18, color_lastfire);
}
}
// mortar attack requests
hasRightTarget = hasLeftTarget = qfalse;
for( i = 0; i < MAX_CLIENTS; i++ ) {
int requestFadeTime = cg.time - (cg.artilleryRequestTime[i] + 25000);
if( requestFadeTime < 5000 ) {
vec3_t dir;
float yaw;
float attackRequestAngle;
VectorSubtract( cg.artilleryRequestPos[i], cg.predictedPlayerEntity.lerpOrigin, dir );
// ripped this out of vectoangles
if( dir[1] == 0 && dir[0] == 0 ) {
yaw = 0;
} else {
if( dir[0] ) {
yaw = ( atan2 ( dir[1], dir[0] ) * 180 / M_PI );
}
else if ( dir[1] > 0 ) {
yaw = 90;
}
else {
yaw = 270;
}
if ( yaw < 0 ) {
yaw += 360;
}
}
if( requestFadeTime > 0 ) {
color_firerequest[3] = 1.f - (requestFadeTime/5000.f);
}
attackRequestAngle = AngleNormalize360(360 - (yaw - 90.f));
yaw = AngleSubtract( attackRequestAngle, angleMin );
if( yaw < 0 ) {
if( !hasLeftTarget ) {
//CG_FillRect( 136 + 2, 236 + 38 - 6, 4, 4, color_firerequest );
trap_R_SetColor( color_firerequest );
CG_DrawPic( 136 + 2, 236 + 38 - 10 + 1, 8, 8, cgs.media.ccMortarTargetArrow );
trap_R_SetColor( NULL );
hasLeftTarget = qtrue;
}
} else if( yaw > 90 ) {
if( !hasRightTarget ) {
//CG_FillRect( 350 + 154 - 6, 236 + 38 - 6, 4, 4, color_firerequest );
trap_R_SetColor( color_firerequest );
CG_DrawPic( 350 + 154 - 10, 236 + 38 - 10 + 1, -8, 8, cgs.media.ccMortarTargetArrow );
trap_R_SetColor( NULL );
hasRightTarget = qtrue;
}
} else {
localOffset = ( ( AngleSubtract( angle, attackRequestAngle ) ) / 5.f ) * 10.f;
//CG_FillRect( 320 + localOffset - 3, 264 - 3, 6, 6, color_firerequest );
trap_R_SetColor( color_firerequest );
//CG_DrawPic( 320 + localOffset - 8, 264 - 8, 16, 16, cgs.media.ccMortarTarget );
CG_DrawPic( 320 - localOffset - 8, 264 - 8, 16, 16, cgs.media.ccMortarTarget );
trap_R_SetColor( NULL );
}
}
}
/*s = va( "%.2f (%i / %i)",AngleNormalize360(angle - .5f * 180), majorOffset, min );
CG_Text_Paint( 140, 224, .25f, color, s, 0, 0, 0 );
s = va( "%.2f",AngleNormalize360(angle) );
CG_Text_Paint( 320 - .5f * CG_Text_Width( s, .25f, 0), 224, .25f, color, s, 0, 0, 0 );
s = va( "%.2f", AngleNormalize360(angle + .5f * 180) );
CG_Text_Paint( 500 - CG_Text_Width( s, .25f, 0 ), 224, .25f, color, s, 0, 0, 0 );*/
// Vertical bar
// sides
CG_FillRect( 295, 164, 1, 200, color); // left
CG_FillRect( 345, 164, 1, 200, color); // right
// 10 units - 2.5 degrees
// total of 200 units
// 200 / 10 = 20 bits, means 20 * 2.5 = 50 degrees
// that means left is cg.predictedPlayerState.viewangles[PITCH] - .5f * 50
angle = AngleNormalize180(360 - (cg.predictedPlayerState.viewangles[PITCH] - 60));
// Deus start
y = angle; // copy angle to y
// Deus end
offset = (2.5f / 65536) * ((int)(angle * (65536 / 2.5f)) & 65535);
min = floor((angle + .5f * 50) / 10.f) * 10;
majorOffset = (int)(floor((int)((angle + .5f * 50) * 10.f) % 100) / 25.f );
for( val = i = 0; i < 20; i++ ) {
localOffset = i * 10.f + (offset * 4.f);
/*if( localOffset >= 150 && localOffset <= 210 ) {
if( i % 3 == majorOffset)
val++;
continue;
}*/
if( i % 4 == majorOffset ) {
printval = min - val * 10;
// rain - old tertiary abuse was nasty and had undefined result
if (printval <= -180)
printval += 360;
else if (printval >= 180)
printval -= 180;
s = va( "%i", printval );
CG_Text_Paint_Ext( 320 - .5f * CG_Text_Width_Ext( s, .15f, 0, &cgs.media.limboFont1 ), 164 + localOffset + .5f * CG_Text_Height_Ext( s, .15f, 0, &cgs.media.limboFont1 ), .15f, .15f, color, s, 0, 0, 0, &cgs.media.limboFont1 );
CG_FillRect( 295 + 1, 164 + localOffset, 12, 1, color);
CG_FillRect( 345 - 12, 164 + localOffset, 12, 1, color);
val++;
} else {
CG_FillRect( 295 + 1, 164 + localOffset, 8, 1, color);
CG_FillRect( 345 - 8, 164 + localOffset, 8, 1, color);
}
}
// the extremes
// 30 degrees up
// 20 degrees down
angleMin = AngleNormalize180(360 - (cg.pmext.mountedWeaponAngles[PITCH] - 60)) - 20.f;
angleMax = AngleNormalize180(360 - (cg.pmext.mountedWeaponAngles[PITCH] - 60)) + 30.f;
// top
localOffset = angleMax - angle;
if( localOffset < 0 )
localOffset = 0;
localOffset = (AngleNormalize360(localOffset) / 2.5f ) * 10.f;
if( localOffset < 100 ) {
CG_FillRect( 295 - 2, 264 - localOffset, 6, 2, color_extends);
CG_FillRect( 345 - 4 + 1, 264 - localOffset, 6, 2, color_extends);
}
// bottom
localOffset = angle - angleMin;
if( localOffset < 0 )
localOffset = 0;
localOffset = (AngleNormalize360(localOffset) / 2.5f ) * 10.f;
if( localOffset < 100 ) {
CG_FillRect( 295 - 2, 264 + localOffset, 6, 2, color_extends);
CG_FillRect( 345 - 4 + 1, 264 + localOffset, 6, 2, color_extends);
}
// last fire pos
if( cg.lastFiredWeapon == WP_MORTAR_SET && cg.mortarImpactTime >= -1 ) {
if( fadeTime < 3000 ) {
float lastfireAngle;
lastfireAngle = AngleNormalize180(360 - (cg.mortarFireAngles[PITCH] - 60));
if( lastfireAngle > angle ) {
localOffset = lastfireAngle - angle;
if( localOffset < 0 )
localOffset = 0;
localOffset = (AngleNormalize360(localOffset) / 2.5f ) * 10.f;
if( localOffset < 100 ) {
CG_FillRect( 295 - 2, 264 - localOffset, 6, 2, color_lastfire);
CG_FillRect( 345 - 4 + 1, 264 - localOffset, 6, 2, color_lastfire);
}
} else {
localOffset = angle - lastfireAngle;
if( localOffset < 0 )
localOffset = 0;
localOffset = (AngleNormalize360(localOffset) / 2.5f ) * 10.f;
if( localOffset < 100 ) {
CG_FillRect( 295 - 2, 264 + localOffset, 6, 2, color_lastfire);
CG_FillRect( 345 - 4 + 1, 264 + localOffset, 6, 2, color_lastfire);
}
}
}
}
// Deus start
// display the info in a box
s = va( "H:%3.1f V:%3.1f", x, y );
w = CG_Text_Width_Ext( s, 0.19f, 0, &cgs.media.limboFont1 );
CG_FillRect( 360 - 2, 214, w + 5, 12 + 2, mortarBackground );
CG_DrawRect_FixedBorder( 360 - 2, 214, w + 5, 12 + 2, 1, mortarBorder );
CG_Text_Paint_Ext( 360, 214 + 11, 0.19f, 0.19f, mclr, s, 0, 0, 0, &cgs.media.limboFont1 );
// Deus end
/*s = va( "%.2f (%i / %i)", angle + .5f * 50, majorOffset, min );
CG_Text_Paint( 348, 164, .25f, color, s, 0, 0, 0 );
s = va( "%.2f",angle );
CG_Text_Paint( 348, 264, .25f, color, s, 0, 0, 0 );
s = va( "%.2f", angle - .5f * 50 );
CG_Text_Paint( 348, 364, .25f, color, s, 0, 0, 0 );*/
}
- RoadKillPuppy
- Posts: 207
- Joined: Thu Apr 08, 2004 9:21 am
- Location: Belgium!
- Contact:
i was referring to the possibility of adding the feature by putting in a pk3.bacon wrote:Well considering that CG_ is client side it would be one hell of a trick for that to be server side...
deus's mod changes the clientside binary, thus it would only be combinable with etmain, or other mods that does not include a modified clientside binary.
other mods could obviously, use the piece of code (with deus' approval of course) to add the feature.
hope that clears things up