Compass-Minimap same as Call of Duty 2

Posted By: Ladlass

Compass-Minimap same as Call of Duty 2 - 07/30/18 19:23

Hi guys, I am trying to make a minimap where the player is in the center and when we rotate the compass rotates too like cod2. But I couldn't make it, I am a newbie, I searched the forum but find nothing solid and useful, can you guys help me with example code or anything I can learn how to make my own.

Thanks
Posted By: Dooley

Re: Compass-Minimap same as Call of Duty 2 - 07/31/18 04:56

These are the resources I try to use, to the best of my ability, in order of priority:

The Manual
Template Scripts included in GStudio7 (or 8) folder
AUM Magazine (it has a lot of older C-Script code, but sometimes it can be easily converted to Lite-C)
Ask here on the forum once all other options have been attempted

Good luck!
Posted By: Ayumi

Re: Compass-Minimap same as Call of Duty 2 - 07/31/18 09:24

First i would try make a Bitmap as BMP with a black cycle and only Text "N, S,W,E" (North, South, West, East) to test.

Than create a Panel with your Position and add this Bitmap to your Panel. Your Bitmap Needs same size in x and y or you Need to set Panel Center_x/Center_y.

Code:
PANEL* PanCompass = 
{
   bmap = bmap_create("Compass.bmp");
   pos_x = 0;
   pos_y = 0;
   flags |= SHOW;   
}





Put your Player in WED to any place.
In a while, you only Need to set "pan" from Player to your Panel.

Code:
while(1)
{
   PanCompass.angle = player.pan - 90; // test it...i only guess
   wait(1);
}



Think about, Panel.angle isn t same as players pan. That means, if Players pan is North, the Degree is 90, not 0.

The second part is calculate the position from Player.
If i have time, i will build an example.
Posted By: Ladlass

Re: Compass-Minimap same as Call of Duty 2 - 07/31/18 10:49

Thank you so much Ayumi, that example for the position would be awesome if you have time.
Posted By: Ayumi

Re: Compass-Minimap same as Call of Duty 2 - 08/01/18 19:10

Here you are. Give your Entitys in WED skill 1 a counter (1,2,3...)
This example works with C_Scan, but you also can do it with vec_dist or c_trace in another while. C_scan is slow but easy to use.

Paint a Bitmap with 256 x 256 Pixel + Alpha Channel. This will be the Compass.
Paint a Bitmap with 256 x 256 Pixel + Alpha Channel (only Alpha). This will be your second Panel for your Entitys.
The second Panel is need, because maybe you later want rotate the pan of your Enemys too. In the first Panel it s not possible, because you also rotate this Panel.

I also need this Code, so later i will code a newer version without c_scan. So far.


Code:
// EntGroups
#define EntGroup skill1
#define TypeEnemy 1

#define EntGroupType skill2
#define Machine 1
#define People 2


var EntsPan[3];

PANEL* PanCompass = 
{
	bmap = "Compass.dds";
	pos_x = 10;
	pos_y = 10;
	layer = 1;
}

PANEL* PanCompassEnemys = 
{
	bmap = "CompassEnemy.dds";
	needle(22,22, "Enemy.pcx",8,8,0,0,360, EntsPan[0]);
	needle(22,22, "Enemy.pcx",8,8,0,0,360, EntsPan[1]);
	needle(22,22, "Enemy.pcx",8,8,0,0,360, EntsPan[2]);
	pos_x = 10;
	pos_y = 10;
	layer = 2;
}



action Enemy()
{
	my.emask |= ENABLE_SCAN;
}

void ScanEvent()
{
	if(event_type == EVENT_DETECT)
	{
		if(you != NULL)
		{
			// 5000 Quants Scanbereich
			// 256 Pixel beträgt die Bitmap
		
		  	var x = player.x - you.x;
		  	var y = player.y - you.y;
		  	var newX = 0;
		  	var newY = 0;
	   
		  	newX = abs(x);
		  	newY = abs(y)* -1;
		  	if(player.x > you.x)
		  	{
		  		newX = abs(x) * -1;
			}
		  
		   if(player.y > you.y)
		   {
		   	newY = abs(y) ;
			}
			
		  	var rangeX = (newX * 128) / 5000;
		  	var rangeY = (newY * 128) / 5000;
//		  	
//			printf("%f %f", (double)x, (double)y);
			pan_setpos(PanCompassEnemys, 6, you.EntGroup, vector(rangeX +128, rangeY+128, 0));							
		}
	}
}

void RotateCompassPan()
{	
	while(player)
	{
		PanCompass.angle = player.pan -90;
		wait(1);	
	}
}

void RotateCompass()
{
	while(player == NULL) wait(10);
	my = player;
	
	my.emask |= ENABLE_DETECT;
	my.event = ScanEvent;

	RotateCompassPan();

	wait(-2);
	
	while(player)
	{	
		c_scan(camera.x,camera.pan, vector(360,0,10000), IGNORE_ME | SCAN_ENTS | SCAN_LIMIT);
		wait(-0.5);
	}
}

void InitializeMinimap()
{
	PanCompass.flags = SHOW|TRANSLUCENT;
	PanCompass.center_x = PanCompass.size_x * 0.5;
	PanCompass.center_y = PanCompass.size_y * 0.5;
	PanCompassEnemys.flags = SHOW|TRANSLUCENT;

	RotateCompass();
}

Posted By: Ladlass

Re: Compass-Minimap same as Call of Duty 2 - 08/04/18 15:48

Hi Ayumi, when I rotate the second pan, the needles of it won't rotate with the panel, they stay at the same position. Can you help?
Posted By: Ayumi

Re: Compass-Minimap same as Call of Duty 2 - 08/04/18 16:40

It s an Panel, you should take the online manual ,looking and learning yourself.

Panel -> Panel elements -> Needles ->
"Needles can not be displayed on rotated panels"
Posted By: Ladlass

Re: Compass-Minimap same as Call of Duty 2 - 08/04/18 22:30

Thanks again, I made it as I wanted.
© 2024 lite-C Forums