Exemplo n.º 1
0
float _ARX_TIME_GetTime()
{
	LARGE_INTEGER liPerfCounter;

	_ARX_TIME_Init();

	QueryPerformanceCounter(&liPerfCounter);
	return ARX_CLEAN_WARN_CAST_FLOAT((liPerfCounter.QuadPart / (double)liFrequency.QuadPart) * 1000);

}
Exemplo n.º 2
0
void AddPoisonFog(EERIE_3D * pos, float power)
{
	int iDiv = 2;

	if (pMenuConfig)
	{
		iDiv += 2 - pMenuConfig->iLevelOfDetails;
	}

	float flDiv =	ARX_CLEAN_WARN_CAST_FLOAT(1 << iDiv);
	ARX_CHECK_LONG(FrameDiff / flDiv);
	long count	=	ARX_CLEAN_WARN_CAST_LONG(FrameDiff / flDiv);

	if (count < 1) count = 1;

	while (count) 
	{
		count--;
		long j = ARX_PARTICLES_GetFree();

		if ((j != -1) && (!ARXPausedTimer) && (rnd() * 2000.f < power))
		{
			ParticleCount++;
			particle[j].special		=	FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
			particle[j].exist		=	TRUE;
			particle[j].zdec		=	0;
			particle[j].ov.x		=	pos->x + 100.f - 200.f * rnd();
			particle[j].ov.y		=	pos->y + 100.f - 200.f * rnd();
			particle[j].ov.z		=	pos->z + 100.f - 200.f * rnd();
			float speed				=	1.f;
			float fval				=	speed * DIV5;
			particle[j].scale.x		=	particle[j].scale.y		=	particle[j].scale.z		=	10.f;
			particle[j].move.x		=	(speed - rnd()) * fval;
			particle[j].move.y		=	(speed - speed * rnd()) * DIV15;
			particle[j].move.z		=	(speed - rnd()) * fval;
			particle[j].scale.x		=	particle[j].scale.y		=	8;
			particle[j].timcreation	=	ARX_CLEAN_WARN_CAST_LONG(ARX_TIME_Get());
			particle[j].tolive		=	4500 + (unsigned long)(rnd() * 4500);
			particle[j].tc			=	TC_smoke;
			particle[j].siz			=	(80 + rnd() * 80 * 2.f) * DIV3;
			particle[j].r			=	rnd() * DIV3;
			particle[j].g			=	1.f;
			particle[j].b			=	rnd() * DIV10;
			particle[j].fparam		=	0.001f;
		}
	}
}
Exemplo n.º 3
0
//*************************************************************************************
//*************************************************************************************
void ARX_FOGS_Render(long init)
{
	if (ARXPausedTimer) return;

	int iDiv = 2;

	if (pMenuConfig)
	{
		iDiv += 2 - pMenuConfig->iLevelOfDetails;
	}

	float flDiv = ARX_CLEAN_WARN_CAST_FLOAT(1 << iDiv);

	for (long i = 0; i < MAX_FOG; i++)
	{
		if (fogs[i].exist)
		{
			unsigned long offs;
			float fval;

			offs = 0;
		

			ARX_CHECK_LONG(FrameDiff / flDiv);
			long count	=	ARX_CLEAN_WARN_CAST_LONG(FrameDiff / flDiv);


			if (count < 1) count = 1;

			while (count)
			{
				count--;
				long j = ARX_PARTICLES_GetFree();

				if ((j != -1) && (rnd() * 2000.f < (float)fogs[i].frequency))
				{
					ParticleCount++;
					particle[j].special = FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
					particle[j].exist = TRUE;
					particle[j].zdec = 0;

					if (fogs[i].special & FOG_DIRECTIONAL)
					{
						particle[j].ov.x = fogs[i].pos.x;
						particle[j].ov.y = fogs[i].pos.y;
						particle[j].ov.z = fogs[i].pos.z;
						fval = fogs[i].speed * DIV10;
						particle[j].move.x = (fogs[i].move.x * fval);
						particle[j].move.y = (fogs[i].move.y * fval);
						particle[j].move.z = (fogs[i].move.z * fval);
					}
					else
					{
						particle[j].ov.x = fogs[i].pos.x + 100.f - 200.f * rnd();
						particle[j].ov.y = fogs[i].pos.y + 100.f - 200.f * rnd();
						particle[j].ov.z = fogs[i].pos.z + 100.f - 200.f * rnd();
						fval = fogs[i].speed * DIV5;
						particle[j].move.x = (fogs[i].speed - rnd() * 2.f) * fval;
						particle[j].move.y = (fogs[i].speed - rnd() * 2.f) * DIV15;
						particle[j].move.z = (fogs[i].speed - rnd() * 2.f) * fval;
					}

					particle[j].scale.x		=	particle[j].scale.y		=	particle[j].scale.z		=	fogs[i].scale;
					particle[j].timcreation	=	lARXTime;
					particle[j].tolive		=	fogs[i].tolive + (unsigned long)(rnd() * fogs[i].tolive);
					particle[j].tc			=	TC_smoke;
					particle[j].siz			=	(fogs[i].size + rnd() * fogs[i].size * 2.f) * DIV3;
					particle[j].r			=	fogs[i].rgb.r;
					particle[j].g			=	fogs[i].rgb.g;
					particle[j].b			=	fogs[i].rgb.b;
					particle[j].fparam		=	fogs[i].rotatespeed;
				}

				fogs[i].lastupdate = ARXTimeUL(); 
			}
		}
	}
}
Exemplo n.º 4
0
////////////////////////////////////////////////////////////////////////////////////
//					ALTERNATIVE METHOD
void AnchorData_Create_Alternative_Method_I(EERIE_BACKGROUND * eb)
{
	char text[256];
	AnchorData_ClearAll(eb);
	EERIE_BKG_INFO * eg;
	EERIEPOLY * ep;
	EERIE_3D pos;
	long k;
	float count = 0;

	long lastper	=	-1;
	long per;
	float total		=	ARX_CLEAN_WARN_CAST_FLOAT(eb->Zsize * eb->Xsize * 4);

	for (long j = 0; j < eb->Zsize; j++)
		for (long i = 0; i < eb->Xsize; i++)
		{
			long LASTFOUND = 0;

			for (long divv = 0; divv < 4; divv++)
			{
				long divvx, divvy;

				switch (divv)
				{
					case 0:
						divvx = 0;
						divvy = 0;
						break;
					case 1:
						divvx = 1;
						divvy = 1;
						break;
					case 2:
						divvx = 0;
						divvy = 1;
						break;
					case 3:
						divvx = 1;
						divvy = 0;
						break;
				}

				float current_y = 99999999999.f;
				F2L((float)count / total * 100.f, &per);

				if (per != lastper)
				{
					sprintf(text, "Anchor Generation: %d%%", per);
					lastper = per;
					_ShowText(text);
				}

				count += 1.f;
				danaeApp.WinManageMess();

				if (LASTFOUND) break;

				eg = &eb->Backg[i+j*eb->Xsize];
				pos.x = (float)((float)((float)i + 0.5f * (float)divvx) * (float)eb->Xdiv);
				pos.y = 0.f;
				pos.z = (float)((float)((float)j + 0.5f * (float)divvy) * (float)eb->Zdiv);
				ep = GetMinPoly(pos.x, pos.y, pos.z);
				k = 0;
				EERIE_CYLINDER currcyl;
				currcyl.radius = 20 - (4.f * divv);
				currcyl.height = -120.f;
				currcyl.origin.x = pos.x;
				currcyl.origin.y = pos.y;
				currcyl.origin.z = pos.z;

				if (ep)
				{

					EERIEPOLY * epmax;
					epmax = GetMaxPoly(pos.x, pos.y, pos.z);
					float roof = 9999999.f;

					if (ep) roof = ep->min.y - 300;

					if (epmax) roof = epmax->min.y - 300;

					current_y = ep->max.y;

					while (current_y > roof)
					{
						currcyl.origin.y = current_y;
						EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 30.f, currcyl.origin.z);

						if (ep2 && !(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f))
							ep2 = NULL;

						if ((ep2) && !(ep2->type & POLY_NOPATH))
						{
							BOOL bval = ANCHOR_AttemptValidCylinderPos(&currcyl, NULL, CFLAG_NO_INTERCOL | CFLAG_EXTRA_PRECISION | CFLAG_RETURN_HEIGHT | CFLAG_ANCHOR_GENERATION);

							if ((bval)
							        && (currcyl.origin.y - 10.f <= current_y))
							{
								EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 38.f, currcyl.origin.z);

								if (ep2 && !(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f))
								{
									current_y -= 10.f;
								}
								else if ((ep2) && (ep2->type & POLY_NOPATH))
								{
									current_y -= 10.f;
								}
								else if (AddAnchor_Original_Method(eb, eg, &currcyl.origin, 0))
								{
									LASTFOUND++;
									current_y = currcyl.origin.y + currcyl.height;
								}
								else current_y -= 10.f;
							}
							else current_y -= 10.f;
						}
						else current_y -= 10.f;

					}
				}
			}
		}

	AnchorData_Create_Phase_II_Original_Method(eb);
	AnchorData_Create_Links_Original_Method(eb);

	/* TO KEEP
		// Parses Anchors to refine anchor creation...
		long ii,ia,ji,ja;
		EERIE_3D p1,p2;
		EERIE_BKG_INFO * eg2;
		count=0;


		total=eb->Zsize*eb->Xsize;
		long usable=0;
		if (0)
		for (j=0;j<eb->Zsize;j++)
		for (long i=0;i<eb->Xsize;i++)
		{
			F2L((float)count/(float)total*100.f,&per);
			if (per!=lastper)
			{
				sprintf(text,"Anchor Generation Pass II: %d%% Suitable %d",per,usable);
				lastper=per;
				_ShowText(text);
			}
			count++;
			eg=&eb->Backg[i+j*eb->Xsize];
			for (long k=0;k<eg->nbianchors;k++)
			{
				ii=i-2;
				ia=i+2;
				ji=j-2;
				ja=j+2;
				FORCERANGE(ii,0,eb->Xsize-1);
				FORCERANGE(ia,0,eb->Xsize-1);
				FORCERANGE(ji,0,eb->Zsize-1);
				FORCERANGE(ja,0,eb->Zsize-1);
				for (long j2=ji;j2<=ja;j2++)
				for (long i2=ii;i2<=ia;i2++)
				{
					eg2=&eb->Backg[i2+j2*eb->Xsize];
					for (long k2=0;k2<eg2->nbianchors;k2++)
					{
						// don't treat currently treated anchor
						if (eg->ianchors[k] == eg2->ianchors[k2]) continue;
						memcpy(&p1,&eb->anchors[eg->ianchors[k]].pos,sizeof(EERIE_3D));
						memcpy(&p2,&eb->anchors[eg2->ianchors[k2]].pos,sizeof(EERIE_3D));
						p1.y+=10.f;
						p2.y+=10.f;
						float dist=TRUEEEDistance3D(&p1,&p2);
						if (dist>120.f) continue;
						if (EEfabs(p1.y-p2.y)>80.f) continue;
						if ((eb->anchors[eg->ianchors[k]].radius>=40)
							&& (eb->anchors[eg2->ianchors[k2]].radius>=40)) 
							continue;
						{
							// found 2 usable anchors
							EERIE_3D pos;
							pos.x=(p1.x+p2.x)*DIV2;
							pos.y=(p1.y+p2.y)*DIV2;
							pos.z=(p1.z+p2.z)*DIV2;
							if (AddAnchor(eb,eg,&pos,MUST_BE_BIG))
								usable++;
						}
					}
				}
			}
		}*/

}
Exemplo n.º 5
0
void AnchorData_Create_Original_Method(EERIE_BACKGROUND * eb)
{
	char text[256];
	AnchorData_ClearAll(eb);
	EERIE_BKG_INFO * eg;
	EERIEPOLY * ep;
	EERIE_3D pos;
#define DECALLL 20.f
	long k;
	float count = 0;
	long lastper	=	-1;
	long per;
	float total		=	ARX_CLEAN_WARN_CAST_FLOAT(eb->Zsize * eb->Xsize * 9);

	for (long j = 0; j < eb->Zsize; j++)
		for (long i = 0; i < eb->Xsize; i++)
		{
			long LASTFOUND = 0;

			for (long divv = 0; divv < 9; divv++)
			{
				long divvx, divvy;

				switch (divv)
				{
					case 0:
						divvx = 0;
						divvy = 0;
						break;
					case 1:
						divvx = 1;
						divvy = 0;
						break;
					case 2:
						divvx = 2;
						divvy = 0;
						break;
					case 3:
						divvx = 0;
						divvy = 1;
						break;
					case 4:
						divvx = 1;
						divvy = 1;
						break;
					case 5:
						divvx = 2;
						divvy = 1;
						break;
					case 6:
						divvx = 0;
						divvy = 2;
						break;
					case 7:
						divvx = 1;
						divvy = 2;
						break;
					case 8:
						divvx = 2;
						divvy = 2;
						break;

				}

				float current_y = 99999999999.f;
				F2L((float)count / total * 100.f, &per);

				if (per != lastper)
				{
					sprintf(text, "Anchor Generation: %d%%", per);
					lastper = per;
					_ShowText(text);
				}

				count += 1.f;
				danaeApp.WinManageMess();

				if (LASTFOUND) break;

				eg = &eb->Backg[i+j*eb->Xsize];
				pos.x = (float)((float)((float)i + 0.33f * (float)divvx) * (float)eb->Xdiv);
				pos.y = 0.f;
				pos.z = (float)((float)((float)j + 0.33f * (float)divvy) * (float)eb->Zdiv);
				ep = GetMinPoly(pos.x, pos.y, pos.z);
				k = 0;
				EERIE_CYLINDER currcyl;
				currcyl.radius = 20 - (4.f * divv);
				currcyl.height = -120.f;
				currcyl.origin.x = pos.x;
				currcyl.origin.y = pos.y;
				currcyl.origin.z = pos.z;

				if (ep)
				{

					EERIEPOLY * epmax;
					epmax = GetMaxPoly(pos.x, pos.y, pos.z);
					float roof = 9999999.f;

					if (ep) roof = ep->min.y - 300;

					if (epmax) roof = epmax->min.y - 300;

					current_y = ep->max.y;

					while (current_y > roof)
					{
						currcyl.origin.y = current_y;
						EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 30.f, currcyl.origin.z);

						if (ep2 && !(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f))
							ep2 = NULL;

						if ((ep2) && !(ep2->type & POLY_NOPATH))
						{
							BOOL bval = ANCHOR_AttemptValidCylinderPos(&currcyl, NULL, CFLAG_NO_INTERCOL | CFLAG_EXTRA_PRECISION | CFLAG_RETURN_HEIGHT | CFLAG_ANCHOR_GENERATION);

							if ((bval)
							        && (currcyl.origin.y - 10.f <= current_y))
							{
								EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 38.f, currcyl.origin.z);

								if (ep2 && !(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f))
								{
									current_y -= 10.f;
								}
								else if ((ep2) && (ep2->type & POLY_NOPATH))
								{
									current_y -= 10.f;
								}
								else if (AddAnchor_Original_Method(eb, eg, &currcyl.origin, 0))
								{
									LASTFOUND++;
									current_y = currcyl.origin.y + currcyl.height;
								}
								else current_y -= 10.f;
							}
							else current_y -= 10.f;
						}
						else current_y -= 10.f;
					}
				}
			}
		}

	AnchorData_Create_Phase_II_Original_Method(eb);
	AnchorData_Create_Links_Original_Method(eb);
}
Exemplo n.º 6
0
void AnchorData_Create_Phase_II_Original_Method(EERIE_BACKGROUND * eb)
{
	char text[256];
	EERIE_BKG_INFO * eg;
	EERIE_3D pos;
	long k;
	float count = 0;


	long lastper	=	-1;
	long per;
	float total		=	ARX_CLEAN_WARN_CAST_FLOAT(eb->Zsize * eb->Xsize);

	for (long j = 0; j < eb->Zsize; j++)
		for (long i = 0; i < eb->Xsize; i++)
		{
			float current_y = 99999999999.f;
			F2L((float)count / total * 100.f, &per);

			if (per != lastper)
			{
				sprintf(text, "Anchor Generation: %d%% (Pass II)", per);
				lastper = per;
				_ShowText(text);
			}

			count += 1.f;
			danaeApp.WinManageMess();

			eg = &eb->Backg[i+j*eb->Xsize];
			pos.x = (float)((float)((float)i) * (float)eb->Xdiv);
			pos.y = 0.f;
			pos.z = (float)((float)((float)j) * (float)eb->Zdiv);
			k = 0;
			EERIE_CYLINDER currcyl;
			currcyl.radius = 30;
			currcyl.height = -150.f;
			currcyl.origin.x = pos.x;
			currcyl.origin.y = pos.y;
			currcyl.origin.z = pos.z;

			if (eg->nbpolyin)
			{
				long ok = 0;

				for (long kkk = 0; kkk < eg->nbpolyin; kkk++)
				{
					EERIEPOLY * ep = eg->polyin[kkk];

					if (ep->type & POLY_PRECISE_PATH)
					{
						ok = 1;
						break;
					}
				}

				if (!ok) continue;

				float roof = GetTileMinY(i, j); 
				current_y = GetTileMaxY(i, j); 

				while (current_y > roof)
				{
					long added = 0;

					for (float pposz = 0.f; pposz < 1.f; pposz += 0.1f)
						for (float pposx = 0.f; pposx < 1.f; pposx += 0.1f)
						{
							currcyl.origin.x = pos.x + pposx * eb->Xdiv;
							currcyl.origin.z = pos.z + pposz * eb->Zdiv;
							currcyl.origin.y = current_y;

							EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 10.f, currcyl.origin.z);

							if (!ep2)
								continue;

							if (!(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f))
								continue;

							if (ep2->type & POLY_NOPATH)
								continue;

							if (ANCHOR_AttemptValidCylinderPos(&currcyl, NULL, CFLAG_NO_INTERCOL | CFLAG_EXTRA_PRECISION | CFLAG_RETURN_HEIGHT | CFLAG_ANCHOR_GENERATION))
							{
								EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 10.f, currcyl.origin.z);

								if (!ep2)
									continue;

								if (!(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f))
									continue;

								if (ep2->type & POLY_NOPATH)
									continue;

								if (DirectAddAnchor_Original_Method(eb, eg, &currcyl.origin, 0))
								{
									added = 1;
								}
							}
						}


					if (added)
						current_y -= 160.f; 

					current_y -= 50.f; 
				}
			}
		}

}
Exemplo n.º 7
0
//-----------------------------------------------------------------------------
void ARX_MINIMAP_GetData(long SHOWLEVEL)
{
	if (minimap[SHOWLEVEL].tc == NULL)
	{
		char name[256];
		char LevelMap[256];
		GetLevelNameByNum(SHOWLEVEL, name);

		sprintf(LevelMap, "Graph\\Levels\\Level%s\\map.bmp", name);
		minimap[SHOWLEVEL].tc = MakeTCFromFile(LevelMap);

		if (minimap[SHOWLEVEL].tc) // 4 pix/meter
		{
			minimap[SHOWLEVEL].tc->Restore(GDevice);
			SpecialBorderSurface(minimap[SHOWLEVEL].tc, minimap[SHOWLEVEL].tc->m_dwOriginalWidth, minimap[SHOWLEVEL].tc->m_dwOriginalHeight);


			minimap[SHOWLEVEL].height = ARX_CLEAN_WARN_CAST_FLOAT(minimap[SHOWLEVEL].tc->m_dwHeight); 
			minimap[SHOWLEVEL].width = ARX_CLEAN_WARN_CAST_FLOAT(minimap[SHOWLEVEL].tc->m_dwWidth);


			float minx = FLT_MAX;
			float maxx = FLT_MIN;
			float miny = FLT_MAX;
			float maxy = FLT_MIN;
			EERIEPOLY * ep;
			EERIE_BKG_INFO * eg;

			for (long j = 0; j < ACTIVEBKG->Zsize; j++)
			{
				for (long i = 0; i < ACTIVEBKG->Xsize; i++)
				{
					eg = &ACTIVEBKG->Backg[i+j*ACTIVEBKG->Xsize];

					for (long k = 0; k < eg->nbpoly; k++)
					{
						ep = &eg->polydata[k];

						if (ep)
						{
							minx = __min(minx, ep->min.x);
							maxx = __max(maxx, ep->max.x);
							miny = __min(miny, ep->min.z);
							maxy = __max(maxy, ep->max.z);
						}
					}
				}

				mapmaxy[SHOWLEVEL] = maxy;
				minimap[SHOWLEVEL].xratio = minx;
				minimap[SHOWLEVEL].yratio = miny;

				for (long iii = 0; iii < 32; iii++)
				{
					minimap[iii].offsetx = 0;
					minimap[iii].offsety = 0;
				}
			}
		}
	}
}
Exemplo n.º 8
0
//-----------------------------------------------------------------------------
void ARX_MINIMAP_Show(LPDIRECT3DDEVICE7 m_pd3dDevice, long SHOWLEVEL, long flag, long fl2)
{
	float sstartx, sstarty;

	if (!pTexDetect)
	{
		GetTextureFile("Graph\\particles\\flare.bmp");
		char temp[256];
		MakeDir(temp, "Graph\\particles\\flare.bmp");
		pTexDetect = D3DTextr_GetSurfaceContainer(temp);
	}

	//	SHOWLEVEL=8;
	// First Load Minimap TC & DATA if needed
	if (minimap[SHOWLEVEL].tc == NULL)
	{
		ARX_MINIMAP_GetData(SHOWLEVEL);
	}

	if ((minimap[SHOWLEVEL].tc) && (minimap[SHOWLEVEL].tc->m_pddsSurface))
	{
		float startx, starty, casex, casey, ratiooo;
		float mod_x = (float)MAX_BKGX / (float)MINIMAP_MAX_X;
		float mod_z = (float)MAX_BKGZ / (float)MINIMAP_MAX_Z;

		if (flag == 1)
		{


			startx = 0;
			starty = 0;
			casex = (900) / ((float)MINIMAP_MAX_X);
			casey = (900) / ((float)MINIMAP_MAX_Z);
			ratiooo = 900.f / 250.f;

			if (fl2)
			{
				casex = (600) / ((float)MINIMAP_MAX_X);
				casey = (600) / ((float)MINIMAP_MAX_Z);
				ratiooo = 600.f / 250.f;
			}

		}
		else
		{
			startx = (140); 
			starty = (120);
			casex = (250) / ((float)MINIMAP_MAX_X);
			casey = (250) / ((float)MINIMAP_MAX_Z);
			ratiooo = 1.f;
		}

		sstartx = startx;
		sstarty = starty;


		float ofx, ofx2, ofy, ofy2, px, py;
		px = py = 0.f;

		ofx		= mini_offset_x[CURRENTLEVEL];
		ofx2	= minimap[SHOWLEVEL].xratio;
		ofy		= mini_offset_y[CURRENTLEVEL];
		ofy2	= minimap[SHOWLEVEL].yratio;

		if ((SHOWLEVEL == ARX_LEVELS_GetRealNum(CURRENTLEVEL)) || (flag == 2))
		{
			// Computes playerpos
			ofx = mini_offset_x[CURRENTLEVEL];
			ofx2 = minimap[SHOWLEVEL].xratio;
			ofy = mini_offset_y[CURRENTLEVEL];
			ofy2 = minimap[SHOWLEVEL].yratio;
		
			px = startx + ((player.pos.x + ofx - ofx2) * DIV100 * casex
			               + mini_offset_x[CURRENTLEVEL] * ratiooo * mod_x) / mod_x ; //DIV100*2;
			py = starty + ((mapmaxy[SHOWLEVEL] - ofy - ofy2) * DIV100 * casey
			               - (player.pos.z + ofy - ofy2) * DIV100 * casey + mini_offset_y[CURRENTLEVEL] * ratiooo * mod_z) / mod_z ;    //DIV100*2;

			if (flag == 1)
			{
				sstartx = startx;
				sstarty = starty;

				startx = 490.f - px;
				starty = 220.f - py;
				px += startx;
				py += starty;
			}
		}


		D3DTLVERTEX verts[4];
		SETTC(m_pd3dDevice, minimap[SHOWLEVEL].tc);

		for (long k = 0; k < 4; k++)
		{
			verts[k].color = 0xFFFFFFFF;
			verts[k].rhw = 1;
			verts[k].sz = 0.00001f;
		}

		float div = DIV25;
		TextureContainer * tc = minimap[SHOWLEVEL].tc;
		float dw = 1.f / (float)max(tc->m_dwDeviceWidth, tc->m_dwOriginalWidth); 
		float dh = 1.f / (float)max(tc->m_dwDeviceHeight, tc->m_dwOriginalHeight);
		
		float vx2 = 4.f * dw * mod_x;
		float vy2 = 4.f * dh * mod_z;

		float _px;
		RECT boundaries;
		float MOD20, MOD20DIV, divXratio, divYratio;

		boundaries.bottom = boundaries.left = boundaries.right = boundaries.top = 0;
		MOD20 = MOD20DIV = divXratio = divYratio = 0.f;

		if (flag != 2)
		{

			if (flag == 1)
			{
				MOD20 = 20.f * Xratio;
				MOD20DIV = 1.f / (MOD20);
				//@PERF do if(fl2){}else{} to make 4 and not 8 flot op if fl2.

				ARX_CHECK_LONG((360 + MOD20)*Xratio);
				ARX_CHECK_LONG((555 - MOD20)*Xratio);
				ARX_CHECK_LONG((85 + MOD20)*Yratio);
				ARX_CHECK_LONG((355 - MOD20)*Yratio);

				//CAST
				boundaries.left		=	ARX_CLEAN_WARN_CAST_LONG((360 + MOD20) * Xratio);
				boundaries.right	=	ARX_CLEAN_WARN_CAST_LONG((555 - MOD20) * Xratio);
				boundaries.top		=	ARX_CLEAN_WARN_CAST_LONG((85 + MOD20) * Yratio);
				boundaries.bottom	=	ARX_CLEAN_WARN_CAST_LONG((355 - MOD20) * Yratio);

				if (fl2)
				{
					//CHECK (DEBUG)
					ARX_CHECK_LONG((390 + MOD20)*Xratio);
					ARX_CHECK_LONG((590 - MOD20)*Xratio);
					ARX_CHECK_LONG((135 + MOD20)*Yratio);
					ARX_CHECK_LONG((295 - MOD20)*Yratio);

					//CAST
					boundaries.left		=	ARX_CLEAN_WARN_CAST_LONG((390 + MOD20) * Xratio);
					boundaries.right	=	ARX_CLEAN_WARN_CAST_LONG((590 - MOD20) * Xratio);
					boundaries.top		=	ARX_CLEAN_WARN_CAST_LONG((135 + MOD20) * Yratio);
					boundaries.bottom	=	ARX_CLEAN_WARN_CAST_LONG((295 - MOD20) * Yratio);
				}
			}

			SETALPHABLEND(m_pd3dDevice, TRUE);
			m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,  D3DBLEND_ZERO);
			m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCCOLOR);
			m_pd3dDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS);
			SETTEXTUREWRAPMODE(m_pd3dDevice, D3DTADDRESS_CLAMP);

			if (fl2)
			{
				m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,  D3DBLEND_ONE);
				m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCCOLOR);
			}
		}
		else
		{
			divXratio = 1.f / Xratio;
			divYratio = 1.f / Yratio;
		}

		for (long j = -2; j < MINIMAP_MAX_Z + 2; j++)
		{
			for (long i = -2; i < MINIMAP_MAX_X + 2; i++)
			{
				float vx, vy, vxx, vyy;
				vxx = ((float)i * (float)ACTIVEBKG->Xdiv * mod_x);
				vyy = ((float)j * (float)ACTIVEBKG->Zdiv * mod_z);
				vx = (vxx * div) * dw;
				vy = (vyy * div) * dh;

				long okay = 1;
				float posx = (startx + i * casex) * Xratio;
				float posy = (starty + j * casey) * Yratio;

				if (flag == 1)
				{

					if	((posx < 360 * Xratio)
					        ||	(posx > 555 * Xratio)
					        ||	(posy < 85 * Yratio)
					        ||	(posy > 355 * Yratio))
						okay = 0;

					if (fl2)
					{
						okay = 1;

						if	((posx < 390 * Xratio)
						        ||	(posx > 590 * Xratio)
						        ||	(posy < 135 * Yratio)
						        ||	(posy > 295 * Yratio))
							okay = 0;
					}

				}
				else
				{
					if ((posx > 345 * Xratio)
					        ||	(posy > 290 * Yratio))
						okay = 0;
				}

				if (okay)
				{
					if ((flag == 2)
					        && (i >= 0) && (i < MINIMAP_MAX_X)
					        && (j >= 0) && (j < MINIMAP_MAX_Z))
					{
						float d = Distance2D(posx * divXratio + casex * DIV2, posy * divYratio /*-casey * 2 * Yratio*/, px, py);

						if (d <= 6.f)
						{
							long r;
							float vv = (6 - d) * DIV6;

							if (vv >= 0.5f)
								vv = 1.f;
							else if (vv > 0.f)
								vv = vv * 2.f;
							else
								vv = 0.f;

							F2L((float)(vv * 255.f), &r);


							long ucLevel =  __max(r, minimap[SHOWLEVEL].revealed[i][j]);
							ARX_CHECK_UCHAR(ucLevel);

							minimap[SHOWLEVEL].revealed[i][j] = ARX_CLEAN_WARN_CAST_UCHAR(ucLevel);


						}
					}

					if (!FOR_EXTERNAL_PEOPLE)
					{
						if ((i >= 0) && (i < MINIMAP_MAX_X)
						        &&	(j >= 0) && (j < MINIMAP_MAX_Z))
						{
							minimap[SHOWLEVEL].revealed[i][j] = 255;
						}
					}

					verts[3].sx = verts[0].sx = (posx);
					verts[1].sy = verts[0].sy = (posy);
					verts[2].sx = verts[1].sx = posx + (casex * Xratio);
					verts[3].sy = verts[2].sy = posy + (casey * Yratio);

					verts[3].tu = verts[0].tu = vx;
					verts[1].tv = verts[0].tv = vy;
					verts[2].tu = verts[1].tu = vx + vx2;
					verts[3].tv = verts[2].tv = vy + vy2;

					if (flag != 2)
					{
						float v;
						float oo = 0.f;

						if ((i < 0) || (i >= MINIMAP_MAX_X) || (j < 0) || (j >= MINIMAP_MAX_Z)) v = 0;
						else v = ((float)minimap[SHOWLEVEL].revealed[i][j]) * DIV255;

						if (flag == 1)
						{
							long vert = 0;
							_px = verts[vert].sx - boundaries.left;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.right - verts[vert].sx;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = verts[vert].sy - boundaries.top;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.bottom - verts[vert].sy;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;
						}

						if (fl2) verts[0].color = D3DRGB(v * DIV2, v * DIV2, v * DIV2);
						else
							verts[0].color = D3DRGB(v, v, v);

						oo += v;

						if ((i + 1 < 0) || (i + 1 >= MINIMAP_MAX_X) || (j < 0) || (j >= MINIMAP_MAX_Z)) v = 0;
						else v = ((float)minimap[SHOWLEVEL].revealed[__min(i+1, MINIMAP_MAX_X-1)][j]) * DIV255;

						if (flag == 1)
						{
							long vert = 1;
							_px = verts[vert].sx - boundaries.left;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.right - verts[vert].sx;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = verts[vert].sy - boundaries.top;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.bottom - verts[vert].sy;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;
						}

						if (fl2) verts[1].color = D3DRGB(v * DIV2, v * DIV2, v * DIV2);
						else
							verts[1].color = D3DRGB(v, v, v);

						oo += v;

						if ((i + 1 < 0) || (i + 1 >= MINIMAP_MAX_X) || (j + 1 < 0) || (j + 1 >= MINIMAP_MAX_Z)) v = 0;
						else v = ((float)minimap[SHOWLEVEL].revealed[__min(i+1, MINIMAP_MAX_X-1)][__min(j+1, MINIMAP_MAX_Z-1)]) * DIV255;

						if (flag == 1)
						{
							long vert = 2;
							_px = verts[vert].sx - boundaries.left;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.right - verts[vert].sx;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = verts[vert].sy - boundaries.top;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.bottom - verts[vert].sy;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;
						}
						

						if (fl2) verts[2].color = D3DRGB(v * DIV2, v * DIV2, v * DIV2);
						else
							verts[2].color = D3DRGB(v, v, v);

						oo += v;

						if ((i < 0) || (i >= MINIMAP_MAX_X) || (j + 1 < 0) || (j + 1 >= MINIMAP_MAX_Z)) v = 0;
						else v = ((float)minimap[SHOWLEVEL].revealed[i][__min(j+1, MINIMAP_MAX_Z-1)]) * DIV255;

						if (flag == 1)
						{
							long vert = 3;
							_px = verts[vert].sx - boundaries.left;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.right - verts[vert].sx;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = verts[vert].sy - boundaries.top;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.bottom - verts[vert].sy;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;
						}

						if (fl2) verts[3].color = D3DRGB(v * DIV2, v * DIV2, v * DIV2);
						else
							verts[3].color = D3DRGB(v, v, v);

						oo += v;

						if (oo > 0.f)
						{
							if (fl2)
							{
								verts[0].sx += DECALX * Xratio;
								verts[0].sy += DECALY * Yratio;
								verts[1].sx += DECALX * Xratio;
								verts[1].sy += DECALY * Yratio;
								verts[2].sx += DECALX * Xratio;
								verts[2].sy += DECALY * Yratio;
								verts[3].sx += DECALX * Xratio;
								verts[3].sy += DECALY * Yratio;
							}

							EERIEDRAWPRIM(GDevice, D3DPT_TRIANGLEFAN, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, 4, 0);
						}
					}
				}
			}
		}

		if (flag != 2)
		{
			m_pd3dDevice->SetTextureStageState(0, D3DTSS_ADDRESS , D3DTADDRESS_WRAP);
			m_pd3dDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESSEQUAL);

			SETALPHABLEND(m_pd3dDevice, FALSE);

			if ((SHOWLEVEL == ARX_LEVELS_GetRealNum(CURRENTLEVEL)))
			{
				// Now Draws Playerpos/angle
				verts[0].color = 0xFFFF0000;
				verts[1].color = 0xFFFF0000;
				verts[2].color = 0xFFFF0000;
				float val;

				if (flag == 1) val = 6.f;
				else val = 3.f;

				float rx = 0.f;
				float ry = -val * 1.8f;
				float rx2 = -val * DIV2;
				float ry2 = val;
				float rx3 = val * DIV2;
				float ry3 = val;

				float angle = DEG2RAD(player.angle.b);
				float ca = EEcos(angle);
				float sa = EEsin(angle);

				verts[0].sx = (px + rx2 * ca + ry2 * sa) * Xratio;
				verts[0].sy = (py + ry2 * ca - rx2 * sa) * Yratio;
				verts[1].sx = (px + rx * ca + ry * sa) * Xratio;
				verts[1].sy = (py + ry * ca - rx * sa) * Yratio;
				verts[2].sx = (px + rx3 * ca + ry3 * sa) * Xratio;
				verts[2].sy = (py + ry3 * ca - rx3 * sa) * Yratio;

				SETTC(GDevice, NULL);

				if (fl2)
				{
					SETALPHABLEND(m_pd3dDevice, TRUE);
					verts[0].sx += DECALX * Xratio;
					verts[0].sy += DECALY * Yratio;
					verts[1].sx += DECALX * Xratio;
					verts[1].sy += DECALY * Yratio;
					verts[2].sx += DECALX * Xratio;
					verts[2].sy += DECALY * Yratio;
				}

				EERIEDRAWPRIM(GDevice, D3DPT_TRIANGLEFAN, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, 3, 0);

				if (fl2) SETALPHABLEND(m_pd3dDevice, FALSE);
			}
		}

		// tsu
		for (long lnpc = 1; lnpc < inter.nbmax; lnpc++)
		{
			if ((inter.iobj[lnpc] != NULL) && (inter.iobj[lnpc]->ioflags & IO_NPC))
			{
				if (inter.iobj[lnpc]->_npcdata->life > 0.f)
					if (!((inter.iobj[lnpc]->GameFlags & GFLAG_MEGAHIDE) ||
					        (inter.iobj[lnpc]->show == SHOW_FLAG_MEGAHIDE))
					        && (inter.iobj[lnpc]->show == SHOW_FLAG_IN_SCENE))
						if (!(inter.iobj[lnpc]->show == SHOW_FLAG_HIDDEN))
							if (inter.iobj[lnpc]->_npcdata->fDetect >= 0)
							{
								if (player.Full_Skill_Etheral_Link >= inter.iobj[lnpc]->_npcdata->fDetect)
								{
									float fpx;
									float fpy;
								
									fpx = sstartx + ((inter.iobj[lnpc]->pos.x - 100 + ofx - ofx2) * DIV100 * casex
									                 + mini_offset_x[CURRENTLEVEL] * ratiooo * mod_x) / mod_x; 
									fpy = sstarty + ((mapmaxy[SHOWLEVEL] - ofy - ofy2) * DIV100 * casey
									                 - (inter.iobj[lnpc]->pos.z + 200 + ofy - ofy2) * DIV100 * casey + mini_offset_y[CURRENTLEVEL] * ratiooo * mod_z) / mod_z; 

									if (flag == 1)
									{

										fpx = startx + ((inter.iobj[lnpc]->pos.x - 100 + ofx - ofx2) * DIV100 * casex
										                + mini_offset_x[CURRENTLEVEL] * ratiooo * mod_x) / mod_x; 
										fpy = starty + ((mapmaxy[SHOWLEVEL] - ofy - ofy2) * DIV100 * casey
										                - (inter.iobj[lnpc]->pos.z + 200 + ofy - ofy2) * DIV100 * casey + mini_offset_y[CURRENTLEVEL] * ratiooo * mod_z) / mod_z; 


									}

									float d = Distance2D(player.pos.x, player.pos.z, inter.iobj[lnpc]->pos.x, inter.iobj[lnpc]->pos.z);

		
									if ((d <= 800) && (fabs(inter.iobj[0]->pos.y - inter.iobj[lnpc]->pos.y) < 250.f))
									{
										float col = 1.f;

										if (d > 600.f)
										{
											col = 1.f - (d - 600.f) * DIV200;
										}

										if (!fl2)
										{
											SETALPHABLEND(m_pd3dDevice, true);
											m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,  D3DBLEND_ONE);
											m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
										}
										else
											SETALPHABLEND(m_pd3dDevice, true);

										if (fl2)
										{
											fpx += DECALX * Xratio;
											fpy += (DECALY + 15) * Yratio;
										}

										fpx *= Xratio;
										fpy *= Yratio;
										EERIEDrawBitmap(GDevice, fpx, fpy,
										                5.f * ratiooo, 5.f * ratiooo, 0, pTexDetect, D3DRGB(col, 0, 0));

										if (!fl2)
											SETALPHABLEND(m_pd3dDevice, false);
									}
								}
							}
			}
		}

		if (flag == 0)
			for (long i = 0; i < Nb_Mapmarkers; i++)
			{
				if (Mapmarkers[i].lvl == SHOWLEVEL + 1)
				{
					float pos_x = Mapmarkers[i].x * 8 * ratiooo * ACTIVEBKG->Xmul * casex + startx;
					float pos_y = Mapmarkers[i].y * 8 * ratiooo * ACTIVEBKG->Zmul * casey + starty;
					float size = 5.f * ratiooo;
					verts[0].color = 0xFFFF0000;
					verts[1].color = 0xFFFF0000;
					verts[2].color = 0xFFFF0000;
					verts[3].color = 0xFFFF0000;
					verts[0].sx = (pos_x - size) * Xratio;
					verts[0].sy = (pos_y - size) * Yratio;
					verts[1].sx = (pos_x + size) * Xratio;
					verts[1].sy = (pos_y - size) * Yratio;
					verts[2].sx = (pos_x + size) * Xratio;
					verts[2].sy = (pos_y + size) * Yratio;
					verts[3].sx = (pos_x - size) * Xratio;
					verts[3].sy = (pos_y + size) * Yratio;
					verts[0].tu = 0.f;
					verts[0].tv = 0.f;
					verts[1].tu = 1.f;
					verts[1].tv = 0.f;
					verts[2].tu = 1.f;
					verts[2].tv = 1.f;
					verts[3].tu = 0.f;
					verts[3].tv = 1.f;

					if ((!fl2)
					        && (MouseInRect(verts[0].sx, verts[0].sy, verts[2].sx, verts[2].sy)))
					{
						if (!Mapmarkers[i].tstring)
						{
							_TCHAR output[4096];
							MakeLocalised(Mapmarkers[i].string, output, 4096, 0);
							Mapmarkers[i].tstring = (_TCHAR *)malloc((_tcslen(output) + 1) * sizeof(_TCHAR));
							ZeroMemory(Mapmarkers[i].tstring, (_tcslen(output) + 1)*sizeof(_TCHAR));
							_tcscpy(Mapmarkers[i].tstring, output);
						}

						if (Mapmarkers[i].tstring)
						{
							RECT rRect, bRect;
							SetRect(&bRect	, (140),	(290)
							        , (140 + 205),	(358));

							float fLeft		= (bRect.left) * Xratio ;
							float fRight	= (bRect.right) * Xratio ;
							float fTop		= (bRect.top) * Yratio ;
							float fBottom	= (bRect.bottom) * Yratio ;
							ARX_CHECK_INT(fLeft);
							ARX_CHECK_INT(fRight);
							ARX_CHECK_INT(fTop);
							ARX_CHECK_INT(fBottom);

							SetRect(&rRect
							        , ARX_CLEAN_WARN_CAST_INT(fLeft)
							        , ARX_CLEAN_WARN_CAST_INT(fTop)
							        , ARX_CLEAN_WARN_CAST_INT(fRight)
							        , ARX_CLEAN_WARN_CAST_INT(fBottom));


							long lLengthDraw = ARX_UNICODE_ForceFormattingInRect(
							                       hFontInGameNote, Mapmarkers[i].tstring, 0, rRect);

							danaeApp.DANAEEndRender();
							_TCHAR	Page_Buffer[256];
							_tcsncpy(Page_Buffer, Mapmarkers[i].tstring, lLengthDraw);
							Page_Buffer[lLengthDraw] = _T('\0');

							DrawBookTextInRect(ARX_CLEAN_WARN_CAST_FLOAT(bRect.left), ARX_CLEAN_WARN_CAST_FLOAT(bRect.top),
							                   ARX_CLEAN_WARN_CAST_FLOAT(bRect.right), ARX_CLEAN_WARN_CAST_FLOAT(bRect.bottom),
							                   Page_Buffer, 0, 0x00FF00FF,
							                   hFontInGameNote);


							danaeApp.DANAEStartRender();
						}
					}

					if (MapMarkerTc == NULL)
					{
						MapMarkerTc = MakeTCFromFile("Graph\\interface\\icons\\mapmarker.bmp");
					}

					SETTC(GDevice, MapMarkerTc);

					if (fl2)
					{
						verts[0].sx += DECALX * Xratio;
						verts[0].sy += DECALY * Yratio;
						verts[1].sx += DECALX * Xratio;
						verts[1].sy += DECALY * Yratio;
						verts[2].sx += DECALX * Xratio;
						verts[2].sy += DECALY * Yratio;
						verts[3].sx += DECALX * Xratio;
						verts[3].sy += DECALY * Yratio;
					}

					EERIEDRAWPRIM(GDevice, D3DPT_TRIANGLEFAN, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, 4, 0);
				}
			}

	}
}