From ee27db43487a331bd062093db3a3e3ebae5cb70e Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 29 Oct 2026 23:41:39 +0000 Subject: [PATCH] Decompile 2 functions in Source/Contents/Effects/WindEffect.cpp, Source/Contents/Effects/WindEffect.h, ... Batch #3827 by sherollyner: 0 byte-identical, 2 confirmed by peer review. - fn_07537 CWindEffect::CWindEffect: logic confirmed by peer review - fn_07544 CWindEffect::Slot03: logic confirmed by peer review Peer-reviewed-by: Yommy, youko Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Contents/Effects/Particle.h | 4 +- Source/Contents/Effects/WindEffect.cpp | 94 ++++++++++++++++++++++++++ Source/Contents/Effects/WindEffect.h | 27 +++++++- 3 files changed, 123 insertions(+), 2 deletions(-) diff --git a/Source/Contents/Effects/Particle.h b/Source/Contents/Effects/Particle.h index b1d8f04b..4a80fe80 100644 --- a/Source/Contents/Effects/Particle.h +++ b/Source/Contents/Effects/Particle.h @@ -73,7 +73,9 @@ public: /* 0044 */ int alpha; /* 0048 */ unsigned char unknown_0048[4]; /* 004C */ int unknown_004C; - /* 0050 */ unsigned char unknown_0050[0x58]; + /* 0050 */ unsigned char unknown_0050[4]; + /* 0054 */ float unknown_0054; + /* 0058 */ unsigned char unknown_0058[0x50]; /* 00A8 */ unsigned char unknown_00A8; /* 00A9 */ unsigned char unknown_00A9[0x17]; /* 00C0 */ float unknown_00C0; diff --git a/Source/Contents/Effects/WindEffect.cpp b/Source/Contents/Effects/WindEffect.cpp index 33afe6a9..40bd17ae 100644 --- a/Source/Contents/Effects/WindEffect.cpp +++ b/Source/Contents/Effects/WindEffect.cpp @@ -1,6 +1,23 @@ #include "Contents/Effects/WindEffect.h" #include "Contents/Effects/Particle.h" +#include "Utility/Math/AffineMatrix.h" + +#include + +// INLINED +static vector3d TransformPoint(const matrix& transform, const vector3d& point) { + vector3d result; + result.x = point.y * transform.values[3] + point.x * transform.values[0] + point.z * transform.values[6] + transform.values[9]; + result.y = point.y * transform.values[4] + point.x * transform.values[1] + point.z * transform.values[7] + transform.values[10]; + result.z = point.y * transform.values[5] + point.x * transform.values[2] + point.z * transform.values[8] + transform.values[11]; + return result; +} + +// OFFSET: 0x00730210 +// FUNCTION: fn_07537 +CWindEffect::CWindEffect() : CEffect(2343) { +} // OFFSET: 0x00730870 // FUNCTION: fn_07543 @@ -8,6 +25,83 @@ bool CWindEffect::Slot06() { return this->ActorExists(); } +// OFFSET: 0x00730880 +// FUNCTION: fn_07544 +void CWindEffect::Slot03() { + for (std::vector::iterator it = this->particles.begin(); it != this->particles.end(); ++it) { + CParticle* particle = *it; + if (particle == nullptr) { + continue; + } + + switch (particle->unknown_00A8) { + case 0: { + int alpha = particle->alpha + 1; + if (alpha >= this->maxAlpha) { + alpha = this->maxAlpha; + particle->unknown_00A8 = 1; + } + particle->alpha = alpha; + break; + } + case 1: { + int alpha = particle->alpha - 1; + if (alpha <= 0) { + alpha = 0; + particle->unknown_00A8 = 0; + } + particle->alpha = alpha; + break; + } + } + + float& angle = *reinterpret_cast(&particle->unknown_00C4); + float nextAngle = particle->unknown_00C0 + angle; + if (nextAngle > 360.0f) { + nextAngle -= 360.0f; + } + angle = nextAngle; + + const float cosine = static_cast(std::cos(static_cast(angle / 180.0f * 3.141592f))); + const float sine = static_cast(std::sin(static_cast(angle / 180.0f * 3.141592f))); + + vector3d points[4] = {}; + const float scale = particle->scale; + points[0].x += scale * cosine; + points[0].y = scale * 0.0f - particle->unknown_0054; + points[0].z += scale * sine; + points[1].x = (cosine + 0.0f) * this->width + points[0].x; + points[1].y = this->width + points[0].y; + points[1].z = (sine + 0.0f) * this->width + points[0].z; + + matrix transform; + transform.MakeXRotation(this->rotation.x / 180.0f * 3.141592f); + transform.AppendZRotation(this->rotation.z / 180.0f * 3.141592f); + transform.AppendTranslate(this->position); + + const vector3d bottom = TransformPoint(transform, points[0]); + const vector3d top = TransformPoint(transform, points[1]); + particle->vertices[1].x = top.x; + particle->vertices[1].y = top.y; + particle->vertices[1].z = top.z; + particle->vertices[3].x = bottom.x; + particle->vertices[3].y = bottom.y; + particle->vertices[3].z = bottom.z; + + if (particle->unknown_000C != 0) { + particle->vertices[0].x = this->lastTop.x; + particle->vertices[0].y = this->lastTop.y; + particle->vertices[0].z = this->lastTop.z; + particle->vertices[2].x = this->lastBottom.x; + particle->vertices[2].y = this->lastBottom.y; + particle->vertices[2].z = this->lastBottom.z; + } + + this->lastBottom = bottom; + this->lastTop = top; + } +} + // OFFSET: 0x00731030 // FUNCTION: fn_07545 void CWindEffect::Slot04() { diff --git a/Source/Contents/Effects/WindEffect.h b/Source/Contents/Effects/WindEffect.h index d3eb710a..ba6e37f5 100644 --- a/Source/Contents/Effects/WindEffect.h +++ b/Source/Contents/Effects/WindEffect.h @@ -2,23 +2,48 @@ #define RAGNAROK_SOURCE_CONTENTS_EFFECTS_WINDEFFECT_H #include "Contents/Effects/Effect.h" +#include "Utility/Math/Vector3d.h" #include +#include #include class CParticle; class CWindEffect : public CEffect { public: + CWindEffect(); + + void Slot03() override; void Slot04() override; bool Slot06() override; - /* 00CC */ unsigned char unknown_00CC[0x60]; + /* 00CC */ unsigned char unknown_00CC = 4; + /* 00CD */ unsigned char unknown_00CD = 0; + /* 00CE */ unsigned char maxAlpha = 200; + /* 00CF */ unsigned char unknown_00CF = 255; + /* 00D0 */ unsigned char unknown_00D0 = 100; + /* 00D1 */ unsigned char unknown_00D1 = 100; + /* 00D4 */ float unknown_00D4 = 12.0f; + /* 00D8 */ float width = 0.5f; + /* 00DC */ float unknown_00DC = 50.0f; + /* 00E0 */ float unknown_00E0 = 5.0f; + /* 00E4 */ short unknown_00E4 = 200; + /* 00E8 */ vector3d rotation = {}; + /* 00F4 */ int unknown_00F4 = 5; + /* 00F8 */ int unknown_00F8 = 7; + /* 00FC */ std::string textureName = "effect\\cloud11.tga"; + /* 0114 */ vector3d lastBottom = {}; + /* 0120 */ vector3d lastTop = {}; /* 012C */ std::vector particles; }; #if defined(_WIN32) && !defined(_WIN64) static_assert(sizeof(CWindEffect) == 0x138); +static_assert(offsetof(CWindEffect, maxAlpha) == 0xCE); +static_assert(offsetof(CWindEffect, unknown_00D4) == 0xD4); +static_assert(offsetof(CWindEffect, rotation) == 0xE8); +static_assert(offsetof(CWindEffect, textureName) == 0xFC); static_assert(offsetof(CWindEffect, particles) == 0x12C); #endif