rodecomp/Source/Contents/Effects/RotateItemEffect.cpp
ragnarok-clanker 6a206a3853 Decompile 2 functions in Source/Contents/Effects/RotateItemEffect.cpp, Source/Contents/Effects/RotateItemEffect.h
Batch #4052 by kyoshi: 0 byte-identical, 2 confirmed by peer review.

- fn_19148 CRotateItemEffect::Close: logic confirmed by peer review
- fn_19149 CRotateItemEffect::Slot01: logic confirmed by peer review

Peer-reviewed-by: Yommy, superintelligence, tayoba
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
2026-10-30 00:53:11 +00:00

122 lines
4.2 KiB
C++

#include "Contents/Effects/RotateItemEffect.h"
#include "Client/Mode/CGameMode.h"
#include "Client/Mode/ModeMgr.h"
#include "Contents/Actors/RenderObject.h"
#include "Contents/Camera/Camera.h"
#include "Contents/Effects/EffectMemoryMgr.h"
#include "Contents/Effects/Particle.h"
#include "Contents/World/World.h"
#include "Utility/Math/AffineMatrix.h"
#include <cstring>
// OFFSET: 0x00B73840
// FUNCTION: fn_19146
CRotateItemEffect::CRotateItemEffect() : CEffect(-1), alpha(0), angle(0) {
}
// OFFSET: 0x00B739B0
// FUNCTION: fn_19148
void CRotateItemEffect::Close() {
for (CParticle* particle : this->particles) {
FreeParticle(particle);
}
this->particles.clear();
}
// OFFSET: 0x00B739F0
// FUNCTION: fn_19149
void CRotateItemEffect::Slot01() {
for (int index = 0; index < 4; ++index) {
CParticle* particle = CreateParticle(reinterpret_cast<const vector3d*>(this->position), 5);
if (!particle) {
continue;
}
particle->unknown_0004 = this->id;
particle->unknown_000C = index;
particle->unknown_0010 = 0;
particle->unknown_0008 = 1;
particle->SetTexture("유저인터페이스\\item\\쿠나이_독.bmp");
particle->scale = 2.5f;
particle->SetColor(255, 200, 255);
*reinterpret_cast<float*>(&particle->unknown_00C4) = 360.0f;
particle->unknown_00C0 = 0.4f;
particle->alpha = 255;
particle->unknown_0054 = 13.0f;
particle->destinationBlend = 6;
this->particles.push_back(particle);
}
}
// OFFSET: 0x00B73AC0
// FUNCTION: fn_19150
bool CRotateItemEffect::Slot06() {
return !this->IsFinished();
}
// OFFSET: 0x00B73AD0
// FUNCTION: fn_19151
void CRotateItemEffect::Slot03() {
for (auto it = this->particles.begin(); it != this->particles.end(); ++it) {
(*it)->position.x = this->position[0];
(*it)->position.y = this->position[1];
(*it)->position.z = this->position[2];
if (CParticle* particle = *it) {
if (this->frame >= 5) {
float& particleAngle = *reinterpret_cast<float*>(&particle->unknown_00C4);
if (particle->unknown_000C == 0) {
particleAngle = static_cast<float>(static_cast<int>(particle->unknown_00C0 * 45.0f + particleAngle) % 360);
if (this->id != 984) {
if (CRenderObject* object = FindRenderObject(this->actor)) {
object->render.angle = static_cast<float>(static_cast<int>(particle->unknown_00C0 * 45.0f + object->render.angle) % 360);
}
}
} else {
this->alpha -= particle->unknown_000C == 1 ? 150 : 25;
particle->alpha = this->alpha;
particleAngle = this->angle;
}
const int index = static_cast<int>(particleAngle);
const float radius = particle->unknown_0054;
particle->unknown_00D0 = radius * g_cosTable[index];
particle->unknown_00D4 = -8.0f;
particle->unknown_00D8 = radius * g_sinTable[index];
this->angle = static_cast<float>(static_cast<int>(particleAngle - 5.0f) % 360);
this->alpha = particle->alpha;
if (particle->alpha > 0) {
matrix rotation;
std::memcpy(rotation.values, g_identityMatrix, sizeof(rotation.values));
CGameMode* mode = static_cast<CGameMode*>(g_modeMgr.GetGameMode());
rotation.MakeXRotation(mode->camera->camera.pitch / 180.0f * 3.141592f);
rotation.AppendYRotation(static_cast<float>(static_cast<int>(particleAngle + 45.0f) % 360) / 180.0f * 3.141592f);
matrix scale;
std::memcpy(scale.values, g_identityMatrix, sizeof(scale.values));
scale.SetScale(particle->scale, particle->scale, 1.0f);
matrix translate;
std::memcpy(translate.values, g_identityMatrix, sizeof(translate.values));
translate.MakeTranslate(particle->unknown_00D0, particle->unknown_00D4, particle->unknown_00D8);
matrix first;
first.Compose(scale, rotation);
matrix result;
result.Compose(first, translate);
particle->transform = result;
}
}
}
++(*it)->unknown_00E8;
}
}
// OFFSET: 0x00B74110
// FUNCTION: fn_19152
void CRotateItemEffect::Slot04() {
for (auto it = this->particles.begin(); it != this->particles.end(); ++it) {
if (*it) {
(*it)->Render(false, 0.0f, 1.0f, 0.0f, 1.0f, false, true);
}
}
}