Can this be done?

Discussion for Bani's Tournament Mod

Moderators: Forum moderators, developers

Gork
Posts: 9
Joined: Sun May 01, 2005 8:50 pm

Can this be done?

Post by Gork »

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?
User avatar
mortis
Posts: 360
Joined: Tue Jul 06, 2004 11:57 pm
Location: at the center of the e-universe
Contact:

Post by mortis »

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...
Gork
Posts: 9
Joined: Sun May 01, 2005 8:50 pm

Post by Gork »

I was thinking more of having the degrees become transparent so that they could be read while looking at the degrees... Or maybe a counter beside the reticle that shows the azimuth...
User avatar
Deus
Posts: 1053
Joined: Fri Mar 12, 2004 2:24 am
Location: Germany
Contact:

Post by Deus »

Image

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
Gork
Posts: 9
Joined: Sun May 01, 2005 8:50 pm

Post by Gork »

hmmm ok, So its possible... I assume it's server side only?
With the little box, does it show the azimuth and degree in a box instead of the reticle?
And if you don't mind, how'd you do it; ie:what did you change?
User avatar
Deus
Posts: 1053
Joined: Fri Mar 12, 2004 2:24 am
Location: Germany
Contact:

Post by Deus »

No,it is just done clientside, but the files need to be updated on the server as well in order to use it.
Image

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&#40; val = i = 0; i < 36; i++ &#41; &#123;
		localOffset = i * 10.f + &#40;offset * 2.f&#41;;

	// Deus start
	//	if&#40; localOffset >= 150 && localOffset <= 210 &#41; &#123; // Disabled to display the whole
	//		if&#40; i % 3 == majorOffset&#41;
	//			val++;
	//		continue;
	//	&#125;
	// Deus end

		if&#40; i % 3 == majorOffset&#41; &#123;
			printval = min - val * 15 + 180;
			
			// rain - old tertiary abuse was nasty and had undefined result
			if &#40;printval < 0&#41;
				printval += 360;
			else if &#40;printval >= 360&#41;
				printval -= 360;

			s = va&#40; "%i", printval &#41;;
			//CG_Text_Paint_Ext&#40; 140 + localOffset - .5f * CG_Text_Width_Ext&#40; s, .15f, 0, &cgs.media.limboFont1 &#41;, 244, .15f, .15f, color, s, 0, 0, 0, &cgs.media.limboFont1 &#41;;
			//CG_FillRect&#40; 140 + localOffset, 248, 1, 16, color&#41;;
			CG_Text_Paint_Ext&#40; 500 - localOffset - .5f * CG_Text_Width_Ext&#40; s, .15f, 0, &cgs.media.limboFont1 &#41;, 244, .15f, .15f, color, s, 0, 0, 0, &cgs.media.limboFont1 &#41;;
			CG_FillRect&#40; 500 - localOffset, 248, 1, 16, color&#41;;
			val++;
		&#125; else &#123;
			//CG_FillRect&#40; 140 + localOffset, 256, 1, 8, color&#41;;
			CG_FillRect&#40; 500 - localOffset, 256, 1, 8, color&#41;;			
		&#125;
	&#125;

	// the extremes
	// 30 degrees plus a 15 degree border
	angleMin = AngleNormalize360&#40;360 - &#40;cg.pmext.mountedWeaponAngles&#91;YAW&#93; - 90.f&#41; - &#40;30.f + 15.f&#41;&#41;;
	angleMax = AngleNormalize360&#40;360 - &#40;cg.pmext.mountedWeaponAngles&#91;YAW&#93; - 90.f&#41; + &#40;30.f + 15.f&#41;&#41;;

	// right
	localOffset = &#40;AngleNormalize360&#40;angle - angleMin&#41; / 5.f &#41; * 10.f;
	//CG_FillRect&#40; 320 + localOffset, 252, 2, 18, color_extends&#41;;
	CG_FillRect&#40; 320 - localOffset, 252, 2, 18, color_extends&#41;;

	// left
	localOffset = &#40;AngleNormalize360&#40;angleMax - angle&#41; / 5.f &#41; * 10.f;
	//CG_FillRect&#40; 320 - localOffset, 252, 2, 18, color_extends&#41;;
	CG_FillRect&#40; 320 + localOffset, 252, 2, 18, color_extends&#41;;

	// last fire pos
	fadeTime = 0;
	if&#40; cg.lastFiredWeapon == WP_MORTAR_SET && cg.mortarImpactTime >= -1 &#41; &#123;
		fadeTime = cg.time - &#40;cg.predictedPlayerEntity.muzzleFlashTime + 5000&#41;;

		if&#40; fadeTime < 3000 &#41; &#123;
			float lastfireAngle;

			if&#40; fadeTime > 0 &#41; &#123;
				color_lastfire&#91;3&#93; = 1.f - &#40;fadeTime/3000.f&#41;;
			&#125;

			lastfireAngle = AngleNormalize360&#40;360 - &#40;cg.mortarFireAngles&#91;YAW&#93; - 90.f&#41;&#41;;

			localOffset = &#40; &#40; AngleSubtract&#40; angle, lastfireAngle &#41; &#41; / 5.f &#41; * 10.f;
			//CG_FillRect&#40; 320 + localOffset, 252, 2, 18, color_lastfire&#41;;
			CG_FillRect&#40; 320 - localOffset, 252, 2, 18, color_lastfire&#41;;
		&#125;
	&#125;

	// mortar attack requests
	hasRightTarget = hasLeftTarget = qfalse;
	for&#40; i = 0; i < MAX_CLIENTS; i++ &#41; &#123;
		int requestFadeTime = cg.time - &#40;cg.artilleryRequestTime&#91;i&#93; + 25000&#41;;

		if&#40; requestFadeTime < 5000 &#41; &#123;
			vec3_t dir;
			float yaw;
			float attackRequestAngle;

			VectorSubtract&#40; cg.artilleryRequestPos&#91;i&#93;, cg.predictedPlayerEntity.lerpOrigin, dir &#41;;

			// ripped this out of vectoangles
			if&#40; dir&#91;1&#93; == 0 && dir&#91;0&#93; == 0 &#41; &#123;
				yaw = 0;
			&#125; else &#123;
				if&#40; dir&#91;0&#93; &#41; &#123;
					yaw = &#40; atan2 &#40; dir&#91;1&#93;, dir&#91;0&#93; &#41; * 180 / M_PI &#41;;
				&#125;
				else if &#40; dir&#91;1&#93; > 0 &#41; &#123;
					yaw = 90;
				&#125;
				else &#123;
					yaw = 270;
				&#125;
				if &#40; yaw < 0 &#41; &#123;
					yaw += 360;
				&#125;
			&#125;

			if&#40; requestFadeTime > 0 &#41; &#123;
				color_firerequest&#91;3&#93; = 1.f - &#40;requestFadeTime/5000.f&#41;;
			&#125;

			attackRequestAngle = AngleNormalize360&#40;360 - &#40;yaw - 90.f&#41;&#41;;

			yaw = AngleSubtract&#40; attackRequestAngle, angleMin &#41;;

			if&#40; yaw < 0 &#41; &#123;
				if&#40; !hasLeftTarget &#41; &#123;
					//CG_FillRect&#40; 136 + 2, 236 + 38 - 6, 4, 4, color_firerequest &#41;;

					trap_R_SetColor&#40; color_firerequest &#41;;
					CG_DrawPic&#40; 136 + 2, 236 + 38 - 10 + 1, 8, 8, cgs.media.ccMortarTargetArrow &#41;;
					trap_R_SetColor&#40; NULL &#41;;

					hasLeftTarget = qtrue;
				&#125;
			&#125; else if&#40; yaw > 90 &#41; &#123;
				if&#40; !hasRightTarget &#41; &#123;
					//CG_FillRect&#40; 350 + 154 - 6, 236 + 38 - 6, 4, 4, color_firerequest &#41;;

					trap_R_SetColor&#40; color_firerequest &#41;;
					CG_DrawPic&#40; 350 + 154 - 10, 236 + 38 - 10 + 1, -8, 8, cgs.media.ccMortarTargetArrow &#41;;
					trap_R_SetColor&#40; NULL &#41;;

					hasRightTarget = qtrue;
				&#125;
			&#125; else &#123;
				localOffset = &#40; &#40; AngleSubtract&#40; angle, attackRequestAngle &#41; &#41; / 5.f &#41; * 10.f;
				//CG_FillRect&#40; 320 + localOffset - 3, 264 - 3, 6, 6, color_firerequest &#41;;

				trap_R_SetColor&#40; color_firerequest &#41;;
 				//CG_DrawPic&#40; 320 + localOffset - 8, 264 - 8, 16, 16, cgs.media.ccMortarTarget &#41;;
				CG_DrawPic&#40; 320 - localOffset - 8, 264 - 8, 16, 16, cgs.media.ccMortarTarget &#41;;
				trap_R_SetColor&#40; NULL &#41;;
			&#125;
		&#125;
	&#125;

 	/*s = va&#40; "%.2f &#40;%i / %i&#41;",AngleNormalize360&#40;angle - .5f * 180&#41;, majorOffset, min &#41;;
	CG_Text_Paint&#40; 140, 224, .25f, color, s, 0, 0, 0 &#41;;
	s = va&#40; "%.2f",AngleNormalize360&#40;angle&#41; &#41;;
	CG_Text_Paint&#40; 320 - .5f * CG_Text_Width&#40; s, .25f, 0&#41;, 224, .25f, color, s, 0, 0, 0 &#41;;
	s = va&#40; "%.2f", AngleNormalize360&#40;angle + .5f * 180&#41; &#41;;
	CG_Text_Paint&#40; 500 - CG_Text_Width&#40; s, .25f, 0 &#41;, 224, .25f, color, s, 0, 0, 0 &#41;;*/

	// Vertical bar

	// sides
	CG_FillRect&#40; 295, 164, 1, 200, color&#41;;	// left
	CG_FillRect&#40; 345, 164, 1, 200, color&#41;;	// 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&#91;PITCH&#93; - .5f * 50
	angle = AngleNormalize180&#40;360 - &#40;cg.predictedPlayerState.viewangles&#91;PITCH&#93; - 60&#41;&#41;;
	// Deus start
	y = angle;	// copy angle to y
	// Deus end

	offset = &#40;2.5f / 65536&#41; * &#40;&#40;int&#41;&#40;angle * &#40;65536 / 2.5f&#41;&#41; & 65535&#41;;
	min = floor&#40;&#40;angle + .5f * 50&#41; / 10.f&#41; * 10;
	majorOffset = &#40;int&#41;&#40;floor&#40;&#40;int&#41;&#40;&#40;angle + .5f * 50&#41; * 10.f&#41; % 100&#41; / 25.f &#41;;

	for&#40; val = i = 0; i < 20; i++ &#41; &#123;
		localOffset = i * 10.f + &#40;offset * 4.f&#41;;

		/*if&#40; localOffset >= 150 && localOffset <= 210 &#41; &#123;
			if&#40; i % 3 == majorOffset&#41;
				val++;
			continue;
		&#125;*/

		if&#40; i % 4 == majorOffset &#41; &#123;
			printval = min - val * 10;
			
			// rain - old tertiary abuse was nasty and had undefined result
			if &#40;printval <= -180&#41;
				printval += 360;
			else if &#40;printval >= 180&#41;
				printval -= 180;

			s = va&#40; "%i", printval &#41;;
			CG_Text_Paint_Ext&#40; 320 - .5f * CG_Text_Width_Ext&#40; s, .15f, 0, &cgs.media.limboFont1 &#41;, 164 + localOffset + .5f * CG_Text_Height_Ext&#40; s, .15f, 0, &cgs.media.limboFont1 &#41;, .15f, .15f, color, s, 0, 0, 0, &cgs.media.limboFont1 &#41;;
			CG_FillRect&#40; 295 + 1, 164 + localOffset, 12, 1, color&#41;;
			CG_FillRect&#40; 345 - 12, 164 + localOffset, 12, 1, color&#41;;
			val++;
		&#125; else &#123;
			CG_FillRect&#40; 295 + 1, 164 + localOffset, 8, 1, color&#41;;
			CG_FillRect&#40; 345 - 8, 164 + localOffset, 8, 1, color&#41;;
		&#125;
	&#125;

	// the extremes
	// 30 degrees up
	// 20 degrees down
	angleMin = AngleNormalize180&#40;360 - &#40;cg.pmext.mountedWeaponAngles&#91;PITCH&#93; - 60&#41;&#41; - 20.f;
	angleMax = AngleNormalize180&#40;360 - &#40;cg.pmext.mountedWeaponAngles&#91;PITCH&#93; - 60&#41;&#41; + 30.f;

	// top
	localOffset = angleMax - angle;
	if&#40; localOffset < 0 &#41;
		localOffset = 0;
	localOffset = &#40;AngleNormalize360&#40;localOffset&#41; / 2.5f &#41; * 10.f;
	if&#40; localOffset < 100 &#41; &#123;
		CG_FillRect&#40; 295 - 2, 264 - localOffset, 6, 2, color_extends&#41;;
		CG_FillRect&#40; 345 - 4 + 1, 264 - localOffset, 6, 2, color_extends&#41;;
	&#125;

	// bottom
	localOffset = angle - angleMin;
	if&#40; localOffset < 0 &#41;
		localOffset = 0;
	localOffset = &#40;AngleNormalize360&#40;localOffset&#41; / 2.5f &#41; * 10.f;
	if&#40; localOffset < 100 &#41; &#123;
		CG_FillRect&#40; 295 - 2, 264 + localOffset, 6, 2, color_extends&#41;;
		CG_FillRect&#40; 345 - 4 + 1, 264 + localOffset, 6, 2, color_extends&#41;;
	&#125;

	// last fire pos
	if&#40; cg.lastFiredWeapon == WP_MORTAR_SET && cg.mortarImpactTime >= -1 &#41; &#123;
		if&#40; fadeTime < 3000 &#41; &#123;
			float lastfireAngle;

			lastfireAngle = AngleNormalize180&#40;360 - &#40;cg.mortarFireAngles&#91;PITCH&#93; - 60&#41;&#41;;

			if&#40; lastfireAngle > angle &#41; &#123;
				localOffset = lastfireAngle - angle;
				if&#40; localOffset < 0 &#41;
					localOffset = 0;
				localOffset = &#40;AngleNormalize360&#40;localOffset&#41; / 2.5f &#41; * 10.f;
				if&#40; localOffset < 100 &#41; &#123;
					CG_FillRect&#40; 295 - 2, 264 - localOffset, 6, 2, color_lastfire&#41;;
					CG_FillRect&#40; 345 - 4 + 1, 264 - localOffset, 6, 2, color_lastfire&#41;;
				&#125;
			&#125; else &#123;
				localOffset = angle - lastfireAngle;
				if&#40; localOffset < 0 &#41;
					localOffset = 0;
				localOffset = &#40;AngleNormalize360&#40;localOffset&#41; / 2.5f &#41; * 10.f;
				if&#40; localOffset < 100 &#41; &#123;
					CG_FillRect&#40; 295 - 2, 264 + localOffset, 6, 2, color_lastfire&#41;;
					CG_FillRect&#40; 345 - 4 + 1, 264 + localOffset, 6, 2, color_lastfire&#41;;
				&#125;
			&#125;
		&#125;
	&#125;
 
	// Deus start
	// display the info in a box
	s = va&#40; "H&#58;%3.1f V&#58;%3.1f", x, y &#41;;
	w = CG_Text_Width_Ext&#40; s, 0.19f, 0, &cgs.media.limboFont1 &#41;;

	CG_FillRect&#40; 360 - 2, 214, w + 5, 12 + 2, mortarBackground &#41;;
	CG_DrawRect_FixedBorder&#40; 360 - 2, 214, w + 5, 12 + 2, 1, mortarBorder &#41;;

	CG_Text_Paint_Ext&#40; 360, 214 + 11, 0.19f, 0.19f, mclr, s, 0, 0, 0, &cgs.media.limboFont1 &#41;;
	// Deus end


	/*s = va&#40; "%.2f &#40;%i / %i&#41;", angle + .5f * 50, majorOffset, min &#41;;
	CG_Text_Paint&#40; 348, 164, .25f, color, s, 0, 0, 0 &#41;;
	s = va&#40; "%.2f",angle &#41;;
	CG_Text_Paint&#40; 348, 264, .25f, color, s, 0, 0, 0 &#41;;
	s = va&#40; "%.2f", angle - .5f * 50 &#41;;
	CG_Text_Paint&#40; 348, 364, .25f, color, s, 0, 0, 0 &#41;;*/
&#125;
FraUz
Posts: 33
Joined: Fri Jan 09, 2004 12:22 am
Location: Italy
Contact:

Post by FraUz »

I love this stuff :shock:
User avatar
RoadKillPuppy
Posts: 207
Joined: Thu Apr 08, 2004 9:21 am
Location: Belgium!
Contact:

Post by RoadKillPuppy »

That little box is some sweet little mod !!
User avatar
mortis
Posts: 360
Joined: Tue Jul 06, 2004 11:57 pm
Location: at the center of the e-universe
Contact:

Post by mortis »

That's awesome Deus. Is there an easy way to pack that into a stand-alone pk3, or would it have to be integrated in etpro?
User avatar
Lagger
Posts: 316
Joined: Mon Sep 29, 2003 8:30 am

Post by Lagger »

since the changes are in the source code, i'm pretty confident that deus made the modification for etmain. so yes you could do that with any serverside-mod or etmain.

the etpro developers would have to integrate it into etpro for it to work there though...
Gork
Posts: 9
Joined: Sun May 01, 2005 8:50 pm

Post by Gork »

Gah the box is amazing thanks Deus...
Now only if there was an option in ETPro to use it... :angel:
bacon
Posts: 549
Joined: Sat Apr 19, 2003 9:34 pm
Contact:

Post by bacon »

Lagger wrote:so yes you could do that with any serverside-mod or etmain.
Well considering that CG_ is client side it would be one hell of a trick for that to be server side...
Gork
Posts: 9
Joined: Sun May 01, 2005 8:50 pm

Post by Gork »

So is it a client side change or a server side?
User avatar
Lagger
Posts: 316
Joined: Mon Sep 29, 2003 8:30 am

Post by Lagger »

bacon wrote:Well considering that CG_ is client side it would be one hell of a trick for that to be server side...
i was referring to the possibility of adding the feature by putting in a pk3.
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 :)
>>steven!
Posts: 645
Joined: Mon Jul 12, 2004 4:00 am
Location: Merseyside, UK
Contact:

Post by >>steven! »

imo should be added to etpro // as a cvar would mean leagues could decide whether to allow it or not.

great on pubs for newbies to learn how to use mortar tho
UK Elite Guard
#ukeg on Quakenet
www.ukeliteguard.co.uk
Est. Jan 2002
Post Reply