rodecomp/Source/Contents/Effects/ShadowExceedNewEffect.cpp
ragnarok-clanker f8a8f00a75 Decompile fn_07436 (CShadowExceedNew::OnProcess)
Batch #15655 by Yommy: 0 byte-identical, 1 confirmed by peer review.

- fn_07436 CShadowExceedNew::OnProcess: logic confirmed by peer review

Peer-reviewed-by: ragnarok-clanker, eAthena
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
2026-11-10 09:50:32 +00:00

150 lines
4.9 KiB
C++

#include "Contents/Effects/SkillEffects.h"
#include "Client/Mode/CGameMode.h"
#include "Client/Mode/ModeMgr.h"
#include "Contents/Actors/RenderObject.h"
#include "Contents/Camera/Camera.h"
#include "Contents/Effects/EffectActor.h"
#include "Contents/Effects/EffectMemoryMgr.h"
#include "Contents/Effects/Particle.h"
#include "Contents/World/World.h"
#include "Utility/Math/Vector3d.h"
#include <cmath>
#include <string>
// OFFSET: 0x00727EF0
// FUNCTION: fn_07430
void CShadowExceedNew::Close() {
for (CEZ2STRParticle* emitter : this->frontEmitters) {
FreeParticle(emitter);
}
this->frontEmitters.clear();
for (CEZ2STRParticle* emitter : this->backEmitters) {
FreeParticle(emitter);
}
this->backEmitters.clear();
}
// OFFSET: 0x00728500
// FUNCTION: fn_07432
void CShadowExceedNew::Open() {
this->retained = 1;
this->AddEvent(0, "effect\\SHC_SHADOW_EXCEED.wav", 0, 0);
CEZ2STRParticle* emitter = static_cast<CEZ2STRParticle*>(CreateEZ2STRParticle(reinterpret_cast<const vector3d*>(this->position), 5));
if (emitter) {
emitter->Load(std::string("SHADOW_CROSS\\SHC_SHADOW_EXCEED\\shadow_exceed\\shadow_exceed_f_shadow_bottom.str"));
emitter->offsetX = 0.0f;
emitter->offsetY = -12.0f;
emitter->offsetZ = 0.0f;
emitter->m_scale = 0.14f;
this->frontEmitters.push_back(emitter);
}
emitter = static_cast<CEZ2STRParticle*>(CreateEZ2STRParticle(reinterpret_cast<const vector3d*>(this->position), 5));
if (emitter) {
emitter->Load(std::string("SHADOW_CROSS\\SHC_SHADOW_EXCEED\\shadow_exceed\\shadow_exceed_f_shadow.str"));
emitter->offsetX = 0.0f;
emitter->offsetY = -10.0f;
emitter->offsetZ = 0.0f;
emitter->m_scale = 0.14f;
this->frontEmitters.push_back(emitter);
}
emitter = static_cast<CEZ2STRParticle*>(CreateEZ2STRParticle(reinterpret_cast<const vector3d*>(this->position), 5));
if (emitter) {
emitter->Load(std::string("SHADOW_CROSS\\SHC_SHADOW_EXCEED\\shadow_exceed\\shadow_exceed_b_shadow_bottom.str"));
emitter->offsetX = 0.0f;
emitter->offsetY = -12.0f;
emitter->offsetZ = 0.0f;
emitter->m_scale = 0.14f;
emitter->depthOffset = 0.0003f;
this->backEmitters.push_back(emitter);
}
emitter = static_cast<CEZ2STRParticle*>(CreateEZ2STRParticle(reinterpret_cast<const vector3d*>(this->position), 5));
if (emitter) {
emitter->Load(std::string("SHADOW_CROSS\\SHC_SHADOW_EXCEED\\shadow_exceed\\shadow_exceed_b_shadow.str"));
emitter->offsetX = 0.0f;
emitter->offsetY = -10.0f;
emitter->offsetZ = 0.0f;
emitter->m_scale = 0.14f;
emitter->depthOffset = 0.0003f;
this->backEmitters.push_back(emitter);
}
}
// OFFSET: 0x007289D0
// FUNCTION: fn_07434
bool CShadowExceedNew::IsAlive() {
CRenderObject* actor = FindRenderObject(this->actor);
if (actor) {
if (this->frontEmitters.size() != 0 && this->backEmitters.size() != 0) {
return true;
}
if (!static_cast<EffectActor*>(actor)->HasId(1004)) {
static_cast<EffectActor*>(actor)->LaunchEffect(1004, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
}
}
return false;
}
// OFFSET: 0x00728DC0
// FUNCTION: fn_07436
void CShadowExceedNew::OnProcess() {
CRenderObject* actor = FindRenderObject(this->actor);
if (!actor) {
return;
}
const float angle = actor->render.angle / 180.0f * 3.141592f;
const float cosine = std::cos(angle);
const float sine = std::sin(angle);
const float y = actor->render.position.y + 0.0f;
const float z = cosine * 5.0f + actor->render.position.z;
const float x = -sine * 5.0f + actor->render.position.x;
const int direction = actor->render.previousAnimation % 8;
this->drawBackEmitters = static_cast<unsigned int>(direction - 2) < 4;
for (auto it = this->frontEmitters.begin(); it != this->frontEmitters.end();) {
(*it)->position.x = x + (*it)->offsetX;
(*it)->position.y = y + (*it)->offsetY;
(*it)->position.z = z + (*it)->offsetZ;
(*it)->m_flipX = direction == 0 || direction == 1;
if ((*it)->Process(0.0f, 0.0f, 0.0f)) {
++it;
} else {
FreeParticle(*it);
it = this->frontEmitters.erase(it);
}
}
for (auto it = this->backEmitters.begin(); it != this->backEmitters.end();) {
(*it)->position.x = x + (*it)->offsetX;
(*it)->position.y = y + (*it)->offsetY;
(*it)->position.z = z + (*it)->offsetZ;
(*it)->m_flipX = direction == 4 || direction == 5;
if ((*it)->Process(0.0f, 0.0f, 0.0f)) {
++it;
} else {
FreeParticle(*it);
it = this->backEmitters.erase(it);
}
}
}
// OFFSET: 0x00729280
// FUNCTION: fn_07438
void CShadowExceedNew::Render() {
if (this->drawBackEmitters) {
for (CEZ2STRParticle* emitter : this->backEmitters) {
emitter->DrawBillboards(static_cast<CGameMode*>(g_modeMgr.GetGameMode())->camera->frame.view);
}
} else {
for (CEZ2STRParticle* emitter : this->frontEmitters) {
emitter->DrawBillboards(static_cast<CGameMode*>(g_modeMgr.GetGameMode())->camera->frame.view);
}
}
}