More random virus particles

master
krzys-h 2015-08-07 15:18:04 +02:00
parent 9bf53e48e8
commit 7da6f1b704
3 changed files with 42 additions and 93 deletions

View File

@ -194,6 +194,34 @@ void NameParticle(std::string &name, int num)
else name = "";
}
//! Returns random letter for use as virus particle
char RandomLetter()
{
static std::vector<char> chars;
if (chars.empty())
{
// Add each special character once
chars.push_back('{');
chars.push_back('}');
chars.push_back('(');
chars.push_back(')');
chars.push_back('<');
chars.push_back('>');
chars.push_back('+');
chars.push_back('-');
chars.push_back('=');
chars.push_back('!');
// Add each letter once
for(char c = 'A'; c <= 'Z'; c++) chars.push_back(c);
// Add each number 4 times
for(char c = '0'; c <= '9'; c++) for(int i = 0; i < 4; i++) chars.push_back(c);
}
return chars[rand()%chars.size()];
}
/** Returns the channel of the particle created or -1 on error. */
int CParticle::CreateParticle(Math::Vector pos, Math::Vector speed, Math::Point dim,
ParticleType type,
@ -300,16 +328,7 @@ int CParticle::CreateParticle(Math::Vector pos, Math::Vector speed, Math::Point
{
t = 4; // effect03 (ENG_RSTATE_TTEXTURE_WHITE)
}
if ( type == PARTIVIRUS1 ||
type == PARTIVIRUS2 ||
type == PARTIVIRUS3 ||
type == PARTIVIRUS4 ||
type == PARTIVIRUS5 ||
type == PARTIVIRUS6 ||
type == PARTIVIRUS7 ||
type == PARTIVIRUS8 ||
type == PARTIVIRUS9 ||
type == PARTIVIRUS10 )
if ( type == PARTIVIRUS )
{
t = 5; // text render
}
@ -364,6 +383,11 @@ int CParticle::CreateParticle(Math::Vector pos, Math::Vector speed, Math::Point
m_particle[i].testTime = 1.0f; // impact immediately
}
if ( type == PARTIVIRUS )
{
m_particle[i].text = RandomLetter();
}
if ( type >= PARTIFOG0 &&
type <= PARTIFOG7 )
{
@ -1777,16 +1801,7 @@ void CParticle::FrameParticle(float rTime)
ti.y = ts.y+0.125f;
}
if ( m_particle[i].type == PARTIVIRUS1 ||
m_particle[i].type == PARTIVIRUS2 ||
m_particle[i].type == PARTIVIRUS3 ||
m_particle[i].type == PARTIVIRUS4 ||
m_particle[i].type == PARTIVIRUS5 ||
m_particle[i].type == PARTIVIRUS6 ||
m_particle[i].type == PARTIVIRUS7 ||
m_particle[i].type == PARTIVIRUS8 ||
m_particle[i].type == PARTIVIRUS9 ||
m_particle[i].type == PARTIVIRUS10 )
if ( m_particle[i].type == PARTIVIRUS )
{
if (progress >= 1.0f)
{
@ -1800,47 +1815,6 @@ void CParticle::FrameParticle(float rTime)
m_particle[i].intensity = 1.0f-(progress-0.25f)/0.75f;
m_particle[i].angle += rTime*Math::PI*1.0f;
if (m_particle[i].type == PARTIVIRUS1) // A ?
{
m_particle[i].text = 'A';
}
if (m_particle[i].type == PARTIVIRUS2) // C ?
{
m_particle[i].text = 'C';
}
if (m_particle[i].type == PARTIVIRUS3) // E ?
{
m_particle[i].text = 'E';
}
if (m_particle[i].type == PARTIVIRUS4) // N ?
{
m_particle[i].text = 'N';
}
if (m_particle[i].type == PARTIVIRUS5) // R ?
{
m_particle[i].text = 'R';
}
if (m_particle[i].type == PARTIVIRUS6) // T ?
{
m_particle[i].text = 'T';
}
if (m_particle[i].type == PARTIVIRUS7) // 0 ?
{
m_particle[i].text = '0';
}
if (m_particle[i].type == PARTIVIRUS8) // 2 ?
{
m_particle[i].text = '2';
}
if (m_particle[i].type == PARTIVIRUS9) // 5 ?
{
m_particle[i].text = '5';
}
if (m_particle[i].type == PARTIVIRUS10) // 9 ?
{
m_particle[i].text = '9';
}
}
if (m_particle[i].type == PARTIBLUE)
@ -3363,7 +3337,7 @@ void CParticle::DrawParticleCylinder(int i)
void CParticle::DrawParticleText(int i)
{
CharTexture tex = m_engine->GetText()->GetCharTexture(static_cast<UTF8Char>(m_particle[i].text), FONT_COLOBOT, FONT_SIZE_BIG*2.0f);
CharTexture tex = m_engine->GetText()->GetCharTexture(static_cast<UTF8Char>(m_particle[i].text), FONT_COURIER, FONT_SIZE_BIG*2.0f);
if (tex.id == 0) return;
m_device->SetTexture(0, tex.id);
m_engine->SetState(ENG_RSTATE_TTEXTURE_ALPHA, IntensityToColor(m_particle[i].intensity));
@ -3617,8 +3591,7 @@ void CParticle::DrawParticle(int sheet)
{
DrawParticleCylinder(i);
}
else if ( m_particle[i].type >= PARTIVIRUS1 &&
m_particle[i].type <= PARTIVIRUS10 )
else if ( m_particle[i].type == PARTIVIRUS )
{
DrawParticleText(i);
}

View File

@ -86,16 +86,7 @@ enum ParticleType
PARTIBLOOD = 30, //! < human blood
PARTIBLOODM = 31, //! < blood laying
PARTIVAPOR = 32, //! < steam
PARTIVIRUS1 = 33, //! < virus 1
PARTIVIRUS2 = 34, //! < virus 2
PARTIVIRUS3 = 35, //! < virus 3
PARTIVIRUS4 = 36, //! < virus 4
PARTIVIRUS5 = 37, //! < virus 5
PARTIVIRUS6 = 38, //! < virus 6
PARTIVIRUS7 = 39, //! < virus 7
PARTIVIRUS8 = 40, //! < virus 8
PARTIVIRUS9 = 41, //! < virus 9
PARTIVIRUS10 = 42, //! < virus 10
PARTIVIRUS = 33, //! < virus (random letter)
PARTIRAY1 = 43, //! < ray 1 (turn)
PARTIRAY2 = 44, //! < ray 2 (electric arc)
PARTIRAY3 = 45, //! < ray 3 (ExchangePost)

View File

@ -1918,11 +1918,6 @@ void COldObject::UpdateMapping()
void COldObject::VirusFrame(float rTime)
{
Gfx::ParticleType type;
Math::Vector pos, speed;
Math::Point dim;
int r;
if ( !m_bVirusMode ) return; // healthy object?
m_virusTime += rTime;
@ -1935,28 +1930,18 @@ void COldObject::VirusFrame(float rTime)
{
m_lastVirusParticle = m_aTime;
r = rand()%10;
if ( r == 0 ) type = Gfx::PARTIVIRUS1;
if ( r == 1 ) type = Gfx::PARTIVIRUS2;
if ( r == 2 ) type = Gfx::PARTIVIRUS3;
if ( r == 3 ) type = Gfx::PARTIVIRUS4;
if ( r == 4 ) type = Gfx::PARTIVIRUS5;
if ( r == 5 ) type = Gfx::PARTIVIRUS6;
if ( r == 6 ) type = Gfx::PARTIVIRUS7;
if ( r == 7 ) type = Gfx::PARTIVIRUS8;
if ( r == 8 ) type = Gfx::PARTIVIRUS9;
if ( r == 9 ) type = Gfx::PARTIVIRUS10;
pos = GetPosition();
Math::Vector pos = GetPosition();
pos.x += (Math::Rand()-0.5f)*10.0f;
pos.z += (Math::Rand()-0.5f)*10.0f;
Math::Vector speed;
speed.x = (Math::Rand()-0.5f)*2.0f;
speed.z = (Math::Rand()-0.5f)*2.0f;
speed.y = Math::Rand()*4.0f+4.0f;
Math::Point dim;
dim.x = Math::Rand()*0.3f+0.3f;
dim.y = dim.x;
m_particle->CreateParticle(pos, speed, dim, type, 3.0f);
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIVIRUS, 3.0f);
}
}