rodecomp/Source/Contents/Effects/MapChainEffect.cpp
ragnarok-clanker 3f8411389e Maintenance: Rename placeholder sub_XXXXXX functions to evidence-based names (Lua registration strings, log/error strings, packet ids
Batch #13406 by ragnarok-clanker: no function's compiled code changes; checked with 124 compiled unit(s), including every includer of Source/Contents/Effects/RagEffect.h, Source/Contents/Effects/PowderingEffect.h, Source/Contents/Effects/SpriteParticle.h, Source/UI/Enchant/EnchantUI.h, Source/UI/Guild/UIAgitWnd.h, Source/UI/Window/UINewSelectCharWnd.h, Source/Contents/Actors/Skill.h, Source/UI/UIChangeMaterialWnd.h, Source/UI/Window/UINewMakeCharWnd.h, Source/Contents/Effects/HealEffect.h, Source/Contents/AchievementMgr.h, Source/UI/Window/UISecondCostumeWnd.h, Source/Contents/Effects/LightSphereEffect.h, Source/Contents/Effects/BlastForge.h, Source/Security/NProtectGameGuardMgr.h, Source/Contents/Effects/MapChainEffect.h, Source/Utility/Math/Int64Math.h.
2026-11-06 16:08:47 +00:00

229 lines
7.9 KiB
C++

#include "Contents/Effects/MapChainEffect.h"
#include "Client/Mode/CGameMode.h"
#include "Client/Mode/ModeMgr.h"
#include "Contents/Camera/Camera.h"
#include "Contents/Effects/EffectMemoryMgr.h"
#include "Contents/Effects/Particle.h"
#include "Utility/Math/AffineMatrix.h"
#include <cstring>
// OFFSET: 0x00B4A9E0
// FUNCTION: fn_18945
CMapChainEffect::CMapChainEffect()
: CEffect(1024), particles(), unknown_00F0(2), unknown_00F4(2), unknown_00F8(2), unknown_00FC(2), unknown_0100(2) {
}
// OFFSET: 0x00B4AB90
// FUNCTION: fn_18947
void CMapChainEffect::CreateChainParticles(int param) {
int local8 = 0;
for (int localC = 0; localC < 360; localC += 60, ++local8) {
for (int i = 0; i < 21; ++i) {
CParticle* particle = CreateParticle(reinterpret_cast<const vector3d*>(&this->position), 5);
if (particle != nullptr) {
particle->unknown_0010 = local8;
particle->unknown_0004 = this->id;
particle->unknown_000C = i;
particle->unknown_0008 = 1;
particle->unknown_00C0 = 10.0f;
particle->scale = 14.0f;
*reinterpret_cast<float*>(&particle->unknown_00C4) = static_cast<float>(localC);
particle->unknown_004C = param;
particle->alpha = 255;
particle->unknown_0050 = 60;
particle->unknown_0054 = -14.0f;
*reinterpret_cast<float*>(particle->unknown_0058) = 1.0f;
particle->destinationBlend = 6;
InitParticleQuad(particle->vertices);
particle->SetTexture("effect\\hero_005.tga");
this->particles.push_back(particle);
}
}
}
int localC2 = 6;
for (int local82 = 0; local82 < 360; local82 += 60, ++localC2) {
for (int i = 0; i < 21; ++i) {
CParticle* particle = CreateParticle(reinterpret_cast<const vector3d*>(&this->position), 5);
if (particle != nullptr) {
particle->unknown_0010 = localC2;
particle->unknown_0004 = this->id;
particle->unknown_000C = i;
particle->unknown_0008 = 1;
particle->unknown_00C0 = 10.0f;
particle->scale = 14.0f;
*reinterpret_cast<float*>(&particle->unknown_00C4) = static_cast<float>(local82);
particle->unknown_004C = param;
particle->alpha = 255;
particle->unknown_0050 = 60;
particle->unknown_0054 = -14.0f;
*reinterpret_cast<float*>(particle->unknown_0058) = 1.0f;
particle->sourceBlend = 5;
particle->destinationBlend = 7;
InitParticleQuad(particle->vertices);
particle->SetTexture("effect\\hero_005.tga");
this->particles.push_back(particle);
}
}
}
}
// OFFSET: 0x00B4AFA0
// FUNCTION: fn_18948
void CMapChainEffect::Close() {
for (std::vector<CParticle*>::iterator it = this->particles.begin(); it != this->particles.end(); ++it) {
FreeParticle(*it);
}
this->particles.clear();
}
// OFFSET: 0x00B4AFE0
// FUNCTION: fn_18949
void CMapChainEffect::Slot01() {
this->CreateChainParticles(25);
this->CreateChainParticles(50);
this->CreateChainParticles(95);
this->CreateChainParticles(120);
this->CreateChainParticles(165);
}
// OFFSET: 0x00B4B0A0
// FUNCTION: fn_18950
void CMapChainEffect::Slot07() {
const char* base = reinterpret_cast<const char*>(this);
for (std::vector<CParticle*>::iterator it = this->particles.begin(); it != this->particles.end(); ++it) {
CParticle* particle = *it;
particle->flags = 5;
particle->position.x = this->position[0];
particle->position.y = this->position[1];
particle->position.z = this->position[2];
particle->unknown_00C0 = *reinterpret_cast<const float*>(base + 0x44);
particle->scale = *reinterpret_cast<const float*>(base + 0x48);
particle->alpha = *reinterpret_cast<const int*>(base + 0x54);
particle->unknown_0054 = *reinterpret_cast<const float*>(base + 0x5C);
*reinterpret_cast<float*>(particle->unknown_0058) = *reinterpret_cast<const float*>(base + 0x60);
particle->sourceBlend = 5;
particle->destinationBlend = 7;
InitParticleQuad(particle->vertices);
particle->unknown_00E8 = 0;
}
}
// OFFSET: 0x00B4B130
// FUNCTION: fn_18951
bool CMapChainEffect::Slot06() {
return this->ActorExists();
}
// OFFSET: 0x00B4B140
// FUNCTION: fn_18952
void CMapChainEffect::Slot03() {
for (std::vector<CParticle*>::iterator it = this->particles.begin(); it != this->particles.end(); ++it) {
CParticle* particle = *it;
particle->position.x = this->position[0];
particle->position.y = this->position[1];
particle->position.z = this->position[2];
if (particle) {
float& angle = *reinterpret_cast<float*>(&particle->unknown_00C4);
const float speed = *reinterpret_cast<const float*>(particle->unknown_0058);
angle += speed;
if (angle >= 360.0f) {
angle -= 360.0f;
}
if (particle->unknown_0010 > 5) {
int delta = -3;
if (particle->unknown_00E8 % 600 <= 250) {
delta = 3;
}
particle->alpha += delta;
if (particle->alpha > 255) {
particle->alpha = 255;
} else if (particle->alpha < 0) {
particle->alpha = 0;
}
}
const CView* view = static_cast<CGameMode*>(g_modeMgr.GetGameMode())->camera;
matrix rotation;
std::memcpy(rotation.values, g_identityMatrix, sizeof(rotation.values));
rotation.MakeYRotation(view->camera.yaw / -180.0f * 3.141592f);
particle->transform = rotation;
const int segment = particle->unknown_000C;
const int index = static_cast<int>(static_cast<float>(static_cast<int>(particle->unknown_0050 / 20.0f) * segment) + angle) % 360;
vector3d points[4] = {};
const int tilt = particle->unknown_004C;
const float sinIndex = g_sinTable[index];
const float cosIndex = g_cosTable[index];
const float sinTilt = g_sinTable[tilt];
const float cosTilt = g_cosTable[tilt];
const float termX = (sinTilt * particle->scale) * cosIndex;
const float termZ = (particle->scale * cosTilt) * cosIndex;
const float widthCos = particle->unknown_00C0 * cosTilt;
const float widthSin = particle->unknown_00C0 * sinTilt;
const float v1x = (termX - widthCos) + 0.0f;
const float v3x = (termX + widthCos) + 0.0f;
const float v1y = (particle->scale * sinIndex - 0.0f) + particle->unknown_0054;
const float v3y = (particle->scale * sinIndex + 0.0f) + particle->unknown_0054;
const float v1z = (termZ + widthSin) + 0.0f;
const float v3z = (termZ - widthSin) + 0.0f;
particle->vertices[1].x = v1x;
particle->vertices[1].y = v1y;
particle->vertices[1].z = v1z;
particle->vertices[3].x = v3x;
particle->vertices[3].y = v3y;
particle->vertices[3].z = v3z;
if (segment != 0) {
particle->vertices[0].x = this->corners[1].x;
particle->vertices[0].y = this->corners[1].y;
particle->vertices[0].z = this->corners[1].z;
particle->vertices[2].x = this->corners[0].x;
particle->vertices[2].y = this->corners[0].y;
particle->vertices[2].z = this->corners[0].z;
}
this->corners[1].x = v1x;
this->corners[1].y = v1y;
this->corners[1].z = v1z;
this->corners[0].x = v3x;
this->corners[0].y = v3y;
this->corners[0].z = v3z;
}
++particle->unknown_00E8;
}
}
// OFFSET: 0x00B4B740
// FUNCTION: fn_18953
void CMapChainEffect::Slot04() {
for (std::vector<CParticle*>::iterator it = this->particles.begin(); it != this->particles.end(); ++it) {
CParticle* particle = *it;
if (particle && particle->unknown_000C > 0) {
if (particle->unknown_0010 < 6) {
particle->destinationBlend = 6;
}
ParticleQuad quad;
quad.billboard = false;
quad.top = 0.0f;
quad.bottom = 1.0f;
quad.left = static_cast<float>(particle->unknown_000C - 1) / 21.0f;
quad.right = static_cast<float>(particle->unknown_000C) / 21.0f;
quad.unused = true;
quad.depth = true;
particle->Render(quad);
}
}
}