diff --git a/dCommon/Amf3.h b/dCommon/Amf3.h index 174ad814..689e7607 100644 --- a/dCommon/Amf3.h +++ b/dCommon/Amf3.h @@ -369,8 +369,21 @@ public: template AmfType& PushDebug(const std::string_view name) { + size_t i = 0; + for (; i < m_Dense.size(); i++) { + const auto& cast = dynamic_cast(m_Dense[i].get()); + if (!cast) continue; + + const auto& nameValue = cast->Get("name"); + if (!nameValue || nameValue->GetValue() != name) continue; + + // found a duplicate, return this instead + auto valueCast = dynamic_cast(cast->Get("value")); + if (valueCast) return *valueCast; + } + auto* value = PushArray(); - value->Insert("name", name.data()); + value->Insert("name", name.data()); return value->Insert("value", std::make_unique()); } diff --git a/dScripts/02_server/Map/njhub/CMakeLists.txt b/dScripts/02_server/Map/njhub/CMakeLists.txt index 367d4647..b2d0ba7f 100644 --- a/dScripts/02_server/Map/njhub/CMakeLists.txt +++ b/dScripts/02_server/Map/njhub/CMakeLists.txt @@ -6,6 +6,7 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_NJHUB "EnemySkeletonSpawner.cpp" "FallingTile.cpp" "FlameJetServer.cpp" + "LightningOrbServer.cpp" "ImaginationShrineServer.cpp" "Lieutenant.cpp" "MonCoreNookDoors.cpp" diff --git a/dScripts/02_server/Map/njhub/LightningOrbServer.cpp b/dScripts/02_server/Map/njhub/LightningOrbServer.cpp new file mode 100644 index 00000000..e686d540 --- /dev/null +++ b/dScripts/02_server/Map/njhub/LightningOrbServer.cpp @@ -0,0 +1,12 @@ +#include "LightningOrbServer.h" + +void LightningOrbServer::OnCollisionPhantom(Entity* self, Entity* target) { + GameMessages::GetPosition playerPos; + playerPos.Send(target->GetObjectID()); + GameMessages::GetPosition selfPos; + selfPos.Send(self->GetObjectID()); + const NiPoint3 newVec((playerPos.pos.x - selfPos.pos.x) * 2.5, 15, (playerPos.pos.z - selfPos.pos.z) * 2.5); + // ahhhh aron said to put a TODO here moving platforms don't work lol. disable this so people can actually do the puzzle + // GameMessages::SendKnockback(target->GetObjectID(), self->GetObjectID(), self->GetObjectID(), 0, newVec); + // GameMessages::SendPlayFXEffect(target->GetObjectID(), -1, u"knockback", "knockback"); +} diff --git a/dScripts/02_server/Map/njhub/LightningOrbServer.h b/dScripts/02_server/Map/njhub/LightningOrbServer.h new file mode 100644 index 00000000..962d7b6a --- /dev/null +++ b/dScripts/02_server/Map/njhub/LightningOrbServer.h @@ -0,0 +1,8 @@ +#pragma once +#include "CppScripts.h" + +class LightningOrbServer : public CppScripts::Script +{ +public: + void OnCollisionPhantom(Entity* self, Entity* target) override; +}; diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index fc955819..a6c3c00d 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -274,6 +274,7 @@ #include "MonCoreNookDoors.h" #include "MonCoreSmashableDoors.h" #include "FlameJetServer.h" +#include "LightningOrbServer.h" #include "BurningTile.h" #include "NjEarthDragonPetServer.h" #include "NjEarthPetServer.h" @@ -628,6 +629,7 @@ namespace { {"scripts\\02_server\\Map\\njhub\\L_MON_CORE_SMASHABLE_DOORS.lua", []() {return new MonCoreSmashableDoors();}}, {"scripts\\02_server\\Map\\njhub\\L_MON_CORE_SMASHABLE_DOORS.lua", []() {return new MonCoreSmashableDoors();}}, {"scripts\\02_server\\Map\\njhub\\L_FLAME_JET_SERVER.lua", []() {return new FlameJetServer();}}, + {"scripts\\02_server\\Map\\njhub\\L_LIGHTNING_ORB_SERVER.lua", []() {return new LightningOrbServer();}}, {"scripts\\02_server\\Map\\njhub\\L_BURNING_TILE.lua", []() {return new BurningTile();}}, {"scripts\\02_server\\Map\\njhub\\L_SPAWN_EARTH_PET_SERVER.lua", []() {return new NjEarthDragonPetServer();}}, {"scripts\\02_server\\Map\\njhub\\L_EARTH_PET_SERVER.lua", []() {return new NjEarthPetServer();}},