#include "Contents/Effects/Skills/RedLineEffect.h" #include "Contents/Effects/Core/EffectMemoryMgr.h" #include "Contents/Effects/Core/EffectPoint.h" #include "Contents/Effects/Particles/Particle.h" #include "Utility/Math/AffineMatrix.h" #include #include namespace { // INLINED __forceinline int ClampedRandom(int range) { const int value = rand() % range; return value >= 0 ? value : 0; } } // OFFSET: 0x00B71770 // FUNCTION: fn_19134 void CRedLineEffect::CreateLines(int layer) { int row = 0; for (int angle = 0; angle < 360; angle += 90) { const int life = ClampedRandom(40) + 60; const float scale = static_cast(ClampedRandom(11)) * 0.015f + 0.15f; const short direction = static_cast(ClampedRandom(360)); const float directionX = g_cosTable[direction] * 5.0f; const float directionZ = g_sinTable[direction] * 5.0f; for (int segment = 0; segment <= 21; ++segment) { CParticle* particle = CreateParticle(reinterpret_cast(this->position), 5); if (particle) { particle->SetTexture("effect\\ring_red.tga"); particle->rowIndex = row; particle->effectId = this->id; particle->columnIndex = segment; particle->groupIndex = 3; particle->angleParameter = 360; *reinterpret_cast(&particle->angleBits) = static_cast(angle); particle->alpha = 150; particle->speedParameter = 120.0f; particle->phaseParameter = 90; particle->scale = scale; particle->offsetX = directionX; particle->offsetZ = directionZ; particle->offsetY = 0.0f; particle->elapsedFrames = life; particle->animationParameter = static_cast(layer); InitParticleQuad(particle->vertices); this->lines.push_back(particle); } } ++row; } } // OFFSET: 0x00B71B80 // FUNCTION: fn_19135 void CRedLineEffect::Close() { for (std::vector::iterator it = this->lines.begin(); it != this->lines.end(); ++it) { FreeParticle(*it); } this->lines.clear(); } // OFFSET: 0x00B71BC0 // FUNCTION: fn_19136 void CRedLineEffect::Open() { this->CreateLines(0); this->CreateLines(1); this->effectLifetime = 75; } // OFFSET: 0x00B71BE0 // FUNCTION: fn_19137 bool CRedLineEffect::IsAlive() { return !this->IsFinished(); } // OFFSET: 0x00B71EA0 // FUNCTION: fn_19138 void CRedLineEffect::OnProcess() { for (std::vector::iterator it = this->lines.begin(); it != this->lines.end(); ++it) { CParticle* particle = *it; vector3d& position = particle->position; position.x = this->position[0]; position.y = this->position[1]; position.z = this->position[2]; if (particle != nullptr) { float& spinAngle = *reinterpret_cast(&particle->angleBits); float spin = spinAngle + 1.0f; const int age = particle->elapsedFrames; if (spin >= 360.0f) { spin -= 360.0f; } spinAngle = spin; float width; if (age >= 125) { particle->alpha = std::max(particle->alpha - 15, 0); particle->speedParameter = std::max(0.0f, particle->speedParameter - 5.0f); width = particle->speedParameter; } else if (age < 100) { width = 0.0f; } else if (age <= 115) { width = g_sinTable[(age - 100) * 6] * particle->speedParameter; } else { width = particle->speedParameter; } width = std::max(0.0f, width); const int segment = particle->columnIndex; const int step = static_cast(static_cast(particle->angleParameter) / 20.0f); const int angle = static_cast(static_cast(step * segment) + spin) % 360; const float flat = width * g_cosTable[particle->phaseParameter]; const float rise = width * g_sinTable[particle->phaseParameter]; EffectPoint points[2]; points[0].x = particle->scale * g_cosTable[angle]; points[0].y = 0.0f; points[0].z = particle->scale * g_sinTable[angle]; if (particle->animationParameter == 1.0f) { points[0].x *= 1.5f; points[0].z *= 1.5f; } points[1].x = flat * g_cosTable[angle] + points[0].x; points[1].y = points[0].y - rise; points[1].z = flat * g_sinTable[angle] + points[0].z; points[0].x += particle->offsetX; points[0].y += particle->offsetY; points[0].z += particle->offsetZ; points[1].x += particle->offsetX; points[1].y += particle->offsetY; points[1].z += particle->offsetZ; particle->vertices[1].x = points[1].x; particle->vertices[1].y = points[1].y; particle->vertices[1].z = points[1].z; particle->vertices[3].x = points[0].x; particle->vertices[3].y = points[0].y; particle->vertices[3].z = points[0].z; if (segment != 0) { particle->vertices[0].x = this->previousOuter.x; particle->vertices[0].y = this->previousOuter.y; particle->vertices[0].z = this->previousOuter.z; particle->vertices[2].x = this->previousInner.x; particle->vertices[2].y = this->previousInner.y; particle->vertices[2].z = this->previousInner.z; } this->previousInner.x = points[0].x; this->previousInner.y = points[0].y; this->previousInner.z = points[0].z; this->previousOuter.x = points[1].x; this->previousOuter.y = points[1].y; this->previousOuter.z = points[1].z; } ++particle->elapsedFrames; } } // OFFSET: 0x00B72240 // FUNCTION: fn_19139 void CRedLineEffect::Render() { for (std::vector::iterator it = this->lines.begin(); it != this->lines.end(); ++it) { CParticle* particle = *it; if (particle && particle->columnIndex > 0) { int blend; short shade; if (particle->animationParameter == 0.0f) { shade = 10; blend = 6; } else { shade = 100; blend = 2; } particle->destinationBlend = blend; particle->SetColor(255, shade, shade); const int segment = particle->columnIndex; const ParticleQuad quad = {false, 0.0f, 1.0f, static_cast(segment - 1) / 21.0f, static_cast(segment) / 21.0f, false, true}; particle->Render(quad); } } }