Exemple #1
0
void CEffects::PlayerSpawn(vec2 Pos)
{
	for(int i = 0; i < 32; i++)
	{
		CParticle p;
		p.SetDefault();
		p.m_Spr = SPRITE_PART_SHELL;
		p.m_Pos = Pos;
		p.m_Vel = RandomDir() * (powf(frandom(), 3)*600.0f);
		p.m_LifeSpan = 0.3f + frandom()*0.3f;
		p.m_StartSize = 64.0f + frandom()*32;
		p.m_EndSize = 0;
		p.m_Rot = frandom()*pi*2;
		p.m_Rotspeed = frandom();
		p.m_Gravity = frandom()*-400.0f;
		p.m_Friction = 0.7f;
		p.m_Color = vec4(0xb5/255.0f, 0x50/255.0f, 0xcb/255.0f, 1.0f);
		if (g_Config.m_GfxEyeCandy)
		{
			p.m_Gravity = frandom() * -800.0f;
		}
		m_pClient->m_pParticles->Add(CParticles::GROUP_GENERAL, &p);
		
	}
	m_pClient->m_pSounds->Play(CSounds::CHN_WORLD, SOUND_PLAYER_SPAWN, 1.0f, Pos);
}
Exemple #2
0
void CEffects::PlayerDeath(vec2 Pos, int ClientID)
{
	vec3 BloodColor(1.0f,1.0f,1.0f);

	if(ClientID >= 0)
	{
		if(m_pClient->m_aClients[ClientID].m_UseCustomColor)
			BloodColor = m_pClient->m_pSkins->GetColorV3(m_pClient->m_aClients[ClientID].m_ColorBody);
		else
		{
			const CSkins::CSkin *s = m_pClient->m_pSkins->Get(m_pClient->m_aClients[ClientID].m_SkinID);
			if(s)
				BloodColor = s->m_BloodColor;
		}
	}

	for(int i = 0; i < 64; i++)
	{
		CParticle p;
		p.SetDefault();
		p.m_Spr = SPRITE_PART_SPLAT01 + (rand()%3);
		p.m_Pos = Pos;
		p.m_Vel = RandomDir() * ((frandom()+0.1f)*900.0f);
		p.m_LifeSpan = 0.3f + frandom()*0.3f;
		p.m_StartSize = 24.0f + frandom()*16;
		p.m_EndSize = 0;
		p.m_Rot = frandom()*pi*2;
		p.m_Rotspeed = (frandom()-0.5f) * pi;
		p.m_Gravity = 800.0f;
		p.m_Friction = 0.8f;
		vec3 c = BloodColor * (0.75f + frandom()*0.25f);
		p.m_Color = vec4(c.r, c.g, c.b, 0.75f);
		m_pClient->m_pParticles->Add(CParticles::GROUP_GENERAL, &p);
	}
}
Exemple #3
0
void CEffects::SmokeTrail(vec2 Pos, vec2 Vel)
{
	if(!m_Add50hz)
		return;

	CParticle p;
	p.SetDefault();
	p.m_Spr = SPRITE_PART_SMOKE;
	p.m_Pos = Pos;
	p.m_Vel = Vel + RandomDir()*50.0f;
	p.m_LifeSpan = 0.5f + frandom()*0.5f;
	p.m_StartSize = 12.0f + frandom()*8;
	p.m_EndSize = 0;
	p.m_Friction = 0.7f;
	p.m_Gravity = frandom()*-500.0f;
	m_pClient->m_pParticles->Add(CParticles::GROUP_PROJECTILE_TRAIL, &p);
}
Exemple #4
0
void CEffects::Explosion(vec2 Pos)
{
	// add to flow
	for(int y = -8; y <= 8; y++)
		for(int x = -8; x <= 8; x++)
		{
			if(x == 0 && y == 0)
				continue;
			
			float a = 1 - (length(vec2(x,y)) / length(vec2(8,8)));
			m_pClient->m_pFlow->Add(Pos+vec2(x,y)*16, normalize(vec2(x,y))*5000.0f*a, 10.0f);
		}
		
	// add the explosion
	CParticle p;
	p.SetDefault();
	p.m_Spr = SPRITE_PART_EXPL01;
	p.m_Pos = Pos;
	p.m_LifeSpan = 0.4f;
	p.m_StartSize = 150.0f;
	p.m_EndSize = 0;
	p.m_Rot = frandom()*pi*2;
	if (g_Config.m_GfxEyeCandy)
	{
		p.m_LifeSpan = 0.6f;
		p.m_StartSize = 200.0f;
	}
	m_pClient->m_pParticles->Add(CParticles::GROUP_EXPLOSIONS, &p);
	
	// add the smoke
	for(int i = 0; i < 24; i++)
	{
		CParticle p;
		p.SetDefault();
		p.m_Spr = SPRITE_PART_SMOKE;
		p.m_Pos = Pos;
		p.m_Vel = RandomDir() * ((1.0f + frandom()*0.2f) * 1000.0f);
		p.m_LifeSpan = 0.5f + frandom()*0.4f;
		p.m_StartSize = 32.0f + frandom()*8;
		p.m_EndSize = 0;
		p.m_Gravity = frandom()*-800.0f;
		p.m_Friction = 0.4f;
		p.m_Color = mix(vec4(0.75f,0.75f,0.75f,1.0f), vec4(0.5f,0.5f,0.5f,1.0f), frandom());
		m_pClient->m_pParticles->Add(CParticles::GROUP_GENERAL, &p);
	}
}
Exemple #5
0
void CEffects::SkidTrail(vec2 Pos, vec2 Vel)
{
	if(!m_Add100hz)
		return;

	CParticle p;
	p.SetDefault();
	p.m_Spr = SPRITE_PART_SMOKE;
	p.m_Pos = Pos;
	p.m_Vel = Vel + RandomDir()*50.0f;
	p.m_LifeSpan = 0.5f + frandom()*0.5f;
	p.m_StartSize = 24.0f + frandom()*12;
	p.m_EndSize = 0;
	p.m_Friction = 0.7f;
	p.m_Gravity = frandom()*-500.0f;
	p.m_Color = vec4(0.75f,0.75f,0.75f,1.0f);
	m_pClient->m_pParticles->Add(CParticles::GROUP_GENERAL, &p);
}
Exemple #6
0
void CEffects::SmokeTrail(vec2 Pos, vec2 Vel)
{
	if(!m_Add50hz)
		return;
		
	CParticle p;
	p.SetDefault();
	p.m_Spr = SPRITE_PART_SMOKE;
	p.m_Pos = Pos;
	p.m_Vel = Vel + RandomDir()*50.0f;
	p.m_LifeSpan = 0.5f + frandom()*0.5f;
	p.m_StartSize = 12.0f + frandom()*8;
	p.m_EndSize = 0;
	p.m_Friction = 0.7;
	p.m_Gravity = frandom()*-500.0f;
	if (g_Config.m_GfxEyeCandy)
	{
		switch (rand()%5)
		{
		case 0:
			p.m_Spr = SPRITE_PART_SMOKE;
			break;
		case 1:
			p.m_Spr = SPRITE_PART_SLICE;
			break;
		case 2:
			p.m_Spr = SPRITE_PART_AIRJUMP;
			break;
		case 3:
			p.m_Spr = SPRITE_PART_BALL;
			break;
		case 4:
			p.m_Spr = SPRITE_PART_SHELL;
			break;
		}
		
		p.m_LifeSpan = 0.8f + frandom() * 0.8f;
		p.m_StartSize = 12.0f + frandom() * 6.0f;
		p.m_Friction = 0.80005f;
		p.m_Gravity = frandom() * -1000.0f;
		p.m_Color = vec4(frandom() * 0.5f + 0.5f, frandom() * 0.5f + 0.5f, frandom() * 0.5f + 0.5f, frandom() * 0.5f + 0.5f);
	}
	m_pClient->m_pParticles->Add(CParticles::GROUP_PROJECTILE_TRAIL, &p);
}
Exemple #7
0
void CEffects::PlayerDeath(vec2 Pos, int ClientID)
{
	vec3 BloodColor(1.0f,1.0f,1.0f);

	if(ClientID >= 0)
	{
		if(m_pClient->m_GameInfo.m_GameFlags&GAMEFLAG_TEAMS)
		{
			int ColorVal = m_pClient->m_pSkins->GetTeamColor(m_pClient->m_aClients[ClientID].m_aUseCustomColors[CSkins::SKINPART_BODY], m_pClient->m_aClients[ClientID].m_aSkinPartColors[CSkins::SKINPART_BODY],
																m_pClient->m_aClients[ClientID].m_Team, CSkins::SKINPART_BODY);
			BloodColor = m_pClient->m_pSkins->GetColorV3(ColorVal);
		}
		else
		{
			if(m_pClient->m_aClients[ClientID].m_aUseCustomColors[CSkins::SKINPART_BODY])
				BloodColor = m_pClient->m_pSkins->GetColorV3(m_pClient->m_aClients[ClientID].m_aSkinPartColors[CSkins::SKINPART_BODY]);
			else
			{
				const CSkins::CSkinPart *s = m_pClient->m_pSkins->GetSkinPart(CSkins::SKINPART_BODY, m_pClient->m_aClients[ClientID].m_SkinPartIDs[CSkins::SKINPART_BODY]);
				if(s)
					BloodColor = s->m_BloodColor;
			}
		}
	}

	for(int i = 0; i < 64; i++)
	{
		CParticle p;
		p.SetDefault();
		p.m_Spr = SPRITE_PART_SPLAT01 + (random_int()%3);
		p.m_Pos = Pos;
		p.m_Vel = RandomDir() * ((frandom()+0.1f)*900.0f);
		p.m_LifeSpan = 0.3f + frandom()*0.3f;
		p.m_StartSize = 24.0f + frandom()*16;
		p.m_EndSize = 0;
		p.m_Rot = frandom()*pi*2;
		p.m_Rotspeed = (frandom()-0.5f) * pi;
		p.m_Gravity = 800.0f;
		p.m_Friction = 0.8f;
		vec3 c = BloodColor * (0.75f + frandom()*0.25f);
		p.m_Color = vec4(c.r, c.g, c.b, 0.75f);
		m_pClient->m_pParticles->Add(CParticles::GROUP_GENERAL, &p);
	}
}
Exemple #8
0
void CEffects::Smoke(vec2 Pos, vec2 Dir)
{
	if(!m_Add50hz)
		return;

	CParticle p;
	p.SetDefault();
	p.m_Spr = SPRITE_PART_SMOKE;
	p.m_Pos = Pos;
	Dir.x += frandom() * 10.0f;
	p.m_Vel = (Dir + RandomDir()) * ((1.0f + frandom() * 0.2f) * 50.0f);
	p.m_LifeSpan = 2.0f + frandom() * 2.0f;
	p.m_StartSize = 32.0f + frandom() * 8;
	p.m_EndSize = p.m_StartSize - 10.0f;
	p.m_Friction = 0.4f;
	p.m_Gravity = frandom() * -800.0f;
	p.m_Color = mix(vec4(0.75f,0.75f,0.75f,1.0f), vec4(0.5f,0.5f,0.5f,1.0f), frandom());
	m_pClient->m_pParticles->Add(CParticles::GROUP_PROJECTILE_TRAIL, &p);
}
Exemple #9
0
void CEffects::Fallout2(vec2 Pos)
{
	vec3 FalloutColor(0.0f, 0.4f, 0.0f);

	CParticle p;
	p.SetDefault();
	p.m_Spr = SPRITE_PART_BALL;
	p.m_Pos = Pos;
	p.m_Vel = RandomDir() * ((frandom()+0.1f)*200.0f);
	p.m_LifeSpan = 5.0f + frandom()*5.0f;
	p.m_StartSize = 16.0f + frandom()*8;
	p.m_EndSize = p.m_StartSize;
	p.m_Rot = frandom()*pi*2;
	p.m_Rotspeed = (frandom()-0.5f) * pi;
	p.m_Gravity = 800.0f;
	p.m_Friction = 0.9f;
	vec3 c = FalloutColor * (0.75f + frandom()*0.25f);
	p.m_Color = vec4(c.r, c.g, c.b, 0.75f);
	m_pClient->m_pParticles->Add(CParticles::GROUP_GENERAL, &p);
}
Exemple #10
0
void CBlood::Update(float TimePassed)
{
	static float FrictionFraction = 0;
	FrictionFraction += TimePassed;

	if(FrictionFraction > 2.0f) // safty messure
		FrictionFraction = 0;

	int FrictionCount = 0;
	while(FrictionFraction > 0.05f)
	{
		FrictionCount++;
		//FrictionFraction -= 0.05f;
		FrictionFraction -= 0.075f;
	}

	for(int g = 0; g < NUM_GROUPS; g++)
	{
		int i = m_aFirstPart[g];
		while(i != -1)
		{
			int Next = m_aBlood[i].m_NextPart;
			//m_aBlood[i].vel += flow_get(m_aBlood[i].pos)*time_passed * m_aBlood[i].flow_affected;
			m_aBlood[i].m_Vel.y += m_aBlood[i].m_Gravity*TimePassed;

			
			// ugly way to force tiles to blood
			int OnForceTile = Collision()->IsForceTile(m_aBlood[i].m_Pos.x, m_aBlood[i].m_Pos.y+4);
			

			for(int f = 0; f < FrictionCount; f++) // apply friction
				m_aBlood[i].m_Vel *= m_aBlood[i].m_Friction;
			
			if (OnForceTile != 0)
				//m_aBlood[i].m_Vel.x = (m_aBlood[i].m_Vel.x + OnForceTile*400) / 2.0f;
				m_aBlood[i].m_Vel.x = OnForceTile*250;
				
			// move the point
			vec2 Vel = m_aBlood[i].m_Vel*TimePassed;
			
			vec2 OldVel = Vel;
			//Vel.x += OnForceTile*1;
			
			if (OnForceTile != 0)
				Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.99f, NULL);
			else
				Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.2f+0.5f*frandom(), NULL);
			//Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.8f, NULL);
			
			/*
			if (m_aBlood[i].m_Spr >= SPRITE_BONE01)
				Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.5f+0.5f*frandom(), NULL);
			else
			if (m_aBlood[i].m_Spr > SPRITE_BLOOD01)
				Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.6f+0.6f*frandom(), NULL);
			else
				Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.1f+0.8f*frandom(), NULL);
			*/
			
			// break big blood splats into smaller ones
			if (m_aBlood[i].m_Spr != SPRITE_BLOOD01 && m_aBlood[i].m_Spr < SPRITE_BONE01)
			{
				if ((Vel.y < 0 && OldVel.y > 0) || (Vel.y > 0 && OldVel.y < 0) ||
					(Vel.x < 0 && OldVel.x > 0) || (Vel.x > 0 && OldVel.x < 0))
				{
					m_aBlood[i].m_Spr = SPRITE_BLOOD01;
					m_aBlood[i].m_StartSize /= 1.75f;
					m_aBlood[i].m_EndSize /= 1.75f;
					
					Bounce(m_aBlood[i].m_Pos, RandomDir(), g);
				}
			}

			// stick to walls and ceiling
			vec2 P = m_aBlood[i].m_Pos;
			
			// not too close the floor
			if (!Collision()->IsTileSolid(P.x, P.y+16))
			{
				if (Collision()->IsTileSolid(P.x-16, P.y))
				{
					float Dist = abs(P.x-int((P.x-16)/32)*32.0f);
					
					Vel.x -= Dist*0.1f;
				}
				else
				if (Collision()->IsTileSolid(P.x+16, P.y))
				{
					float Dist = abs(P.x-int((P.x+16)/32)*32.0f);
					
					Vel.x += Dist*0.1f;
				}
				else
				if (Collision()->IsTileSolid(P.x, P.y-16))
				{
					float Dist = abs(P.y-int((P.y-16)/32)*32.0f);
					
					Vel.y -= Dist*0.005f;
					Vel.x *= 0.99f;
				}
			}

			
			m_aBlood[i].m_Vel = Vel* (1.0f/TimePassed);

			m_aBlood[i].m_Life += TimePassed;
			
			
			if (abs(m_aBlood[i].m_Vel.x) + abs(m_aBlood[i].m_Vel.y) > 60.0f)
			{
				if (m_aBlood[i].m_Rotspeed == 0.0f)
					m_aBlood[i].m_Rot = GetAngle(m_aBlood[i].m_Vel);
				else
				{
					m_aBlood[i].m_Rot += TimePassed * m_aBlood[i].m_Rotspeed;
				}
			}
			else
			{
				//if (OldVel.y < 0 && Vel.y > 0)
				//	m_aBlood[i].m_Rot = 0;				
			}
				
			// check blood death
			if(m_aBlood[i].m_Life > m_aBlood[i].m_LifeSpan)
			{
				// remove it from the group list
				if(m_aBlood[i].m_PrevPart != -1)
					m_aBlood[m_aBlood[i].m_PrevPart].m_NextPart = m_aBlood[i].m_NextPart;
				else
					m_aFirstPart[g] = m_aBlood[i].m_NextPart;

				if(m_aBlood[i].m_NextPart != -1)
					m_aBlood[m_aBlood[i].m_NextPart].m_PrevPart = m_aBlood[i].m_PrevPart;

				// insert to the free list
				if(m_FirstFree != -1)
					m_aBlood[m_FirstFree].m_PrevPart = i;
				m_aBlood[i].m_PrevPart = -1;
				m_aBlood[i].m_NextPart = m_FirstFree;
				m_FirstFree = i;
			}

			i = Next;
		}
	}
}
Exemple #11
0
void CBlood::Update(float TimePassed)
{
	static float FrictionFraction = 0;
	FrictionFraction += TimePassed;

	if(FrictionFraction > 2.0f) // safty messure
		FrictionFraction = 0;

	int FrictionCount = 0;
	while(FrictionFraction > 0.05f)
	{
		FrictionCount++;
		//FrictionFraction -= 0.05f;
		FrictionFraction -= 0.075f;
	}

	for(int g = 0; g < NUM_GROUPS; g++)
	{
		int i = m_aFirstPart[g];
		while(i != -1)
		{
			int Next = m_aBlood[i].m_NextPart;
			//m_aBlood[i].vel += flow_get(m_aBlood[i].pos)*time_passed * m_aBlood[i].flow_affected;
			m_aBlood[i].m_Vel.y += m_aBlood[i].m_Gravity*TimePassed;

			for(int f = 0; f < FrictionCount; f++) // apply friction
				m_aBlood[i].m_Vel *= m_aBlood[i].m_Friction;

			// move the point
			vec2 Vel = m_aBlood[i].m_Vel*TimePassed;
			
			vec2 OldVel = Vel;
			
			if (m_aBlood[i].m_Spr >= SPRITE_BONE01)
				Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.5f+0.5f*frandom(), NULL);
			else
			if (m_aBlood[i].m_Spr > SPRITE_BLOOD01)
				Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.6f+0.6f*frandom(), NULL);
			else
				Collision()->MovePoint(&m_aBlood[i].m_Pos, &Vel, 0.1f+0.8f*frandom(), NULL);
			
			// break big blood splats into smaller ones
			if (m_aBlood[i].m_Spr != SPRITE_BLOOD01 && m_aBlood[i].m_Spr < SPRITE_BONE01)
			{
				if ((Vel.y < 0 && OldVel.y > 0) || (Vel.y > 0 && OldVel.y < 0) ||
					(Vel.x < 0 && OldVel.x > 0) || (Vel.x > 0 && OldVel.x < 0))
				{
					m_aBlood[i].m_Spr = SPRITE_BLOOD01;
					m_aBlood[i].m_StartSize /= 1.75f;
					m_aBlood[i].m_EndSize /= 1.75f;
					
					Bounce(m_aBlood[i].m_Pos, RandomDir());
				}
			}
			
			m_aBlood[i].m_Vel = Vel* (1.0f/TimePassed);

			m_aBlood[i].m_Life += TimePassed;
			
			
			if (abs(m_aBlood[i].m_Vel.x) + abs(m_aBlood[i].m_Vel.y) > 60.0f)
			{
				if (m_aBlood[i].m_Rotspeed == 0.0f)
					m_aBlood[i].m_Rot = GetAngle(m_aBlood[i].m_Vel);
				else
				{
					m_aBlood[i].m_Rot += TimePassed * m_aBlood[i].m_Rotspeed;
				}
			}
				
			// check blood death
			if(m_aBlood[i].m_Life > m_aBlood[i].m_LifeSpan)
			{
				// remove it from the group list
				if(m_aBlood[i].m_PrevPart != -1)
					m_aBlood[m_aBlood[i].m_PrevPart].m_NextPart = m_aBlood[i].m_NextPart;
				else
					m_aFirstPart[g] = m_aBlood[i].m_NextPart;

				if(m_aBlood[i].m_NextPart != -1)
					m_aBlood[m_aBlood[i].m_NextPart].m_PrevPart = m_aBlood[i].m_PrevPart;

				// insert to the free list
				if(m_FirstFree != -1)
					m_aBlood[m_FirstFree].m_PrevPart = i;
				m_aBlood[i].m_PrevPart = -1;
				m_aBlood[i].m_NextPart = m_FirstFree;
				m_FirstFree = i;
			}

			i = Next;
		}
	}
}