Ejemplo n.º 1
0
void CLevitate::CreateConeStrip(float rbase, float rhaut, float hauteur, int def,
                                int numcone) {
	
	T_CONE & c = cone[numcone];
	
	free(c.coned3d);
	free(c.conevertex);
	free(c.coneind);
	
	c.conenbvertex = def * 2 + 2;
	c.conenbfaces = def * 2 + 2;
	c.coned3d = (TexturedVertex *)malloc(c.conenbvertex * sizeof(TexturedVertex));
	c.conevertex = (Vec3f *)malloc(c.conenbvertex * sizeof(Vec3f));
	c.coneind = (unsigned short *)malloc(c.conenbvertex * sizeof(unsigned short));
	
	Vec3f * vertex = c.conevertex;
	unsigned short * pind = c.coneind;
	unsigned short ind = 0;
	int nb;
	float a = 0.f;
	float da = 360.f / (float)def;
	nb = this->cone[numcone].conenbvertex >> 1;
	
	while(nb) {
		*pind++ = ind++;
		*pind++ = ind++;
		*vertex++ = Vec3f(rhaut * EEcos(radians(a)), -hauteur, rhaut * EEsin(radians(a)));
		*vertex++ = Vec3f(rbase * EEcos(radians(a)), 0.f, rbase * EEsin(radians(a)));
		a += da;
		nb--;
	}
}
Ejemplo n.º 2
0
bool CylinderAboveInvalidZone(EERIE_CYLINDER * cyl)
{
	float count = 0;
	float failcount = 0;

	for (float rad = 0; rad < cyl->radius; rad += 10.f)
		for (float ang = 0; ang < 360; ang += 45)
		{
			if (rad == 0) ang = 360;

			EERIE_3D pos;
			pos.x = cyl->origin.x - EEsin(DEG2RAD(ang)) * rad;
			pos.y = cyl->origin.y - 20.f;
			pos.z = cyl->origin.z + EEcos(DEG2RAD(ang)) * rad;
			EERIEPOLY * ep = ANCHOR_CheckInPoly(pos.x, pos.y, pos.z);

			if (!ep) continue;

			if (ep->type & POLY_NOPATH) return true;

			count += 1.f;
			float vy;
			GetTruePolyY(ep, &pos, &vy);

			if (EEfabs(vy - cyl->origin.y) > 160.f)
				failcount++;
		}

	float failratio = failcount / count;

	if (failratio > 0.75f) return true;

	return false;
}
//-----------------------------------------------------------------------------
void CLevitate::CreateConeStrip(float rbase, float rhaut, float hauteur, int def, int numcone)
{
	if (this->cone[numcone].coned3d) free((void *)this->cone[numcone].coned3d);

	if (this->cone[numcone].conevertex) free((void *)this->cone[numcone].conevertex);

	if (this->cone[numcone].coneind) free((void *)this->cone[numcone].coneind);

	this->cone[numcone].conenbvertex = def * 2 + 2;
	this->cone[numcone].conenbfaces = def * 2 + 2;
	this->cone[numcone].coned3d = (D3DTLVERTEX *)malloc(this->cone[numcone].conenbvertex * sizeof(D3DTLVERTEX));
	this->cone[numcone].conevertex = (EERIE_3D *)malloc(this->cone[numcone].conenbvertex * sizeof(EERIE_3D));
	this->cone[numcone].coneind = (unsigned short *)malloc(this->cone[numcone].conenbvertex * sizeof(unsigned short));

	float			a, da;
	EERIE_3D	*	vertex = this->cone[numcone].conevertex;
	unsigned short	* pind = this->cone[numcone].coneind, ind = 0;
	int				nb;
	a = 0.f;
	da = 360.f / (float)def;
	nb = this->cone[numcone].conenbvertex >> 1;

	while (nb)
	{
		*pind++ = ind++;
		*pind++ = ind++;

		vertex->x = rhaut * EEcos(DEG2RAD(a));
		vertex->y = -hauteur;
		vertex->z = rhaut * EEsin(DEG2RAD(a));
		vertex++;
		vertex->x = rbase * EEcos(DEG2RAD(a));
		vertex->y = 0.f;
		vertex->z = rbase * EEsin(DEG2RAD(a));
		vertex++;

		a += da;
		nb--;
	}
}
Ejemplo n.º 4
0
//-----------------------------------------------------------------------------
void CMassLightning::Create(EERIE_3D aePos, float afBeta = 0)
{
	long lMax = 0;
	EERIE_3D eTarget;
	float ft = 360.0f / (float)number;

	for (int i = 0; i < number; i++)
	{
		eTarget.x = aePos.x - EEsin(DEG2RAD(i * ft)) * 500.0f;
		eTarget.y = aePos.y;
		eTarget.z = aePos.z + EEcos(DEG2RAD(i * ft)) * 500.0f;
		pTab[i]->Create(aePos, eTarget, 0);
		long lTime = (long)(ulDuration + rnd() * 5000.0f);
		pTab[i]->SetDuration(lTime);
		lMax = max(lMax, lTime);
		pTab[i]->spellinstance = this->spellinstance;
		pTab[i]->SetColor1(1.f, 0.75f, 0.75f); // milieu
		pTab[i]->SetColor2(0.3f, 0.f, 0.f); // extrémités
	}

	SetDuration(lMax + 1000);
}
Ejemplo n.º 5
0
void MiniMap::drawPlayer(float playerSize, float playerX, float playerY, bool alphaBlending) {
	
	TexturedVertex verts[4];
	
	for(int k = 0; k < 4; k++) {
		verts[k].color = 0xFFFF0000; // red
		verts[k].rhw = 1;
		verts[k].p.z = 0.00001f;
	}
	
	float rx = 0.f;
	float ry = -playerSize * 1.8f;
	float rx2 = -playerSize * (1.0f / 2);
	float ry2 = playerSize;
	float rx3 = playerSize * (1.0f / 2);
	float ry3 = playerSize;
	
	float angle = radians(m_player->angle.b);
	float ca = EEcos(angle);
	float sa = EEsin(angle);
	
	verts[0].p.x = (playerX + rx2 * ca + ry2 * sa) * Xratio;
	verts[0].p.y = (playerY + ry2 * ca - rx2 * sa) * Yratio;
	verts[1].p.x = (playerX + rx * ca + ry * sa) * Xratio;
	verts[1].p.y = (playerY + ry * ca - rx * sa) * Yratio;
	verts[2].p.x = (playerX + rx3 * ca + ry3 * sa) * Xratio;
	verts[2].p.y = (playerY + ry3 * ca - rx3 * sa) * Yratio;
	
	GRenderer->ResetTexture(0);
	GRenderer->SetRenderState(Renderer::AlphaBlending, alphaBlending);
	if(alphaBlending) {
		GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendInvSrcColor);
	}
	
	EERIEDRAWPRIM(Renderer::TriangleFan, verts);
	
	GRenderer->SetRenderState(Renderer::AlphaBlending, false);
}
Ejemplo n.º 6
0
void CMassLightning::Create(Vec3f aePos, float afBeta = 0) {
	
	(void)afBeta;
	
	long lMax = 0;
	Vec3f eTarget;
	float ft = 360.0f / (float)number;

	for(int i = 0; i < number; i++) {
		eTarget.x = aePos.x - EEsin(radians(i * ft)) * 500.0f;
		eTarget.y = aePos.y;
		eTarget.z = aePos.z + EEcos(radians(i * ft)) * 500.0f;
		pTab[i]->Create(aePos, eTarget, 0);
		long lTime = ulDuration + Random::get(0, 5000);
		pTab[i]->SetDuration(lTime);
		lMax = std::max(lMax, lTime);
		pTab[i]->spellinstance = this->spellinstance;
		pTab[i]->SetColor1(1.f, 0.75f, 0.75f); // middle
		pTab[i]->SetColor2(0.3f, 0.f, 0.f); // extremities
	}

	SetDuration(lMax + 1000);
}
Ejemplo n.º 7
0
void ManageQuakeFX(EERIE_CAMERA * cam) {
	if(QuakeFx.intensity>0.f) {
		float tim=(float)arxtime.get_frame_time()-(float)QuakeFx.start;

		if(tim >= QuakeFx.duration) {
			QuakeFx.intensity=0.f;
			return;
		}

		float itmod=1.f-(tim/QuakeFx.duration);
		float periodicity=EEsin((float)arxtime.get_frame_time()*QuakeFx.frequency*( 1.0f / 100 ));

		if(periodicity > 0.5f && (QuakeFx.flags & 1))
			ARX_SOUND_PlaySFX(SND_QUAKE, NULL, 1.0F - 0.5F * QuakeFx.intensity);

		float truepower = periodicity * QuakeFx.intensity * itmod * 0.01f;
		float halfpower = truepower * .5f;
		cam->orgTrans.pos += randomVec(-halfpower, halfpower);
		cam->angle.setYaw(cam->angle.getYaw() + rnd() * truepower - halfpower);
		cam->angle.setPitch(cam->angle.getPitch() + rnd() * truepower - halfpower);
		cam->angle.setRoll(cam->angle.getRoll() + rnd() * truepower - halfpower);
	}
}
Ejemplo n.º 8
0
BOOL ANCHOR_ARX_COLLISION_Move_Cylinder(IO_PHYSICS * ip, INTERACTIVE_OBJ * io, float MOVE_CYLINDER_STEP, long flags)
{
	MOVING_CYLINDER = 1;
	DIRECT_PATH = TRUE;
	IO_PHYSICS test;

	if (ip == NULL)
	{
		MOVING_CYLINDER = 0;
		return FALSE;
	}

	float distance = TRUEEEDistance3D(&ip->startpos, &ip->targetpos);

	if (distance <= 0.f)
	{
		MOVING_CYLINDER = 0;
		return TRUE; 
	}

	float onedist = 1.f / distance;
	EERIE_3D mvector;
	mvector.x = (ip->targetpos.x - ip->startpos.x) * onedist;
	mvector.y = (ip->targetpos.y - ip->startpos.y) * onedist;
	mvector.z = (ip->targetpos.z - ip->startpos.z) * onedist;

	while (distance > 0.f)
	{
		// First We compute current increment
		float curmovedist = __min(distance, MOVE_CYLINDER_STEP);

		distance -= curmovedist;
		//CUR_FRAME_SLICE=curmovedist*onedist;
		// Store our cylinder desc into a test struct
		memcpy(&test, ip, sizeof(IO_PHYSICS));

		// uses test struct to simulate movement.
		test.cyl.origin.x += mvector.x * curmovedist;
		test.cyl.origin.y += mvector.y * curmovedist;
		test.cyl.origin.z += mvector.z * curmovedist;

		vector2D.x = mvector.x * curmovedist;
		vector2D.y = 0.f;
		vector2D.z = mvector.z * curmovedist;

		if ((flags & CFLAG_CHECK_VALID_POS)
		        && (CylinderAboveInvalidZone(&test.cyl)))
			return FALSE;

		if (ANCHOR_AttemptValidCylinderPos(&test.cyl, io, flags))
		{
			memcpy(ip, &test, sizeof(IO_PHYSICS));

		}
		else
		{
			if (flags & CFLAG_CLIMBING)
			{
				memcpy(&test.cyl, &ip->cyl, sizeof(EERIE_CYLINDER));
				test.cyl.origin.y += mvector.y * curmovedist;

				if (ANCHOR_AttemptValidCylinderPos(&test.cyl, io, flags))
				{
					memcpy(ip, &test, sizeof(IO_PHYSICS));
					goto oki;
				}
			}

			DIRECT_PATH = FALSE;
			// Must Attempt To Slide along collisions
			register EERIE_3D	vecatt;
			EERIE_3D			rpos		= { 0, 0, 0 };
			EERIE_3D			lpos		= { 0, 0, 0 };
			long				RFOUND		=	0;
			long				LFOUND		=	0;
			long				maxRANGLE	=	90;
			long				maxLANGLE	=	270;
			float				ANGLESTEPP;

			if (flags & CFLAG_EASY_SLIDING)    // player sliding in fact...
			{
				ANGLESTEPP	=	10.f;
				maxRANGLE	=	70;
				maxLANGLE	=	290;
			}
			else ANGLESTEPP	=	30.f;

			register float rangle	=	ANGLESTEPP;
			register float langle	=	360.f - ANGLESTEPP;


			while (rangle <= maxRANGLE)   //tries on the Right and Left sides
			{
				memcpy(&test.cyl, &ip->cyl, sizeof(EERIE_CYLINDER)); 
				float t = DEG2RAD(MAKEANGLE(rangle));
				_YRotatePoint(&mvector, &vecatt, EEcos(t), EEsin(t));
				test.cyl.origin.x	+=	vecatt.x * curmovedist;
				test.cyl.origin.y	+=	vecatt.y * curmovedist;
				test.cyl.origin.z	+=	vecatt.z * curmovedist;

				if (ANCHOR_AttemptValidCylinderPos(&test.cyl, io, flags))
				{
					memcpy(&rpos, &test.cyl.origin, sizeof(EERIE_3D));
					RFOUND = 1;
				}

				rangle += ANGLESTEPP;

				memcpy(&test.cyl, &ip->cyl, sizeof(EERIE_CYLINDER));   
				t = DEG2RAD(MAKEANGLE(langle));
				_YRotatePoint(&mvector, &vecatt, EEcos(t), EEsin(t));
				test.cyl.origin.x	+=	vecatt.x * curmovedist;
				test.cyl.origin.y	+=	vecatt.y * curmovedist;
				test.cyl.origin.z	+=	vecatt.z * curmovedist;

				if (ANCHOR_AttemptValidCylinderPos(&test.cyl, io, flags))
				{
					memcpy(&lpos, &test.cyl.origin, sizeof(EERIE_3D));
					LFOUND = 1;
				}

				langle -= ANGLESTEPP;

				if ((RFOUND) || (LFOUND)) break;
			}

			if ((LFOUND) && (RFOUND))
			{
				langle = 360.f - langle;

				if (langle < rangle)
				{
					memcpy(&ip->cyl.origin, &lpos, sizeof(EERIE_3D));
					distance -= curmovedist;
				}
				else
				{
					memcpy(&ip->cyl.origin, &rpos, sizeof(EERIE_3D));
					distance -= curmovedist;
				}
			}
			else if (LFOUND)
			{
				memcpy(&ip->cyl.origin, &lpos, sizeof(EERIE_3D));
				distance -= curmovedist;
			}
			else if (RFOUND)
			{
				memcpy(&ip->cyl.origin, &rpos, sizeof(EERIE_3D));
				distance -= curmovedist;
			}
			else  //stopped
			{
				ip->velocity.x = ip->velocity.y = ip->velocity.z = 0.f;
				MOVING_CYLINDER = 0;
				return FALSE;
			}
		}

	oki:
		;
	}

	MOVING_CYLINDER = 0;
	return TRUE;
}
//---------------------------------------------------------------------
float CRepelUndead::Render(LPDIRECT3DDEVICE7 m_pd3dDevice)
{
 


	if (ulCurrentTime >= ulDuration)
	{
		return 0.f;
	}

	SETZWRITE(m_pd3dDevice, FALSE);
	m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,  D3DBLEND_ONE);
	m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
	SETALPHABLEND(m_pd3dDevice, TRUE);

	//----------------------------
	EERIE_3D  eObjAngle;
	EERIE_3D  eObjPos;
	EERIE_3D  eObjScale;
	EERIE_RGB rgbObjColor;

	eObjAngle.b = fBeta;
	eObjAngle.a = 0;
	eObjAngle.g = 0;
	eObjPos.x = eSrc.x;
	eObjPos.y = eSrc.y - 5.f;
	eObjPos.z = eSrc.z;
	rgbObjColor.r = 0.6f;
	rgbObjColor.g = 0.6f;
	rgbObjColor.b = 0.8f;

	float vv = 1.f + (EEsin(ARX_TIME_Get() * DIV1000)); 
	vv *= DIV2;
	vv += 1.1f;
	eObjScale.z = vv;
	eObjScale.y = vv;
	eObjScale.x = vv;

	if (ssol)
		DrawEERIEObjEx(m_pd3dDevice, ssol, &eObjAngle, &eObjPos, &eObjScale, &rgbObjColor);

	vv *= 100.f;

	for (int n = 0; n < 4; n++)
	{
		int j = ARX_PARTICLES_GetFree();

		if ((j != -1) && (!ARXPausedTimer))
		{
			ParticleCount++;
			particle[j].exist		=	1;
			particle[j].zdec		=	0;
 
			particle[j].ov.x		=	eSrc.x - EEsin(frand2() * 360.f) * vv; 
			particle[j].ov.y		=	eSrc.y;
			particle[j].ov.z		=	eSrc.z + EEcos(frand2() * 360.f) * vv; 
			particle[j].move.x		=	0.8f * frand2(); 
			particle[j].move.y		=	-4.f * rnd(); 
			particle[j].move.z		=	0.8f * frand2(); 
			particle[j].scale.x		=	-0.1f;
			particle[j].scale.y		=	-0.1f;
			particle[j].scale.z		=	-0.1f;
			particle[j].timcreation =	lARXTime;
			particle[j].tolive		=	2600 + (unsigned long)(rnd() * 600.f);
			particle[j].tc			=	tex_p2;
			particle[j].siz			=	0.3f;
			particle[j].r			=	0.4f;
			particle[j].g			=	0.4f;
			particle[j].b			=	0.6f;
		}
	}

	if (this->lLightId == -1)
		this->lLightId = GetFreeDynLight();

	if (this->lLightId != -1)
	{
		long id = this->lLightId;
		DynLight[id].exist = 1;
		DynLight[id].intensity = 2.3f;
		DynLight[id].fallend = 350.f;
		DynLight[id].fallstart = 150.f;
		DynLight[id].rgb.r = 0.8f;
		DynLight[id].rgb.g = 0.8f;
		DynLight[id].rgb.b = 1;
		DynLight[id].pos.x = eSrc.x;
		DynLight[id].pos.y = eSrc.y - 50.f;
		DynLight[id].pos.z = eSrc.z;
		DynLight[id].duration = 200;
		DynLight[id].time_creation = ARXTimeUL();
	}

	return 1;
}
//-----------------------------------------------------------------------------
void CMultiPoisonProjectile::Create(EERIE_3D _eSrc, float _afBeta = 0)
{

	float afAlpha = 0.f;
	float afBeta = 0.f;

	spells[spellinstance].hand_group = inter.iobj[spells[spellinstance].caster]->obj->fastaccess.primary_attach;

	if (spells[spellinstance].hand_group != -1)
	{
		spells[spellinstance].hand_pos.x = inter.iobj[spells[spellinstance].caster]->obj->vertexlist3[spells[spellinstance].hand_group].v.x;
		spells[spellinstance].hand_pos.y = inter.iobj[spells[spellinstance].caster]->obj->vertexlist3[spells[spellinstance].hand_group].v.y;
		spells[spellinstance].hand_pos.z = inter.iobj[spells[spellinstance].caster]->obj->vertexlist3[spells[spellinstance].hand_group].v.z;
	}

	if (spells[spellinstance].caster == 0) // player
	{
		afBeta = player.angle.b;
		afAlpha = player.angle.a;

		if (spells[spellinstance].hand_group != -1)
		{
			_eSrc.x = spells[spellinstance].hand_pos.x - EEsin(DEG2RAD(afBeta)) * 90;
			_eSrc.y = spells[spellinstance].hand_pos.y;
			_eSrc.z = spells[spellinstance].hand_pos.z + EEcos(DEG2RAD(afBeta)) * 90;
		}
		else
		{
			_eSrc.x = player.pos.x - EEsin(DEG2RAD(afBeta)) * 90;
			_eSrc.y = player.pos.y;
			_eSrc.z = player.pos.z + EEcos(DEG2RAD(afBeta)) * 90;
		}
	}
	else
	{
		afBeta = inter.iobj[spells[spellinstance].caster]->angle.b;

		if (spells[spellinstance].hand_group != -1)
		{
			_eSrc.x = spells[spellinstance].hand_pos.x - EEsin(DEG2RAD(afBeta)) * 90;
			_eSrc.y = spells[spellinstance].hand_pos.y;
			_eSrc.z = spells[spellinstance].hand_pos.z + EEcos(DEG2RAD(afBeta)) * 90;
		}
		else
		{
			_eSrc.x = inter.iobj[spells[spellinstance].caster]->pos.x - EEsin(DEG2RAD(afBeta)) * 90;
			_eSrc.y = inter.iobj[spells[spellinstance].caster]->pos.y;
			_eSrc.z = inter.iobj[spells[spellinstance].caster]->pos.z + EEcos(DEG2RAD(afBeta)) * 90;
		}
	}


	long lMax = 0;

	for (UINT i = 0 ; i < uiNumber ; i++)
	{
		pTab[i]->Create(_eSrc, afBeta + frand2() * 10.0f);
		long lTime = ulDuration + (long) rnd() * 5000;
		pTab[i]->SetDuration(lTime);
		lMax = max(lMax, lTime);

		CPoisonProjectile * pPP = (CPoisonProjectile *) pTab[i];

		pPP->SetColor(0.5f + rnd() * 0.5f, 0.5f + rnd() * 0.5f, 0.5f + rnd() * 0.5f);
		pPP->SetColor1(0.5f + rnd() * 0.5f, 0.5f + rnd() * 0.5f, 0.5f + rnd() * 0.5f);

		pPP->SetColor(0, 1, 0);
		pPP->SetColor1(0.3f, 0.8f, 0);
		pPP->lLightId = GetFreeDynLight();

		if (pPP->lLightId != -1)
		{
			long id						= pPP->lLightId;
			DynLight[id].exist			= 1;
			DynLight[id].intensity		= 2.3f;
			DynLight[id].fallend		= 250.f;
			DynLight[id].fallstart		= 150.f;
			DynLight[id].rgb.r			= 0;
			DynLight[id].rgb.g			= 1;
			DynLight[id].rgb.b			= 0;
			DynLight[id].pos.x			= pPP->eSrc.x;
			DynLight[id].pos.y			= pPP->eSrc.y;
			DynLight[id].pos.z			= pPP->eSrc.z;
			DynLight[id].time_creation	= ARXTimeUL();
			DynLight[id].duration		= 200;
		}

		pTab[i]->spellinstance = this->spellinstance;

	}

	SetDuration(lMax + 1000);
}
Ejemplo n.º 11
0
//-----------------------------------------------------------------------------
void CMultiPoisonProjectile::Create(Vec3f _eSrc, float _afBeta = 0) {
	
	(void)_afBeta;

	float afBeta = 0.f;
	
	Entity * caster = entities[spells[spellinstance].caster];
	spells[spellinstance].hand_group = caster->obj->fastaccess.primary_attach;
	if(spells[spellinstance].hand_group != -1) {
		long group = spells[spellinstance].hand_group;
		spells[spellinstance].hand_pos = caster->obj->vertexlist3[group].v;
	}
	
	if (spells[spellinstance].caster == 0) // player
	{
		afBeta = player.angle.b;

		if (spells[spellinstance].hand_group != -1)
		{
			_eSrc.x = spells[spellinstance].hand_pos.x - EEsin(radians(afBeta)) * 90;
			_eSrc.y = spells[spellinstance].hand_pos.y;
			_eSrc.z = spells[spellinstance].hand_pos.z + EEcos(radians(afBeta)) * 90;
		}
		else
		{
			_eSrc.x = player.pos.x - EEsin(radians(afBeta)) * 90;
			_eSrc.y = player.pos.y;
			_eSrc.z = player.pos.z + EEcos(radians(afBeta)) * 90;
		}
	}
	else
	{
		afBeta = entities[spells[spellinstance].caster]->angle.b;

		if (spells[spellinstance].hand_group != -1)
		{
			_eSrc.x = spells[spellinstance].hand_pos.x - EEsin(radians(afBeta)) * 90;
			_eSrc.y = spells[spellinstance].hand_pos.y;
			_eSrc.z = spells[spellinstance].hand_pos.z + EEcos(radians(afBeta)) * 90;
		}
		else
		{
			_eSrc.x = entities[spells[spellinstance].caster]->pos.x - EEsin(radians(afBeta)) * 90;
			_eSrc.y = entities[spells[spellinstance].caster]->pos.y;
			_eSrc.z = entities[spells[spellinstance].caster]->pos.z + EEcos(radians(afBeta)) * 90;
		}
	}


	long lMax = 0;

	for (unsigned int i = 0 ; i < uiNumber ; i++)
	{
		pTab[i]->Create(_eSrc, afBeta + frand2() * 10.0f);
		long lTime = ulDuration + Random::get(0, 5000);
		pTab[i]->SetDuration(lTime);
		lMax = max(lMax, lTime);

		CPoisonProjectile * pPP = (CPoisonProjectile *) pTab[i];

		pPP->lLightId = GetFreeDynLight();

		if (pPP->lLightId != -1)
		{
			long id						= pPP->lLightId;
			DynLight[id].exist			= 1;
			DynLight[id].intensity		= 2.3f;
			DynLight[id].fallend		= 250.f;
			DynLight[id].fallstart		= 150.f;
			DynLight[id].rgb = Color3f::green;
			DynLight[id].pos = pPP->eSrc;
			DynLight[id].time_creation	= (unsigned long)(arxtime);
			DynLight[id].duration		= 200;
		}

		pTab[i]->spellinstance = this->spellinstance;

	}

	SetDuration(lMax + 1000);
}
Ejemplo n.º 12
0
void CMultiMagicMissile::Create()
{
	
	long lMax = 0;

	if(pTab) {
		spells[spellinstance].hand_group = GetActionPointIdx(entities[spells[spellinstance].caster]->obj, "primary_attach");
		
		if(spells[spellinstance].hand_group != -1) {
			Entity * caster = entities[spells[spellinstance].caster];
			long group = spells[spellinstance].hand_group;
			spells[spellinstance].hand_pos = caster->obj->vertexlist3[group].v;
		}
		
		Vec3f aePos;
		float afAlpha, afBeta;
		if(spells[spellinstance].caster == 0) { // player
			afBeta = player.angle.getPitch();
			afAlpha = player.angle.getYaw();
			Vec3f vector;
			vector.x = -EEsin(radians(afBeta)) * EEcos(radians(afAlpha)) * 60.f;
			vector.y = EEsin(radians(afAlpha)) * 60.f;
			vector.z = EEcos(radians(afBeta)) * EEcos(radians(afAlpha)) * 60.f;

			if(spells[spellinstance].hand_group != -1) {
				aePos = spells[spellinstance].hand_pos + vector;
			} else {
				aePos.x = player.pos.x - EEsin(radians(afBeta)) + vector.x; 
				aePos.y = player.pos.y + vector.y; //;
				aePos.z = player.pos.z + EEcos(radians(afBeta)) + vector.z; 
			}
		} else {
			afAlpha = 0;
			afBeta = entities[spells[spellinstance].caster]->angle.getPitch();
			Vec3f vector;
			vector.x = -EEsin(radians(afBeta)) * EEcos(radians(afAlpha)) * 60;
			vector.y = EEsin(radians(afAlpha)) * 60;
			vector.z = EEcos(radians(afBeta)) * EEcos(radians(afAlpha)) * 60;

			if(spells[spellinstance].hand_group != -1) {
				aePos = spells[spellinstance].hand_pos + vector;
			} else {
				aePos = entities[spells[spellinstance].caster]->pos + vector;
			}

			Entity * io = entities[spells[spellinstance].caster];

			if(ValidIONum(io->targetinfo)) {
				Vec3f * p1 = &spells[spellinstance].caster_pos;
				Vec3f * p2 = &entities[io->targetinfo]->pos;
				afAlpha = -(degrees(getAngle(p1->y, p1->z, p2->y, p2->z + glm::distance(Vec2f(p2->x, p2->z), Vec2f(p1->x, p1->z))))); //alpha entre orgn et dest;
			} else if (ValidIONum(spells[spellinstance].target)) {
				Vec3f * p1 = &spells[spellinstance].caster_pos;
				Vec3f * p2 = &entities[spells[spellinstance].target]->pos;
				afAlpha = -(degrees(getAngle(p1->y, p1->z, p2->y, p2->z + glm::distance(Vec2f(p2->x, p2->z), Vec2f(p1->x, p1->z))))); //alpha entre orgn et dest;
			}
		}

		for(unsigned int i = 0; i < uiNumber; i++) {
			if(pTab[i]) {
				Anglef angles(afAlpha, afBeta, 0.f);

				if(i > 0) {
					angles.setYaw(angles.getYaw() + frand2() * 4.0f);
					angles.setPitch(angles.getPitch() + frand2() * 6.0f);
				}

				pTab[i]->Create(aePos, angles);  

				float fTime = ulDuration + frand2() * 1000.0f;
				long lTime = checked_range_cast<long>(fTime);

				lTime		= std::max(1000L, lTime);
				lMax		= std::max(lMax, lTime);

				CMagicMissile * pMM = (CMagicMissile *)pTab[i];

				pMM->SetDuration(lTime);

				if(spells[spellinstance].caster == 0 && cur_mr == 3) {
					pMM->SetColor(Color3f(0.9f, 0.2f, 0.5f));
				} else {
					pMM->SetColor(Color3f(0.9f + rnd() * 0.1f, 0.9f + rnd() * 0.1f, 0.7f + rnd() * 0.3f));
				}

				pTab[i]->lLightId = GetFreeDynLight();

				if(pTab[i]->lLightId != -1) {
					EERIE_LIGHT * el = &DynLight[pTab[i]->lLightId];
					el->exist		= 1;
					el->intensity	= 0.7f + 2.3f;
					el->fallend		= 190.f;
					el->fallstart	= 80.f;

					if(spells[spellinstance].caster == 0 && cur_mr == 3) {
						el->rgb.r = 1;
						el->rgb.g = 0.3f;
						el->rgb.b = 0.8f;
					} else {
						el->rgb.r = 0;
						el->rgb.g = 0;
						el->rgb.b = 1;
					}

					el->pos	 = pMM->eSrc;
					el->duration = 300;
				}
			}
		}
	}

	SetDuration(lMax + 1000);
}
Ejemplo n.º 13
0
void AddFixedObjectHalo(const EERIE_FACE & face, const TransformInfo & t, const Entity * io, TexturedVertex * tvList, const EERIE_3DOBJ * eobj)
{
	float mdist=ACTIVECAM->cdepth;
	float ddist = mdist-fdist(t.pos, ACTIVECAM->orgTrans.pos);
	ddist = ddist/mdist;
	ddist = std::pow(ddist, 6);

	ddist = clamp(ddist, 0.25f, 0.9f);

	float tot=0;
	float _ffr[3];

	for(long o = 0; o < 3; o++) {
		Vec3f temporary3D;
		temporary3D = t.rotation * eobj->vertexlist[face.vid[o]].norm;

		float power = 255.f-(float)EEfabs(255.f*(temporary3D.z)*( 1.0f / 2 ));

		power = clamp(power, 0.f, 255.f);

		tot += power;
		_ffr[o] = power;

		u8 lfr = io->halo.color.r * power;
		u8 lfg = io->halo.color.g * power;
		u8 lfb = io->halo.color.b * power;
		tvList[o].color = ((0xFF << 24) | (lfr << 16) | (lfg << 8) | (lfb));
	}

	if(tot > 150.f) {
		long first;
		long second;
		long third;

		if(_ffr[0] >= _ffr[1] && _ffr[1] >= _ffr[2]) {
			first = 0;
			second = 1;
			third = 2;
		} else if(_ffr[0] >= _ffr[2] && _ffr[2] >= _ffr[1]) {
			first = 0;
			second = 2;
			third = 1;
		} else if(_ffr[1] >= _ffr[0] && _ffr[0] >= _ffr[2]) {
			first = 1;
			second = 0;
			third = 2;
		} else if(_ffr[1] >= _ffr[2] && _ffr[2] >= _ffr[0]) {
			first = 1;
			second = 2;
			third = 0;
		} else if(_ffr[2] >= _ffr[0] && _ffr[0] >= _ffr[1]) {
			first = 2;
			second = 0;
			third = 1;
		} else {
			first = 2;
			second = 1;
			third = 0;
		}

		if(_ffr[first] > 70.f && _ffr[second] > 60.f) {
			TexturedVertex vert[4];

			vert[0] = tvList[first];
			vert[1] = tvList[first];
			vert[2] = tvList[second];
			vert[3] = tvList[second];

			float siz = ddist * (io->halo.radius * 1.5f * (EEsin(arxtime.get_frame_time() * .01f) * .1f + .7f)) * .6f;

			Vec3f vect1;
			vect1.x = tvList[first].p.x - tvList[third].p.x;
			vect1.y = tvList[first].p.y - tvList[third].p.y;
			float len1 = 1.f / ffsqrt(vect1.x * vect1.x + vect1.y * vect1.y);

			if(vect1.x < 0.f)
				len1 *= 1.2f;

			vect1.x *= len1;
			vect1.y *= len1;

			Vec3f vect2;
			vect2.x = tvList[second].p.x - tvList[third].p.x;
			vect2.y = tvList[second].p.y - tvList[third].p.y;
			float len2 = 1.f / ffsqrt(vect2.x * vect2.x + vect2.y * vect2.y);

			if(vect2.x < 0.f)
				len2 *= 1.2f;

			vect2.x *= len2;
			vect2.y *= len2;

			vert[1].p.x += (vect1.x + 0.2f - rnd() * 0.1f) * siz;
			vert[1].p.y += (vect1.y + 0.2f - rnd() * 0.1f) * siz;
			vert[1].color = 0xFF000000;

			vert[0].p.z += 0.0001f;
			vert[3].p.z += 0.0001f;
			vert[1].rhw *= .8f;
			vert[2].rhw *= .8f;

			vert[2].p.x += (vect2.x + 0.2f - rnd() * 0.1f) * siz;
			vert[2].p.y += (vect2.y + 0.2f - rnd() * 0.1f) * siz;

			if(io->halo.flags & HALO_NEGATIVE)
				vert[2].color = 0x00000000;
			else
				vert[2].color = 0xFF000000;

			Halo_AddVertices(vert);
		}
	}
}
Ejemplo n.º 14
0
float CRepelUndead::Render() {
	
	if(ulCurrentTime >= ulDuration) {
		return 0.f;
	}
	
	GRenderer->SetRenderState(Renderer::DepthWrite, false);
	GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendOne);
	GRenderer->SetRenderState(Renderer::AlphaBlending, true);
	
	Anglef  eObjAngle;
	Vec3f  eObjPos;
	Vec3f  eObjScale;
	Color3f rgbObjColor;

	eObjAngle.b = fBeta;
	eObjAngle.a = 0;
	eObjAngle.g = 0;
	eObjPos.x = eSrc.x;
	eObjPos.y = eSrc.y - 5.f;
	eObjPos.z = eSrc.z;
	rgbObjColor.r = 0.6f;
	rgbObjColor.g = 0.6f;
	rgbObjColor.b = 0.8f;

	float vv = 1.f + (EEsin(arxtime.get_updated() * ( 1.0f / 1000 ))); 
	vv *= ( 1.0f / 2 );
	vv += 1.1f;
	eObjScale.z = vv;
	eObjScale.y = vv;
	eObjScale.x = vv;
	
	if(ssol) {
		DrawEERIEObjEx(ssol, &eObjAngle, &eObjPos, &eObjScale, &rgbObjColor);
	}
	
	vv *= 100.f;
	
	for(int n = 0; n < 4; n++) {
		
		PARTICLE_DEF * pd = createParticle();
		if(!pd) {
			break;
		}
		
		float dx = -EEsin(frand2() * 360.f) * vv;
		float dz =  EEcos(frand2() * 360.f) * vv;
		pd->ov = eSrc + Vec3f(dx, 0.f, dz);
		pd->move = Vec3f(0.8f * frand2(), -4.f * rnd(), 0.8f * frand2());
		pd->scale = Vec3f::repeat(-0.1f);
		pd->tolive = Random::get(2600, 3200);
		pd->tc = tex_p2;
		pd->siz = 0.3f;
		pd->rgb = Color3f(.4f, .4f, .6f);
	}
	
	if(lLightId == -1) {
		lLightId = GetFreeDynLight();
	}
	
	if(lLightId != -1) {
		long id = lLightId;
		DynLight[id].exist = 1;
		DynLight[id].intensity = 2.3f;
		DynLight[id].fallend = 350.f;
		DynLight[id].fallstart = 150.f;
		DynLight[id].rgb = Color3f(0.8f, 0.8f, 1.f);
		DynLight[id].pos = eSrc + Vec3f(0.f, -50.f, 0.f);
		DynLight[id].duration = 200;
		DynLight[id].time_creation = (unsigned long)(arxtime);
	}
	
	return 1;
}
Ejemplo n.º 15
0
//-----------------------------------------------------------------------------
void CFireBall::Update(unsigned long aulTime)
{
	ulCurrentTime += aulTime;

	if(ulCurrentTime > MIN_TIME_FIREBALL) {
		// smoke en retard
		pPSSmoke.SetPos(eCurPos);
		pPSSmoke.Update(aulTime);
		eCurPos += eMove * (aulTime * 0.0045f);
		pPSFire.SetPos(eCurPos);
		pPSFire.fParticleSpeed = 100;
		pPSFire.fParticleSpeedRandom = 200;
		pPSFire.p3ParticleGravity = -eMove * 2.f;
		pPSFire2.p3ParticleGravity = -eMove * 2.f;
		pPSFire2.SetPos(eCurPos);
		pPSFire2.fParticleSpeed = 100;
		pPSFire2.fParticleSpeedRandom = 100;
	}
	else
	{
		float afAlpha = 0.f;
	
		if (spells[spellinstance].caster == 0)
		{
			SetAngle(player.angle.b);
			afAlpha = player.angle.a;
			long idx = GetGroupOriginByName(entities[spells[spellinstance].caster]->obj, "chest");

			if (idx)
			{
				eCurPos.x = entities[spells[spellinstance].caster]->obj->vertexlist3[idx].v.x - fBetaRadSin * 60;
				eCurPos.y = entities[spells[spellinstance].caster]->obj->vertexlist3[idx].v.y;
				eCurPos.z = entities[spells[spellinstance].caster]->obj->vertexlist3[idx].v.z + fBetaRadCos * 60;
			}
			else
			{
				eCurPos.x = player.pos.x - fBetaRadSin * 60;
				eCurPos.y = player.pos.y;
				eCurPos.z = player.pos.z + fBetaRadCos * 60;
			}
		}
		else
		{
			SetAngle(entities[spells[spellinstance].caster]->angle.b);

			eCurPos.x = entities[spells[spellinstance].caster]->pos.x - fBetaRadSin * 60;
			eCurPos.y = entities[spells[spellinstance].caster]->pos.y;
			eCurPos.z = entities[spells[spellinstance].caster]->pos.z + fBetaRadCos * 60;

			if ((ValidIONum(spells[spellinstance].caster))
			        && (entities[spells[spellinstance].caster]->ioflags & IO_NPC))
			{
				eCurPos.x -= EEsin(radians(entities[spells[spellinstance].caster]->angle.b)) * 30.f;
				eCurPos.y -= 80.f;
				eCurPos.z += EEcos(radians(entities[spells[spellinstance].caster]->angle.b)) * 30.f;
			}
			
			Entity * io = entities[spells[spellinstance].caster];

			if (ValidIONum(io->targetinfo))
			{
				Vec3f * p1 = &eCurPos;
				Vec3f p2 = entities[io->targetinfo]->pos;
				p2.y -= 60.f;
				afAlpha = 360.f - (degrees(getAngle(p1->y, p1->z, p2.y, p2.z + dist(Vec2f(p2.x, p2.z), Vec2f(p1->x, p1->z))))); //alpha entre orgn et dest;
			}
		}


		eMove.x = - fBetaRadSin * 100 * cos(radians(MAKEANGLE(afAlpha)));
		eMove.y = sin(radians(MAKEANGLE(afAlpha))) * 100;
		eMove.z = + fBetaRadCos * 100 * cos(radians(MAKEANGLE(afAlpha)));

		Vec3f vMove = eMove.getNormalized();

		// smoke en retard
		pPSSmoke.p3ParticleDirection = -vMove;
		pPSSmoke.SetPos(eCurPos);
		pPSSmoke.RecomputeDirection();
		eCurPos = eCurPos + eMove * (aulTime * 0.0045f);
		pPSFire.p3ParticleDirection = -vMove;
		pPSFire.RecomputeDirection();
		pPSFire.SetPos(eCurPos);
		pPSFire.p3ParticleGravity = -eMove * 2.f;
		pPSFire2.p3ParticleDirection = -vMove;
		pPSFire2.p3ParticleGravity = -eMove * 2.f;
		pPSFire2.RecomputeDirection();
		pPSFire2.SetPos(eCurPos);
	}
	
	pPSFire.Update(aulTime);
	pPSFire2.Update(aulTime);
}
Ejemplo n.º 16
0
//-----------------------------------------------------------------------------
void CMultiMagicMissile::Create(EERIE_3D aePos, EERIE_3D angles)
{
	long lMax = 0;

	if (pTab)
	{

		float afAlpha = angles.a;
		float afBeta = angles.b;
		spells[spellinstance].hand_group = GetActionPointIdx(inter.iobj[spells[spellinstance].caster]->obj, "PRIMARY_ATTACH");

		if (spells[spellinstance].hand_group != -1)
		{
			spells[spellinstance].hand_pos.x = inter.iobj[spells[spellinstance].caster]->obj->vertexlist3[spells[spellinstance].hand_group].v.x;
			spells[spellinstance].hand_pos.y = inter.iobj[spells[spellinstance].caster]->obj->vertexlist3[spells[spellinstance].hand_group].v.y;
			spells[spellinstance].hand_pos.z = inter.iobj[spells[spellinstance].caster]->obj->vertexlist3[spells[spellinstance].hand_group].v.z;
		}

		if (spells[spellinstance].caster == 0) // player
		{
			afBeta = player.angle.b;
			afAlpha = player.angle.a;
			EERIE_3D vector;
			vector.x = -EEsin(DEG2RAD(afBeta)) * EEcos(DEG2RAD(afAlpha)) * 60.f;
			vector.y = EEsin(DEG2RAD(afAlpha)) * 60.f;
			vector.z = EEcos(DEG2RAD(afBeta)) * EEcos(DEG2RAD(afAlpha)) * 60.f;

			if (spells[spellinstance].hand_group != -1)
			{
				aePos.x = spells[spellinstance].hand_pos.x + vector.x; 
				aePos.y = spells[spellinstance].hand_pos.y + vector.y; 
				aePos.z = spells[spellinstance].hand_pos.z + vector.z; 
			}
			else
			{
				aePos.x = player.pos.x - EEsin(DEG2RAD(afBeta)) + vector.x; 
				aePos.y = player.pos.y + vector.y; //;
				aePos.z = player.pos.z + EEcos(DEG2RAD(afBeta)) + vector.z; 
			}
		}
		else
		{
			afAlpha = 0;
			afBeta = inter.iobj[spells[spellinstance].caster]->angle.b;
			EERIE_3D vector;
			vector.x = -EEsin(DEG2RAD(afBeta)) * EEcos(DEG2RAD(afAlpha)) * 60;
			vector.y = EEsin(DEG2RAD(afAlpha)) * 60;
			vector.z = EEcos(DEG2RAD(afBeta)) * EEcos(DEG2RAD(afAlpha)) * 60;

			if (spells[spellinstance].hand_group != -1)
			{
				aePos.x = spells[spellinstance].hand_pos.x + vector.x; 
				aePos.y = spells[spellinstance].hand_pos.y + vector.y; 
				aePos.z = spells[spellinstance].hand_pos.z + vector.z; 
			}
			else
			{
				aePos.x = inter.iobj[spells[spellinstance].caster]->pos.x + vector.x; 
				aePos.y = inter.iobj[spells[spellinstance].caster]->pos.y + vector.y; 
				aePos.z = inter.iobj[spells[spellinstance].caster]->pos.z + vector.z; 
			}

			INTERACTIVE_OBJ * io = inter.iobj[spells[spellinstance].caster];

			if (ValidIONum(io->targetinfo))
			{
				EERIE_3D * p1 = &spells[spellinstance].caster_pos;
				EERIE_3D * p2 = &inter.iobj[io->targetinfo]->pos;
				afAlpha = -(RAD2DEG(GetAngle(p1->y, p1->z, p2->y, p2->z + TRUEDistance2D(p2->x, p2->z, p1->x, p1->z)))); //alpha entre orgn et dest;
			}
			else if (ValidIONum(spells[spellinstance].target))
			{
				EERIE_3D * p1 = &spells[spellinstance].caster_pos;
				EERIE_3D * p2 = &inter.iobj[spells[spellinstance].target]->pos;
				afAlpha = -(RAD2DEG(GetAngle(p1->y, p1->z, p2->y, p2->z + TRUEDistance2D(p2->x, p2->z, p1->x, p1->z)))); //alpha entre orgn et dest;
			}
		}

		for (UINT i = 0 ; i < uiNumber ; i++)
		{
			if (pTab[i])
			{
				EERIE_3D angles;
				angles.a = afAlpha;
				angles.b = afBeta;
				angles.g = 0;

				if (i > 0)
				{
					angles.a += frand2() * 4.0f;
					angles.b += frand2() * 6.0f;
				}

				pTab[i]->Create(aePos, angles);  

				float	fTime	= ulDuration + frand2() * 1000.0f;
				ARX_CHECK_LONG(fTime);
				long	lTime	= ARX_CLEAN_WARN_CAST_LONG(fTime);

				lTime		= max(1000, lTime);
				lMax		= max(lMax, lTime);

				CMagicMissile * pMM = (CMagicMissile *)pTab[i];

				pMM->SetDuration(lTime);

				if ((spells[spellinstance].caster == 0) && (cur_mr == 3))
				{
					pMM->SetColor(0.9f, 0.2f, 0.5f);
					pMM->SetColor1(0.9f, 0.2f, 0.5f);
				}
				else
				{
					pMM->SetColor(0.9f + rnd() * 0.1f, 0.9f + rnd() * 0.1f, 0.7f + rnd() * 0.3f);
					pMM->SetColor1(0.9f + rnd() * 0.1f, 0.9f + rnd() * 0.1f, 0.7f + rnd() * 0.3f);
				}

				pTab[i]->lLightId = GetFreeDynLight();

				if (pTab[i]->lLightId != -1)
				{
					EERIE_LIGHT * el = &DynLight[pTab[i]->lLightId];
					el->exist		= 1;
					el->intensity	= 0.7f + 2.3f;
					el->fallend		= 190.f;
					el->fallstart	= 80.f;

					if ((spells[spellinstance].caster == 0) && (cur_mr == 3))
					{
						el->rgb.r = 1;
						el->rgb.g = 0.3f;
						el->rgb.b = 0.8f;
					}
					else
					{
						el->rgb.r = 0;
						el->rgb.g = 0;
						el->rgb.b = 1;
					}

					el->pos.x	 = pMM->eSrc.x;
					el->pos.y	 = pMM->eSrc.y;
					el->pos.z	 = pMM->eSrc.z;
					el->duration = 300;
				}

			}
		}
	}

	SetDuration(lMax + 1000);
}
Ejemplo n.º 17
0
/*--------------------------------------------------------------------------*/
float CPortal::Render(LPDIRECT3DDEVICE7 device)
{
	SETALPHABLEND(device, TRUE);
	SETZWRITE(device, FALSE);

	device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
	device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);

	//calcul sphere
	int			nb = this->spherenbpt;
	D3DTLVERTEX * v = this->sphered3d, d3dvs;
	EERIE_3D	* pt = this->spherevertex;
	int col = RGBA_MAKE(0, (int)(200.f * this->spherealpha), (int)(255.f * this->spherealpha), 255);

	while (nb)
	{
		d3dvs.sx = pt->x + this->pos.x;	//pt du bas
		d3dvs.sy = pt->y + this->pos.y;
		d3dvs.sz = pt->z + this->pos.z;
		EE_RTP(&d3dvs, v);

		if (!ARXPausedTimer) v->color = col;

		v++;
		pt++;
		nb--;
	}

	//update les couleurs aux impacts
	nb = 256;

	while (nb--)
	{
		if (this->tabeclair[nb].actif)
		{
			float a;

			a = 1.f - ((float)this->tabeclair[nb].currduration / (float)this->tabeclair[nb].duration);

			if (a < 0.f) a = 0.f;

			if (this->tabeclair[nb].numpt >= 0)
			{
				int r = (int)((0.f + (255.f - 0.f) * a) * this->spherealpha * 3.f);

				if (r > 255) r = 255;

				int g = (int)((200.f + (255.f - 200.f) * a) * this->spherealpha * 3.f);

				if (g > 255) g = 255;

				int b = (int)(255.f * this->spherealpha * 3.f);

				if (b > 255) b = 255;

				if (!ARXPausedTimer) this->sphered3d[this->tabeclair[nb].numpt].color = RGBA_MAKE(r, g, b, 255);
			}

		}
	}


	//affichage de la sphere back
	SETCULL(device, D3DCULL_CW);
	device->SetTexture(0, NULL);
	device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, D3DFVF_TLVERTEX, this->sphered3d, this->spherenbpt, (unsigned short *)this->sphereind, this->spherenbfaces * 3, 0);

	//affichage eclair
	this->DrawAllEclair(device);

	//affichage des particules à l'interieur
	if (rnd() > .25f)
	{
		int j = ARX_PARTICLES_GetFree();

		if ((j != -1) && (!ARXPausedTimer))
		{
			ParticleCount++;
			particle[j].exist = 1;
			particle[j].zdec = 0;

			float a = rnd() * 360.f;
			float b = rnd() * 360.f;
			float rr = this->r * (rnd() + .25f) * 0.05f;

			particle[j].ov.x	=	this->pos.x;
			particle[j].ov.y	=	this->pos.y;
			particle[j].ov.z	=	this->pos.z;
			particle[j].move.x	=	rr * EEsin(DEG2RAD(a)) * EEcos(DEG2RAD(b));
			particle[j].move.y	=	rr * EEcos(DEG2RAD(a));
			particle[j].move.z	=	rr * EEsin(DEG2RAD(a)) * EEsin(DEG2RAD(b));
			particle[j].siz		=	10.f;
			particle[j].tolive	=	1000 + (unsigned long)(float)(rnd() * 1000.f);
			particle[j].scale.x	=	1.f;
			particle[j].scale.y	=	1.f;
			particle[j].scale.z	=	1.f;
			particle[j].timcreation	=	lARXTime;
			particle[j].tc		=	tp;
			particle[j].special	=	FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
			particle[j].fparam	=	0.0000001f;
			particle[j].r		=	1.f;
			particle[j].g		=	1.f;
			particle[j].b		=	1.f;
		}
	}

	//affichage de la sphere front
	SETCULL(device, D3DCULL_CCW);
	device->SetTexture(0, NULL);
	device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, D3DFVF_TLVERTEX, this->sphered3d, this->spherenbpt, (unsigned short *)this->sphereind, this->spherenbfaces * 3, 0);

	device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
	device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
	SETALPHABLEND(device, FALSE);
	SETCULL(device, D3DCULL_NONE);
	SETZWRITE(device, TRUE);

	return 0;
}
Ejemplo n.º 18
0
void ARXDRAW_DrawAllTransPolysPos( LPDIRECT3DDEVICE7 pd3dDevice, long MODIF )
{
	int flg_NOCOUNT_USEVB = EERIE_NOCOUNT | (bSoftRender?EERIE_USEVB:0);
	SetZBias( pd3dDevice, 1 );

	SETALPHABLEND( pd3dDevice, TRUE );

	long i, to = 0; 

	register EERIEPOLY * ep;

	for ( i = 0 ; i < TRANSPOLYSPOS ; i++ ) 
	{
		ep = TransPol[i];

		if ( ( !( Project.hide & HIDE_BACKGROUND ) ) )
		{
			if ( ep->type & POLY_DOUBLESIDED ) SETCULL( pd3dDevice, D3DCULL_NONE );
			else SETCULL( pd3dDevice, D3DCULL_CW );
		
			if ( ViewMode & VIEWMODE_FLAT ) SETTC( pd3dDevice, NULL );
			else	SETTC( pd3dDevice, ep->tex );

			if ( ep->type & POLY_QUAD ) to = 4;
			else to = 3;

			float ttt = ep->transval;

			if ( ttt >= 2.f )  //MULTIPLICATIVE
			{
				SETBLENDMODE( pd3dDevice, D3DBLEND_ONE, D3DBLEND_ONE );
				ttt	*= DIV2;
				ttt	+= 0.5f;
				ep->tv[3].color = ep->tv[2].color = ep->tv[1].color = ep->tv[0].color = _EERIERGB( ttt );
			}
			else if ( ttt >= 1.f ) //ADDITIVE
			{	
				ttt -= 1.f;
				SETBLENDMODE( pd3dDevice, D3DBLEND_ONE, D3DBLEND_ONE );
				ep->tv[3].color = ep->tv[2].color = ep->tv[1].color = ep->tv[0].color = _EERIERGB( ttt );
			}
			else if ( ttt > 0.f )  //NORMAL TRANS
			{
				ttt = 1.f - ttt;
				SETBLENDMODE( pd3dDevice, D3DBLEND_DESTCOLOR, D3DBLEND_SRCCOLOR );
				ep->tv[3].color = ep->tv[2].color = ep->tv[1].color = ep->tv[0].color = _EERIERGBA(ttt);  
			}
			else  //SUBTRACTIVE
			{
				SETBLENDMODE( pd3dDevice, D3DBLEND_ZERO, D3DBLEND_INVSRCCOLOR );
				ttt = 1.f - ttt;
				ep->tv[3].color = ep->tv[2].color = ep->tv[1].color = ep->tv[0].color = _EERIERGB( ttt );
			}

			EERIEDRAWPRIM( pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE , ep->tv, to,  0, bSoftRender?EERIE_USEVB:0  );

				if (ep->type & POLY_LAVA)
				{
					pd3dDevice->SetRenderState( D3DRENDERSTATE_SRCBLEND,  D3DBLEND_DESTCOLOR );
					pd3dDevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE );	
					SETALPHABLEND( pd3dDevice, TRUE );	
					D3DTLVERTEX verts[4];
					SETTC( pd3dDevice, enviro );

				ARX_CHECK(to > 0);

					for ( long j = 0 ; j < to ; j++ )
					{
						verts[j].sx		= ep->tv[j].sx;
						verts[j].sy		= ep->tv[j].sy;
						verts[j].sz		= ep->tv[j].sz;
						verts[j].rhw	= ep->tv[j].rhw;
						verts[j].color	= 0xFFFFFFFF;
						verts[j].tu		= ep->v[j].sx * DIV1000 + EEsin( ( ep->v[j].sx ) * DIV200 + (float) FrameTime * DIV2000 ) * DIV20;
						verts[j].tv		= ep->v[j].sz * DIV1000 + EEcos( (ep->v[j].sz) * DIV200 + (float) FrameTime * DIV2000 ) * DIV20;
					}	

					EERIEDRAWPRIM(pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, to, 0, flg_NOCOUNT_USEVB );

					for ( i = 0 ; i < to ; i++ )
					{
						verts[i].tu = ep->v[i].sx * DIV1000 + EEsin( ( ep->v[i].sx ) * DIV100 + (float)FrameTime * DIV2000 ) * DIV10;
						verts[i].tv = ep->v[i].sz * DIV1000 + EEcos( ( ep->v[i].sz ) * DIV100 + (float)FrameTime * DIV2000 ) * DIV10;
					}	
					EERIEDRAWPRIM(pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, to, 0, flg_NOCOUNT_USEVB );
					
					for ( i = 0 ; i < to ; i++ )
					{
							verts[i].tu		= ep->v[i].sx * DIV600 + EEsin ( ( ep->v[i].sx ) * DIV160 + (float)FrameTime * DIV2000 ) * DIV11;
							verts[i].tv		= ep->v[i].sz * DIV600 + EEcos ( ( ep->v[i].sz ) * DIV160 + (float)FrameTime * DIV2000 ) * DIV11;
							verts[i].color	= 0xFF666666;
					}	

					pd3dDevice->SetRenderState( D3DRENDERSTATE_SRCBLEND,  D3DBLEND_ZERO );
					pd3dDevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCCOLOR );
					EERIEDRAWPRIM(pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, to, 0, flg_NOCOUNT_USEVB );
				}
			}


		if ( ep->type & POLY_WATER )
		{
				pd3dDevice->SetRenderState( D3DRENDERSTATE_SRCBLEND,  D3DBLEND_DESTCOLOR );
				pd3dDevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE );	

				SETALPHABLEND( pd3dDevice, TRUE );	
				
				D3DTLVERTEX verts[4];

				SETTC( pd3dDevice, enviro );

			ARX_CHECK(to > 0);

				for ( long j = 0 ; j < to ; j++ )
				{
					verts[j].sx		= ep->tv[j].sx;
					verts[j].sy		= ep->tv[j].sy;
					verts[j].sz		= ep->tv[j].sz;
					verts[j].rhw	= ep->tv[j].rhw;
					verts[j].color	= 0xFF505050;
					verts[j].tu		= ep->v[j].sx * DIV1000 + EEsin( ( ep->v[j].sx ) * DIV200 + (float)FrameTime * DIV1000 ) * DIV32;
					verts[j].tv		= ep->v[j].sz * DIV1000 + EEcos( ( ep->v[j].sz ) * DIV200 + (float)FrameTime * DIV1000 ) * DIV32;

					if ( ep->type & POLY_FALL ) verts[j].tv += (float)FrameTime * DIV4000;
				}

				EERIEDRAWPRIM(pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, to, 0, flg_NOCOUNT_USEVB );

				for ( i = 0 ; i < to ; i++ )
				{
					verts[i].tu = ( ep->v[i].sx + 30.f ) * DIV1000 + EEsin( ( ep->v[i].sx + 30 ) * DIV200 + (float)FrameTime * DIV1000 ) * DIV28;
					verts[i].tv = ( ep->v[i].sz + 30.f ) * DIV1000 - EEcos( ( ep->v[i].sz + 30 ) * DIV200 + (float)FrameTime * DIV1000 ) * DIV28;

					if ( ep->type & POLY_FALL ) verts[i].tv += (float)FrameTime * DIV4000;
				}

				EERIEDRAWPRIM(pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, to, 0, flg_NOCOUNT_USEVB );

				for ( i = 0 ; i < to ; i++ )
				{
					verts[i].tu = ( ep->v[i].sx + 60.f ) * DIV1000 - EEsin( ( ep->v[i].sx + 60 ) * DIV200 + (float)FrameTime * DIV1000 ) * DIV40;
					verts[i].tv = ( ep->v[i].sz + 60.f ) * DIV1000 - EEcos( ( ep->v[i].sz + 60 ) * DIV200 + (float)FrameTime * DIV1000 ) * DIV40;

					if ( ep->type & POLY_FALL ) verts[i].tv += (float)FrameTime * DIV4000;
				}	
				EERIEDRAWPRIM(pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, to, 0, flg_NOCOUNT_USEVB );
		}
	}

	SetZBias( pd3dDevice, 0 );
}
/*--------------------------------------------------------------------------*/
float CLevitate::Render(LPDIRECT3DDEVICE7 device)
{
	if (this->key > 1) return 0;

	SETALPHABLEND(device, TRUE);
	SETZWRITE(device, FALSE);

	//calcul du cone
	D3DTLVERTEX d3dvs, *d3dv;
	EERIE_3D	* vertex;
	int			nb, nbc, col;
	float		ddu = this->ang;
	float		u = ddu, du = .99999999f / (float)this->def;

	switch (this->key)
	{
		case 0:
			nbc = 2;

			while (nbc--)
			{
				vertex = this->cone[nbc].conevertex;
				d3dv = this->cone[nbc].coned3d;
				nb = (this->cone[nbc].conenbvertex) >> 1;

				while (nb)
				{
					d3dvs.sx = this->pos.x + (vertex + 1)->x + ((vertex->x - (vertex + 1)->x) * this->scale);
					d3dvs.sy = this->pos.y + (vertex + 1)->y + ((vertex->y - (vertex + 1)->y) * this->scale);
					d3dvs.sz = this->pos.z + (vertex + 1)->z + ((vertex->z - (vertex + 1)->z) * this->scale);
					
					EE_RT2(&d3dvs, d3dv);


					float fRandom	= rnd() * 80.f ;
					ARX_CHECK_INT(fRandom);

					col	= ARX_CLEAN_WARN_CAST_INT(fRandom);


					if (!ARXPausedTimer) d3dv->color = RGBA_MAKE(col, col, col, col);

					d3dv->tu = u;
					d3dv->tv = 0.f;
					vertex++;
					d3dv++;

					d3dvs.sx = this->pos.x + vertex->x;
					d3dvs.sy = this->pos.y;
					d3dvs.sz = this->pos.z + vertex->z;
					
					EE_RT2(&d3dvs, d3dv);


					fRandom = rnd() * 80.f ;
					ARX_CHECK_INT(fRandom);

					col = ARX_CLEAN_WARN_CAST_INT(fRandom);


					if (!ARXPausedTimer) d3dv->color = RGBA_MAKE(0, 0, 0, col);

					d3dv->tu = u;
					d3dv->tv = 0.9999999f;
					vertex++;
					d3dv++;

					u += du;
					nb--;
				}

				u = ddu;
				du = -du;
			}

			nbc = 3;

			while (nbc--)
			{
				int j = ARX_PARTICLES_GetFree();

				if ((j != -1) && (!ARXPausedTimer))
				{
					ParticleCount++;
					particle[j].exist = 1;
					particle[j].zdec = 0;

					float a = DEG2RAD(360.f * rnd());

					particle[j].ov.x = this->pos.x + this->rbase * EEcos(a);
					particle[j].ov.y = this->pos.y;
					particle[j].ov.z = this->pos.z + this->rbase * EEsin(a);
					float t = EEDistance3D(&particle[j].ov, &this->pos);
					particle[j].move.x = (5.f + 5.f * rnd()) * ((particle[j].ov.x - this->pos.x) / t);
					particle[j].move.y = 3.f * rnd();
					particle[j].move.z = (5.f + 5.f * rnd()) * ((particle[j].ov.z - this->pos.z) / t);
					particle[j].siz = 30.f + 30.f * rnd();
					particle[j].tolive = 3000;
					particle[j].scale.x = 1.f;
					particle[j].scale.y = 1.f;
					particle[j].scale.z = 1.f;
					particle[j].timcreation = -(long)(ARXTime + 3000); //spells[i].lastupdate;
					particle[j].tc = NULL;
					particle[j].special = FIRE_TO_SMOKE | FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
					particle[j].fparam = 0.0000001f;
					particle[j].r = 1.f;
					particle[j].g = 1.f;
					particle[j].b = 1.f;
				}
			}
			break;
		case 1:
			nbc = 2;

			while (nbc--)
			{
				vertex = this->cone[nbc].conevertex;
				d3dv = this->cone[nbc].coned3d;
				nb = (this->cone[nbc].conenbvertex) >> 1;

				while (nb)
				{
					d3dvs.sx = this->pos.x + vertex->x;
					d3dvs.sy = this->pos.y + vertex->y;
					d3dvs.sz = this->pos.z + vertex->z;
	
					EE_RT2(&d3dvs, d3dv);
					col = (int)(rnd() * 80.f);

					if (!ARXPausedTimer) d3dv->color = RGBA_MAKE(col, col, col, col);

					d3dv->tu = u;
					d3dv->tv = 0.f;
					vertex++;
					d3dv++;

					d3dvs.sx = this->pos.x + vertex->x;
					d3dvs.sy = this->pos.y;
					d3dvs.sz = this->pos.z + vertex->z;

					EE_RT2(&d3dvs, d3dv);
					col = (int)(rnd() * 80.f);

					if (!ARXPausedTimer) d3dv->color = RGBA_MAKE(0, 0, 0, col);

					d3dv->tu = u;
					d3dv->tv = 1; 
					vertex++;
					d3dv++;

					u += du;
					nb--;
				}

				u = ddu;
				du = -du;
			}

			nbc = 10;

			while (nbc--)
			{
				int j = ARX_PARTICLES_GetFree();

				if ((j != -1) && (!ARXPausedTimer))
				{
					ParticleCount++;
					particle[j].exist = 1;
					particle[j].zdec = 0;

					float a = DEG2RAD(360.f * rnd());

					particle[j].ov.x = this->pos.x + this->rbase * EEcos(a);
					particle[j].ov.y = this->pos.y;
					particle[j].ov.z = this->pos.z + this->rbase * EEsin(a);
					float t = EEDistance3D(&particle[j].ov, &this->pos);
					particle[j].move.x = (5.f + 5.f * rnd()) * ((particle[j].ov.x - this->pos.x) / t);
					particle[j].move.y = 3.f * rnd();
					particle[j].move.z = (5.f + 5.f * rnd()) * ((particle[j].ov.z - this->pos.z) / t);
					particle[j].siz = 30.f + 30.f * rnd();
					particle[j].tolive = 3000;
					particle[j].scale.x = 1.f;
					particle[j].scale.y = 1.f;
					particle[j].scale.z = 1.f;
					particle[j].timcreation = -(long)(ARXTime + 3000);
					particle[j].tc = NULL;
					particle[j].special = FIRE_TO_SMOKE | FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
					particle[j].fparam = 0.0000001f;
					particle[j].r = 1.f;
					particle[j].g = 1.f;
					particle[j].b = 1.f;
				}
			}

			break;
	}

	//tracé du cone back
	device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
	device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
	SETALPHABLEND(device, TRUE);
	SETTEXTUREWRAPMODE(device, D3DTADDRESS_MIRROR);

	if (this->tsouffle) device->SetTexture(0, this->tsouffle->m_pddsSurface);
	else device->SetTexture(0, NULL);

	SETCULL(device, D3DCULL_CW);
	int i = cone[1].conenbfaces - 2;
	int j = 0;

	while (i--)
	{
		ARX_DrawPrimitive_SoftClippZ(&cone[1].coned3d[j],
		                             &cone[1].coned3d[j+1],
		                             &cone[1].coned3d[j+2]);
		j++;
	}

	i = cone[0].conenbfaces - 2;
	j = 0;

	while (i--)
	{
		ARX_DrawPrimitive_SoftClippZ(&cone[0].coned3d[j],
		                             &cone[0].coned3d[j+1],
		                             &cone[0].coned3d[j+2]);
		j++;
	}

	//tracé du cone front
	SETCULL(device, D3DCULL_CCW);
	
	i = cone[1].conenbfaces - 2;
	j = 0;

	while (i--)
	{
		ARX_DrawPrimitive_SoftClippZ(&cone[1].coned3d[j],
		                             &cone[1].coned3d[j+1],
		                             &cone[1].coned3d[j+2]);
		j++;
	}

	i = cone[0].conenbfaces - 2;
	j = 0;

	while (i--)
	{
		ARX_DrawPrimitive_SoftClippZ(&cone[0].coned3d[j],
		                             &cone[0].coned3d[j+1],
		                             &cone[0].coned3d[j+2]);
		j++;
	}

	//tracé des pierres
	device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
	device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
	this->DrawStone(device);

	device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
	device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
	SETALPHABLEND(device, FALSE);
	SETZWRITE(device, TRUE);

	return 0;
}
Ejemplo n.º 20
0
void AddFlare(const Vec2s & pos, float sm, short typ, Entity * io, bool bookDraw) {

	long i;
	for(i = 0; i < MAX_FLARES; i++) {
		if(!magicFlares[i].exist) {
			break;
		}
	}
	if(i >= MAX_FLARES) {
		return;
	}

	FLARES * fl = &magicFlares[i];
	fl->exist = 1;
	flarenum++;

	if(!bookDraw)
		fl->bDrawBitmap = 0;
	else
		fl->bDrawBitmap = 1;

	fl->io = io;
	if(io) {
		fl->flags = 1;
		io->flarecount++;
	} else {
		fl->flags = 0;
	}

	fl->x = float(pos.x) - rnd() * 4.f;
	fl->y = float(pos.y) - rnd() * 4.f - 50.f;
	fl->tv.rhw = fl->v.rhw = 1.f;
	fl->tv.specular = fl->v.specular = 1;

	if(!bookDraw) {
		EERIE_CAMERA ka = *Kam;
		ka.angle = Anglef(360.f, 360.f, 360.f) - ka.angle;
		EERIE_CAMERA * oldcam = ACTIVECAM;
		SetActiveCamera(&ka);
		PrepareCamera(&ka);
		fl->v.p += ka.orgTrans.pos;
		EE_RTP(&fl->tv, &fl->v);
		fl->v.p += ka.orgTrans.pos;

		float vx = -(fl->x - subj.center.x) * 0.2173913f;
		float vy = (fl->y - subj.center.y) * 0.1515151515151515f;
		if(io) {
			fl->v.p.x = io->pos.x - EEsin(radians(MAKEANGLE(io->angle.getPitch() + vx))) * 100.f;
			fl->v.p.y = io->pos.y + EEsin(radians(MAKEANGLE(io->angle.getYaw() + vy))) * 100.f - 150.f;
			fl->v.p.z = io->pos.z + EEcos(radians(MAKEANGLE(io->angle.getPitch() + vx))) * 100.f;
		} else {
			fl->v.p.x = float(pos.x - (g_size.width() / 2)) * 150.f / float(g_size.width());
			fl->v.p.y = float(pos.y - (g_size.height() / 2)) * 150.f / float(g_size.width());
			fl->v.p.z = 75.f;
			ka = *oldcam;
			SetActiveCamera(&ka);
			PrepareCamera(&ka);
			float temp = (fl->v.p.y * -ka.orgTrans.xsin) + (fl->v.p.z * ka.orgTrans.xcos);
			fl->v.p.y = (fl->v.p.y * ka.orgTrans.xcos) - (-fl->v.p.z * ka.orgTrans.xsin);
			fl->v.p.z = (temp * ka.orgTrans.ycos) - (-fl->v.p.x * ka.orgTrans.ysin);
			fl->v.p.x = (temp * -ka.orgTrans.ysin) + (fl->v.p.x * ka.orgTrans.ycos);
			fl->v.p += oldcam->orgTrans.pos;
		}
		fl->tv.p = fl->v.p;
		SetActiveCamera(oldcam);
		PrepareCamera(oldcam);
	} else {
		fl->tv.p = Vec3f(fl->x, fl->y, 0.001f);
	}

	switch(PIPOrgb) {
		case 0: {
			fl->rgb = Color3f(rnd() * (2.f/3) + .4f, rnd() * (2.f/3), rnd() * (2.f/3) + .4f);
			break;
		}
		case 1: {
			fl->rgb = Color3f(rnd() * .625f + .5f, rnd() * .625f + .5f, rnd() * .55f);
			break;
		}
		case 2: {
			fl->rgb = Color3f(rnd() * (2.f/3) + .4f, rnd() * .55f, rnd() * .55f);
			break;
		}
	}

	if(typ == -1) {
		float zz = (EERIEMouseButton & 1) ? 0.29f : ((sm > 0.5f) ? rnd() : 1.f);
		if(zz < 0.2f) {
			fl->type = 2;
			fl->size = rnd() * 42.f + 42.f;
			fl->tolive = (800.f + rnd() * 800.f) * FLARE_MUL;
		} else if(zz < 0.5f) {
			fl->type = 3;
			fl->size = rnd() * 52.f + 16.f;
			fl->tolive = (800.f + rnd() * 800.f) * FLARE_MUL;
		} else {
			fl->type = 1;
			fl->size = (rnd() * 24.f + 32.f) * sm;
			fl->tolive = (1700.f + rnd() * 500.f) * FLARE_MUL;
		}
	} else {
		fl->type = (rnd() > 0.8f) ? 1 : 4;
		fl->size = (rnd() * 38.f + 64.f) * sm;
		fl->tolive = (1700.f + rnd() * 500.f) * FLARE_MUL;
	}

	fl->dynlight = -1;
	fl->move = OPIPOrgb;

	for(long kk = 0; kk < 3; kk++) {

		if(rnd() < 0.5f) {
			continue;
		}

		PARTICLE_DEF * pd = createParticle();
		if(!pd) {
			break;
		}

		if(!bookDraw) {
			pd->special = FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
			if(!io) {
				pd->special |= PARTICLE_NOZBUFFER;
			}
		} else {
			pd->special = FADE_IN_AND_OUT;
		}

		pd->ov = fl->v.p + randomVec(-5.f, 5.f);
		pd->move = Vec3f(0.f, 5.f, 0.f);
		pd->scale = Vec3f(-2.f);
		pd->tolive = 1300 + kk * 100 + Random::get(0, 800);
		pd->tc = fire2;
		if(kk == 1) {
			pd->move.y = 4.f;
			pd->siz = 1.5f;
		} else {
			pd->siz = 1.f + rnd();
		}
		pd->rgb = Color3f(fl->rgb.r * (2.f/3), fl->rgb.g * (2.f/3), fl->rgb.b * (2.f/3));
		pd->fparam = 1.2f;

		if(bookDraw)
			pd->type = PARTICLE_2D;
	}
}
//---------------------------------------------------------------------
float CRuneOfGuarding::Render(LPDIRECT3DDEVICE7 m_pd3dDevice)
{
 

	float x = eSrc.x;
	float y = eSrc.y - 20;
	float z = eSrc.z;

	SETZWRITE(m_pd3dDevice, FALSE);
	m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,  D3DBLEND_ONE);
	m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
	SETALPHABLEND(m_pd3dDevice, TRUE);

	//----------------------------
	//	long color = D3DRGB(1,1,1);
	//	int size = 100;
	//----------------------------
	EERIE_3D stiteangle;
	EERIE_3D stitepos;
	EERIE_3D stitescale;
	EERIE_RGB stitecolor;

	float stiteangleb = (float) ulCurrentTime * fOneOnDuration * 120;
	stiteangle.a = 0;
	stiteangle.g = 0;
	stitepos.x = x;
	stitepos.y = y;
	stitepos.z = z;

	float gtc = (float)ARX_TIME_Get();
	float v = EEsin(gtc * DIV1000) * DIV10;
	stiteangle.b = MAKEANGLE(gtc * DIV1000); 
	stitecolor.r = 0.4f - v;
	stitecolor.g = 0.4f - v;
	stitecolor.b = 0.6f - v;
	stitescale.x = 1;
	stitescale.y = -0.1f;
	stitescale.z = 1;

	if (slight)
		DrawEERIEObjEx(m_pd3dDevice, slight, &stiteangle, &stitepos, &stitescale, &stitecolor);

	stiteangle.b = stiteangleb;
	stitecolor.r = 0.6f;
	stitecolor.g = 0.f;
	stitecolor.b = 0.f;
	stitescale.x = 2;
	stitescale.y = 2;
	stitescale.z = 2;

	if (ssol)
		DrawEERIEObjEx(m_pd3dDevice, ssol, &stiteangle, &stitepos, &stitescale, &stitecolor);

	stitecolor.r = 0.6f;
	stitecolor.g = 0.3f;
	stitecolor.b = 0.45f;
	stitescale.z = 1.8f;
	stitescale.y = 1.8f;
	stitescale.x = 1.8f;


	if (srune)
		DrawEERIEObjEx(m_pd3dDevice, srune, &stiteangle, &stitepos, &stitescale, &stitecolor);


	for (int n = 0; n < 4; n++)
	{
		int j = ARX_PARTICLES_GetFree();

		if ((j != -1) && (!ARXPausedTimer))
		{
			ParticleCount++;
			particle[j].exist		=	1;
			particle[j].zdec		=	0;
 
			particle[j].ov.x		=	x + frand2() * 40; 
			particle[j].ov.y		=	y;
			particle[j].ov.z		=	z + frand2() * 40;
			particle[j].move.x		=	0.8f * frand2(); 
			particle[j].move.y		=	-4.f * rnd(); 
			particle[j].move.z		=	0.8f * frand2(); 
			particle[j].scale.x		=	-0.1f;
			particle[j].scale.y		=	-0.1f;
			particle[j].scale.z		=	-0.1f;
			particle[j].timcreation = lARXTime;
			particle[j].tolive		=	2600 + (unsigned long)(rnd() * 600.f);
			particle[j].tc			=	tex_p2;
			particle[j].siz			=	0.3f;
			particle[j].r			=	0.4f;
			particle[j].g			=	0.4f;
			particle[j].b			=	0.6f;
		}
	}

	return 1.0f - rnd() * 0.3f;
}
Ejemplo n.º 22
0
/*--------------------------------------------------------------------------*/
float CLevitate::Render()
{
	if (this->key > 1) return 0;

	GRenderer->SetRenderState(Renderer::AlphaBlending, true);
	GRenderer->SetRenderState(Renderer::DepthWrite, false);

	//calcul du cone
	TexturedVertex d3dvs, *d3dv;
	Vec3f	* vertex;
	int			nb, nbc, col;
	float		ddu = this->ang;
	float		u = ddu, du = .99999999f / (float)this->def;

	switch (this->key)
	{
		case 0:
			nbc = 2;

			while (nbc--)
			{
				vertex = this->cone[nbc].conevertex;
				d3dv = this->cone[nbc].coned3d;
				nb = (this->cone[nbc].conenbvertex) >> 1;

				while (nb)
				{
					d3dvs.p.x = this->pos.x + (vertex + 1)->x + ((vertex->x - (vertex + 1)->x) * this->scale);
					d3dvs.p.y = this->pos.y + (vertex + 1)->y + ((vertex->y - (vertex + 1)->y) * this->scale);
					d3dvs.p.z = this->pos.z + (vertex + 1)->z + ((vertex->z - (vertex + 1)->z) * this->scale);
					
					EE_RT2(&d3dvs, d3dv);


					float fRandom	= rnd() * 80.f;

					col = checked_range_cast<int>(fRandom);

					if (!arxtime.is_paused()) d3dv->color = Color::grayb(col).toBGR(col);

					d3dv->uv.x = u;
					d3dv->uv.y = 0.f;
					vertex++;
					d3dv++;

					d3dvs.p.x = this->pos.x + vertex->x;
					d3dvs.p.y = this->pos.y;
					d3dvs.p.z = this->pos.z + vertex->z;
					
					EE_RT2(&d3dvs, d3dv);


					fRandom = rnd() * 80.f;

					col = checked_range_cast<int>(fRandom);


					if (!arxtime.is_paused()) d3dv->color = Color::black.toBGR(col);

					d3dv->uv.x = u;
					d3dv->uv.y = 0.9999999f;
					vertex++;
					d3dv++;

					u += du;
					nb--;
				}

				u = ddu;
				du = -du;
			}

			nbc = 3;
			while(nbc--) {
				
				PARTICLE_DEF * pd = createParticle();
				if(!pd) {
					break;
				}
				
				float a = radians(360.f * rnd());
				pd->ov = pos + Vec3f(rbase * EEcos(a), 0.f, rbase * EEsin(a));
				float t = fdist(pd->ov, pos);
				pd->move = Vec3f((5.f + 5.f * rnd()) * ((pd->ov.x - pos.x) / t), 3.f * rnd(),
				                 (5.f + 5.f * rnd()) * ((pd->ov.z - pos.z) / t));
				pd->siz = 30.f + 30.f * rnd();
				pd->tolive = 3000;
				pd->timcreation = -(long(arxtime) + 3000l); // TODO WTF
				pd->special = FIRE_TO_SMOKE | FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION
				              | DISSIPATING;
				pd->fparam = 0.0000001f;
			}
			break;
		
		case 1:
			nbc = 2;

			while (nbc--)
			{
				vertex = this->cone[nbc].conevertex;
				d3dv = this->cone[nbc].coned3d;
				nb = (this->cone[nbc].conenbvertex) >> 1;

				while (nb)
				{
					d3dvs.p = this->pos + *vertex;
	
					EE_RT2(&d3dvs, d3dv);
					col = Random::get(0, 80);

					if (!arxtime.is_paused()) d3dv->color = Color::grayb(col).toBGR(col);

					d3dv->uv.x = u;
					d3dv->uv.y = 0.f;
					vertex++;
					d3dv++;

					d3dvs.p.x = this->pos.x + vertex->x;
					d3dvs.p.y = this->pos.y;
					d3dvs.p.z = this->pos.z + vertex->z;

					EE_RT2(&d3dvs, d3dv);
					col = Random::get(0, 80);

					if (!arxtime.is_paused()) d3dv->color = Color::black.toBGR(col);

					d3dv->uv.x = u;
					d3dv->uv.y = 1; 
					vertex++;
					d3dv++;

					u += du;
					nb--;
				}

				u = ddu;
				du = -du;
			}
			
			nbc = 10;
			while(nbc--) {
				
				PARTICLE_DEF * pd = createParticle();
				if(!pd) {
					break;
				}
				
				float a = radians(360.f * rnd());
				pd->ov = pos + Vec3f(rbase * EEcos(a), 0.f, rbase * EEsin(a));
				float t = fdist(pd->ov, pos);
				pd->move = Vec3f((5.f + 5.f * rnd()) * ((pd->ov.x - pos.x) / t), 3.f * rnd(),
				                 (5.f + 5.f * rnd()) * ((pd->ov.z - pos.z) / t));
				pd->siz = 30.f + 30.f * rnd();
				pd->tolive = 3000;
				pd->timcreation = -(long(arxtime) + 3000l); // TODO WTF
				pd->special = FIRE_TO_SMOKE | FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION
				              | DISSIPATING;
				pd->fparam = 0.0000001f;
			}
			
			break;
	}

	//tracé du cone back
	GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendOne);
	GRenderer->SetRenderState(Renderer::AlphaBlending, true);
	GRenderer->GetTextureStage(0)->SetWrapMode(TextureStage::WrapMirror);

	GRenderer->SetTexture(0, tsouffle);

	GRenderer->SetCulling(Renderer::CullCW);
	int i = cone[1].conenbfaces - 2;
	int j = 0;

	while (i--)
	{
		ARX_DrawPrimitive(&cone[1].coned3d[j],
		                             &cone[1].coned3d[j+1],
		                             &cone[1].coned3d[j+2]);
		j++;
	}

	i = cone[0].conenbfaces - 2;
	j = 0;

	while (i--)
	{
		ARX_DrawPrimitive(&cone[0].coned3d[j],
		                             &cone[0].coned3d[j+1],
		                             &cone[0].coned3d[j+2]);
		j++;
	}

	//tracé du cone front
	GRenderer->SetCulling(Renderer::CullCCW);
	
	i = cone[1].conenbfaces - 2;
	j = 0;

	while (i--)
	{
		ARX_DrawPrimitive(&cone[1].coned3d[j],
		                             &cone[1].coned3d[j+1],
		                             &cone[1].coned3d[j+2]);
		j++;
	}

	i = cone[0].conenbfaces - 2;
	j = 0;

	while (i--)
	{
		ARX_DrawPrimitive(&cone[0].coned3d[j],
		                             &cone[0].coned3d[j+1],
		                             &cone[0].coned3d[j+2]);
		j++;
	}

	//tracé des pierres
	GRenderer->SetBlendFunc(Renderer::BlendSrcAlpha, Renderer::BlendInvSrcAlpha);
	this->DrawStone();

	GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendZero);
	GRenderer->SetRenderState(Renderer::AlphaBlending, false);
	GRenderer->SetRenderState(Renderer::DepthWrite, true);

	return 0;
}
//-----------------------------------------------------------------------------
float CExplosion::Render(LPDIRECT3DDEVICE7 device)
{
	if (this->key > 1) return 0;

	SETALPHABLEND(device, TRUE);
	SETZWRITE(device, FALSE);

	device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
	device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);

	//calcul du disque
	D3DTLVERTEX d3dvs, *d3dv;
	EERIE_3D	* vertex;
	int			nb, col, col2;
	float		rin;

	switch (key)
	{
		case 0:
			rin = 255.f * scale;
			vertex = disquevertex;
			d3dv = disqued3d;
			nb = disquenbvertex >> 1;

			while (nb)
			{
				d3dvs.sx = pos.x + (vertex + 1)->x + ((vertex->x - (vertex + 1)->x) * scale);
				d3dvs.sy = pos.y;
				d3dvs.sz = pos.z + (vertex + 1)->z + ((vertex->z - (vertex + 1)->z) * scale);
				EE_RTP(&d3dvs, d3dv);
				d3dv->color = RGBA_MAKE(255, 200, 0, 255);
				vertex++;
				d3dv++;

				d3dvs.sx = pos.x + vertex->x;
				d3dvs.sy = pos.y;
				d3dvs.sz = pos.z + vertex->z;
				EE_RTP(&d3dvs, d3dv);

				if (!ARXPausedTimer) d3dv->color = RGBA_MAKE((int)(rin * rnd()), 0, 0, 255);

				vertex++;
				d3dv++;
				nb--;
			}

			if (rnd() > .25f)
			{
				int j = ARX_PARTICLES_GetFree();

				if ((j != -1) && (!ARXPausedTimer))
				{
					ParticleCount++;
					particle[j].exist = 1;
					particle[j].zdec = 0;

					float a = DEG2RAD(360.f * scale);
					float b = rin; 

					particle[j].ov.x		=	pos.x + b * EEcos(a);
					particle[j].ov.y		=	pos.y;
					particle[j].ov.z		=	pos.z + b * EEsin(a);
					particle[j].move.x		=	0.f;
					particle[j].move.y		=	rnd();
					particle[j].move.z		=	0.f;
					particle[j].siz			=	10.f + 10.f * rnd();
					particle[j].tolive		=	500 + (unsigned long)(float)(rnd() * 500.f);
					particle[j].scale.x		=	1.f;
					particle[j].scale.y		=	1.f;
					particle[j].scale.z		=	1.f;
					particle[j].timcreation	=	lARXTime;
					particle[j].tc			=	tp;
					particle[j].special		=	FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
					particle[j].fparam		=	0.0000001f;
					particle[j].r			=	1.f;
					particle[j].g			=	1.f;
					particle[j].b			=	1.f;
				}

				j = ARX_PARTICLES_GetFree();

				if ((j != -1) && (!ARXPausedTimer))
				{
					ParticleCount++;
					particle[j].exist = 1;
					particle[j].zdec = 0;

					float a = DEG2RAD(-360.f * scale);
					float b = this->rin;

					particle[j].ov.x	=	pos.x + b * EEcos(a);
					particle[j].ov.y	=	pos.y;
					particle[j].ov.z	=	pos.z + b * EEsin(a);
					particle[j].move.x	=	0.f;
					particle[j].move.y	=	rnd();
					particle[j].move.z	=	0.f;
					particle[j].siz		=	10.f + 10.f * rnd();
					particle[j].tolive	=	500 + (unsigned long)(float)(rnd() * 500.f);
					particle[j].scale.x	=	1.f;
					particle[j].scale.y	=	1.f;
					particle[j].scale.z	=	1.f;
					particle[j].timcreation	=	lARXTime;
					particle[j].tc		=	tp;
					particle[j].special	=	FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
					particle[j].fparam	=	0.0000001f;
					particle[j].r		=	1.f;
					particle[j].g		=	1.f;
					particle[j].b		=	1.f;
				}
			}

			if (rnd() > .1f)
			{
				int j = ARX_PARTICLES_GetFree();

				if ((j != -1) && (!ARXPausedTimer))
				{
					ParticleCount++;
					particle[j].exist = 1;
					particle[j].zdec = 0;

					float a = rnd() * 360.f; 
					float b = rin * rnd();

					particle[j].ov.x	=	pos.x + b * EEcos(a);
					particle[j].ov.y	=	pos.y + 70.f;
					particle[j].ov.z	=	pos.z + b * EEsin(a);
					particle[j].move.x	=	0.f;
					particle[j].move.y	=	-(5.f + 10.f * rnd());
					particle[j].move.z	=	0.f;
					particle[j].siz		=	10.f + 20.f * rnd();
					particle[j].tolive	=	1000 + (unsigned long)(float)(rnd() * 1000.f);
					particle[j].scale.x	=	1.f;
					particle[j].scale.y	=	1.f;
					particle[j].scale.z	=	1.f;
					particle[j].timcreation	=	lARXTime;
					particle[j].tc		=	tp2;
					particle[j].special	=	FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
					particle[j].fparam	=	0.0000001f;
					particle[j].r		=	1.f;
					particle[j].g		=	1.f;
					particle[j].b		=	1.f;
				}
			}

			break;
		case 1:
			D3DTLVERTEX d3dvs2;
			rin = 1.f + (puissance * scale);
			vertex = disquevertex;
			d3dv = disqued3d;
			nb = disquenbvertex >> 1;
			float a = 1.f - scale;
			col = RGBA_MAKE((int)(255.f * a), (int)(200.f * a), 0, 255);
			col2 = RGBA_MAKE((int)(255.f * a * rnd()), 0, 0, 0);

			while (nb--)
			{
				d3dvs.sx = pos.x + vertex->x * rin;
				d3dvs.sy = pos.y;
				d3dvs.sz = pos.z + vertex->z * rin;
				vertex++;
				d3dvs2.sx = pos.x + vertex->x * rin;
				d3dvs2.sy = pos.y;
				d3dvs2.sz = pos.z + vertex->z * rin;
				vertex++;

				if (tactif[nb] >= 0)
				{
					EERIE_3D pos, dir;
					pos.x = d3dvs2.sx;
					pos.y = d3dvs2.sy;
					pos.z = d3dvs2.sz;
					dir.x = d3dvs.sx;
					dir.y = d3dvs.sy;
					dir.z = d3dvs.sz;

					DynLight[tactif[nb]].pos.x = dir.x;
					DynLight[tactif[nb]].pos.y = dir.y;
					DynLight[tactif[nb]].pos.z = dir.z;
					DynLight[tactif[nb]].intensity = .7f + 2.f * rnd();

					Collision(nb, &pos, &dir);
					ExplosionAddParticule(nb, &d3dvs, tp);
				}

				EE_RTP(&d3dvs, d3dv);

				if (!ARXPausedTimer) d3dv->color = col;

				d3dv++;

				EE_RTP(&d3dvs2, d3dv);

				if (!ARXPausedTimer) d3dv->color = col2;

				d3dv++;
			}

			break;
	}

	//tracé du disque
	SETCULL(device, D3DCULL_NONE);
	device->SetTexture(0, NULL);
	device->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX, disqued3d, disquenbvertex, (unsigned short *)disqueind, disquenbvertex + 2, 0);

	device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
	device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
	SETALPHABLEND(device, FALSE);
	SETZWRITE(device, TRUE);

	return 0;
}
Ejemplo n.º 24
0
//---------------------------------------------------------------------
float CRuneOfGuarding::Render()
{
 

	float x = eSrc.x;
	float y = eSrc.y - 20;
	float z = eSrc.z;

	GRenderer->SetRenderState(Renderer::DepthWrite, false);
	GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendOne);
	GRenderer->SetRenderState(Renderer::AlphaBlending, true);
	
	Anglef stiteangle;
	Color3f stitecolor;
	
	float stiteangleb = (float) ulCurrentTime * fOneOnDuration * 120;
	stiteangle.a = 0;
	stiteangle.g = 0;
	Vec3f stitepos = Vec3f(x, y, z);

	float gtc = arxtime.get_updated();
	float v = EEsin(gtc * ( 1.0f / 1000 )) * ( 1.0f / 10 );
	stiteangle.b = MAKEANGLE(gtc * ( 1.0f / 1000 )); 
	stitecolor.r = 0.4f - v;
	stitecolor.g = 0.4f - v;
	stitecolor.b = 0.6f - v;
	Vec3f stitescale = Vec3f(1.f, -0.1f, 1.f);
	
	if(slight) {
		DrawEERIEObjEx(slight, &stiteangle, &stitepos, &stitescale, &stitecolor);
	}
	
	stiteangle.b = stiteangleb;
	stitecolor.r = 0.6f;
	stitecolor.g = 0.f;
	stitecolor.b = 0.f;
	stitescale = Vec3f::repeat(2.f);
	
	if(ssol) {
		DrawEERIEObjEx(ssol, &stiteangle, &stitepos, &stitescale, &stitecolor);
	}
	
	stitecolor.r = 0.6f;
	stitecolor.g = 0.3f;
	stitecolor.b = 0.45f;
	stitescale = Vec3f::repeat(1.8f);
	
	if(srune) {
		DrawEERIEObjEx(srune, &stiteangle, &stitepos, &stitescale, &stitecolor);
	}
	
	for(int n = 0; n < 4; n++) {
		
		PARTICLE_DEF * pd = createParticle();
		if(!pd) {
			break;
		}
		
		pd->ov = Vec3f(x + frand2() * 40.f, y, z + frand2() * 40.f);
		pd->move = Vec3f(0.8f * frand2(), -4.f * rnd(), 0.8f * frand2());
		pd->scale = Vec3f::repeat(-0.1f);
		pd->tolive = Random::get(2600, 3200);
		pd->tc = tex_p2;
		pd->siz = 0.3f;
		pd->rgb = Color3f(.4f, .4f, .6f);
	}
	
	return 1.0f - rnd() * 0.3f;
}
Ejemplo n.º 25
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);
				}
			}

	}
}
Ejemplo n.º 26
0
bool AddAnchor_Original_Method(EERIE_BACKGROUND * eb, EERIE_BKG_INFO * eg, EERIE_3D * pos, long flags)
{
	long found = 0;
	long best = 0;
	long stop_radius = 0;
	float best_dist = 99999999999.f;
	float v_dist = 99999999999.f;

	EERIE_CYLINDER testcyl;
	EERIE_CYLINDER currcyl;
	EERIE_CYLINDER bestcyl;

	bestcyl.height = 0;
	bestcyl.radius = 0;

	
	for (long rad = 0; rad < 20; rad += 10) 
		for (long ang = 0; ang < 360; ang += 45) // 45
		{
			float t = DEG2RAD((float)ang);
			// We set our current position depending on given position, radius & angle.
			currcyl.radius = 40; 
			currcyl.height = -165; 
			currcyl.origin.x = pos->x - EEsin(t) * (float)rad;
			currcyl.origin.y = pos->y;
			currcyl.origin.z = pos->z + EEcos(t) * (float)rad;

			stop_radius = 0;
			found = 0;
			long climb = 0;

			while ((stop_radius != 1))
			{
				memcpy(&testcyl, &currcyl, sizeof(EERIE_CYLINDER));
				testcyl.radius += INC_RADIUS;

				if (ANCHOR_AttemptValidCylinderPos(&testcyl, NULL, CFLAG_NO_INTERCOL | CFLAG_EXTRA_PRECISION | CFLAG_ANCHOR_GENERATION))
				{
					memcpy(&currcyl, &testcyl, sizeof(EERIE_CYLINDER));
					found = 1;
				}
				else
				{
					if ((testcyl.origin.y != currcyl.origin.y)
					        && (EEfabs(testcyl.origin.y - pos->y) < 50))
					{
						testcyl.radius -= INC_RADIUS;
						memcpy(&currcyl, &testcyl, sizeof(EERIE_CYLINDER));
						climb++;
					}
					else
						stop_radius = 1;
				}

				if (climb > 4) stop_radius = 1;

				if (currcyl.radius >= 50.f) stop_radius = 1;
			}

			if (found)
			{
				float dist = TRUEEEDistance3D(pos, &currcyl.origin);
				float vd = EEfabs(pos->y - currcyl.origin.y);

				if (currcyl.radius >= bestcyl.radius)	
				{
					if (((best_dist > dist) && (currcyl.radius == bestcyl.radius))
					        || (currcyl.radius > bestcyl.radius))
					{
						memcpy(&bestcyl, &currcyl, sizeof(EERIE_CYLINDER));
						best_dist = dist;
						v_dist = vd;
						best = 1;
					}
				}
			}
		}

	if (!best) return FALSE;

	if (CylinderAboveInvalidZone(&bestcyl)) return FALSE;

	if (flags == MUST_BE_BIG)
	{
		if (bestcyl.radius < 60) return FALSE;
	}

	// avoid to recreate same anchor twice...
	if (0)
		for (long k = 0; k < eb->nbanchors; k++)
		{
			_ANCHOR_DATA * ad = &eb->anchors[k];

			if ((ad->pos.x == bestcyl.origin.x)
			        &&	(ad->pos.y == bestcyl.origin.y)
			        &&	(ad->pos.z == bestcyl.origin.z))
			{
				if (ad->radius >= bestcyl.radius)
					return FALSE;

				if (ad->radius <= bestcyl.radius)
				{
					ad->height = bestcyl.height;
					ad->radius = bestcyl.radius;
					return FALSE;
				}
			}
		}

	eg->ianchors = (long *)realloc(eg->ianchors, sizeof(long) * (eg->nbianchors + 1));

	if (!eg->ianchors) HERMES_Memory_Emergency_Out();

	eg->ianchors[eg->nbianchors] = eb->nbanchors;
	eg->nbianchors++;

	eb->anchors = (_ANCHOR_DATA *)realloc(eb->anchors, sizeof(_ANCHOR_DATA) * (eb->nbanchors + 1));

	if (!eb->anchors) HERMES_Memory_Emergency_Out();

	_ANCHOR_DATA * ad = &eb->anchors[eb->nbanchors];
	ad->pos.x = bestcyl.origin.x; 
	ad->pos.y = bestcyl.origin.y; 
	ad->pos.z = bestcyl.origin.z; 
	ad->height = bestcyl.height; 
	ad->radius = bestcyl.radius; 
	ad->linked = NULL;
	ad->nblinked = 0;
	ad->flags = 0;
	eb->nbanchors++;
	return TRUE;
}