rodecomp/Source/Contents/Effects/RichManKim.cpp
ragnarok-clanker 84f5f1ccd9 Decompile fn_07115 (CRichManKim::Open)
Batch #16553 by eAthena: 0 byte-identical, 1 confirmed by peer review.

- fn_07115 CRichManKim::Open: logic confirmed by peer review

Peer-reviewed-by: Yommy, alisonrag, br4yan
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
2026-11-10 23:14:56 +00:00

101 lines
3 KiB
C++

#include "Contents/Effects/RichManKim.h"
#include "Contents/Effects/EffectMemoryMgr.h"
#include "Contents/Effects/Particle.h"
#include "Utility/Math/AffineMatrix.h"
#include <cstdlib>
#include <cstring>
// OFFSET: 0x0070B160
// FUNCTION: fn_07114
void CRichManKim::Close() {
for (auto it = this->particles.begin(); it != this->particles.end(); ++it) {
FreeParticle(*it);
}
this->particles.clear();
}
// OFFSET: 0x0070B1A0
// FUNCTION: fn_07115
void CRichManKim::Open() {
CParticle* particle = CreateParticle(reinterpret_cast<const vector3d*>(this->position), 5);
if (!particle) {
return;
}
particle->SetTexture("effect\\pocket.bmp");
particle->effectId = this->id;
particle->columnIndex = 0;
particle->rowIndex = 0;
particle->groupIndex = 1;
particle->alpha = 200;
particle->angleBits = 0;
particle->phaseParameter = 0;
particle->scale = 1.0f;
particle->animationParameter = -5.0f - static_cast<float>(rand() % 5);
*reinterpret_cast<float*>(particle->animationParameters) = 0.0f;
particle->SetColor(200, 200, 200);
InitParticleQuad(particle->vertices);
this->angleIndex = rand() % 359;
this->particles.push_back(particle);
}
// OFFSET: 0x0070B370
// FUNCTION: fn_07116
bool CRichManKim::IsAlive() {
return this->ActorExists();
}
// OFFSET: 0x0070B380
// FUNCTION: fn_07117
void CRichManKim::OnProcess() {
for (auto 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) {
int index = ++this->angleIndex;
if (index > 360) {
this->angleIndex = 0;
index = 0;
}
float& width = *reinterpret_cast<float*>(particle->animationParameters);
const float height = static_cast<float>(static_cast<double>(particle->animationParameter) - static_cast<double>(g_cosTable[index]) * 0.08);
const float stretch = static_cast<float>(static_cast<double>(g_cosTable[index]) * 0.003 + static_cast<double>(width));
particle->animationParameter = height;
width = stretch;
matrix rotation;
std::memcpy(rotation.values, g_identityMatrix, sizeof(rotation.values));
rotation.AppendXRotation(3.141592f);
matrix scaling;
std::memcpy(scaling.values, g_identityMatrix, sizeof(scaling.values));
scaling.SetScale(stretch + 2.0f, 5.0f, 1.0f);
matrix translation;
translation.IsIdentity();
translation.MakeTranslate(0.0f, height, 0.0f);
matrix transform;
transform.Compose(scaling, rotation);
const matrix combined = transform;
transform.Compose(combined, translation);
particle->transform = transform;
}
++particle->elapsedFrames;
}
}
// OFFSET: 0x0070B780
// FUNCTION: fn_07118
void CRichManKim::Render() {
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);
}
}
}