diff --git a/Source/Contents/Effects/EffectLists.cpp b/Source/Contents/Effects/EffectLists.cpp index 461fa0d5..16370229 100644 --- a/Source/Contents/Effects/EffectLists.cpp +++ b/Source/Contents/Effects/EffectLists.cpp @@ -73,6 +73,8 @@ #include "Render/Renderer.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Math/AffineMatrix.h" +#include "Contents/Effects/Particle.h" +#include "Script/LuaScript.h" #include #include @@ -1501,3 +1503,62 @@ void EffectLists::Update() { } } } + +// OFFSET: 0x00B3A9C0 +// FUNCTION: fn_18790 +bool HasEffectScript(std::string path, std::string name) { + bool exists = false; + std::string versionKey = EmitterKey(name.substr(), "effect_version"); + g_luaScript->Call("IsExistValue", "s>b", versionKey.c_str(), &exists); + if (exists) { + return true; + } + + std::string emitterKey = EmitterKey(name.substr(), "emitterInfo"); + g_luaScript->Call("IsExistValue", "s>b", emitterKey.c_str(), &exists); + return exists; +} + +// OFFSET: 0x00B3B0A0 +// FUNCTION: fn_18795 +void ReadEffectScriptV1(std::string name) { + g_luaScript->Call("ReadEmitterInfoz_ver_1_0", "s", EmitterInfoKey(name.substr()).c_str()); + g_luaScript->Call("ReadEffectInfoz", "s", EffectFunctionName(name.substr()).c_str()); +} + +// OFFSET: 0x00B3B240 +// FUNCTION: fn_18796 +void ReadEffectScriptV2(std::string name) { + g_luaScript->Call("ReadEmitterInfoz", "s", EmitterKey(name.substr(), "emitterInfo").c_str()); + g_luaScript->Call("ReadMagicFloorInfoz", "s", EmitterKey(name.substr(), "magicfloorInfo").c_str()); + g_luaScript->Call("ReadEvilsPawInfoz", "s", EmitterKey(name.substr(), "evilsPawInfo").c_str()); + g_luaScript->Call("ReadAnimatedEmitterInfoz", "s", EmitterKey(name.substr(), "animatedEmitterInfo").c_str()); + g_luaScript->Call("ReadEZ2STRInfoz", "s", EmitterKey(name.substr(), "ez2strInfo").c_str()); + g_luaScript->Call("ReadWindEffectInfoz", "s", EmitterKey(name.substr(), "windEffectInfo").c_str()); +} + +// OFFSET: 0x00B3AC30 +// FUNCTION: fn_18792 +void EffectLists::LoadMapEffectScript(bool reload) { + if (this->indexed.empty()) { + return; + } + + std::string directory = "Lua Files\\EffectTool\\"; + std::string name = CurrentMapScriptName(); + std::string path = directory + name; + if (HasEffectScript(path.c_str(), name.substr()) || g_luaScript->Load(path.c_str(), true, false)) { + int version = 0; + std::string versionKey = EmitterKey(name.substr(), "effect_version"); + g_luaScript->Call("GetValue", "s>d", versionKey.c_str(), &version); + switch (version) { + case 0: + case 1: + ReadEffectScriptV1(name.substr()); + break; + case 2: + ReadEffectScriptV2(name.substr()); + break; + } + } +} diff --git a/Source/Contents/Effects/EffectLists.h b/Source/Contents/Effects/EffectLists.h index ab80f273..b35c13de 100644 --- a/Source/Contents/Effects/EffectLists.h +++ b/Source/Contents/Effects/EffectLists.h @@ -47,6 +47,7 @@ public: bool RegisterAllocators(); bool RegisterAllocator(int id, CAllocator* allocator); void Update(); + void LoadMapEffectScript(bool reload); }; #if defined(_WIN32) && !defined(_WIN64) @@ -63,6 +64,9 @@ float DirectionAngle(float x, float z); double ScreenAngle(vector3d from, vector3d to); std::string CurrentMapScriptName(); std::string EffectFunctionName(std::string name); +bool HasEffectScript(std::string path, std::string name); +void ReadEffectScriptV1(std::string name); +void ReadEffectScriptV2(std::string name); extern EffectLists* g_effectMgr;