From 423b55e0b83a1735e22028f5cebf3e305056a6ae Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Tue, 10 Nov 2026 16:57:15 -0600 Subject: [PATCH] feat(scripts): L_SIMPLE_ONCE_ONLY_MOVER_SPINNER_EVENT The script of the platforms a spinner moves once: a simple mover (or a mover on a two point path) in the spinner's group_deactivated_event group goes to its waypoint 1 when the spinner fires the event named in the platform's name_deactivated_event. The NJ spinner script already fires those events at its groups. Co-Authored-By: Claude Fable 5.2 --- dScripts/02_server/Map/General/CMakeLists.txt | 1 + .../SimpleOnceOnlyMoverSpinnerEvent.cpp | 10 +++++++++ .../General/SimpleOnceOnlyMoverSpinnerEvent.h | 10 +++++++++ dScripts/CppScripts.cpp | 2 ++ .../MovingPlatformComponentTests.cpp | 21 +++++++++++++++++++ 5 files changed, 44 insertions(+) create mode 100644 dScripts/02_server/Map/General/SimpleOnceOnlyMoverSpinnerEvent.cpp create mode 100644 dScripts/02_server/Map/General/SimpleOnceOnlyMoverSpinnerEvent.h diff --git a/dScripts/02_server/Map/General/CMakeLists.txt b/dScripts/02_server/Map/General/CMakeLists.txt index dc32d53c5..221faebea 100644 --- a/dScripts/02_server/Map/General/CMakeLists.txt +++ b/dScripts/02_server/Map/General/CMakeLists.txt @@ -15,6 +15,7 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL "PropertyPlatform.cpp" "QbEnemyStunner.cpp" "QbSpawner.cpp" + "SimpleOnceOnlyMoverSpinnerEvent.cpp" "StoryBoxInteractServer.cpp" "TokenConsoleServer.cpp" "TouchMissionUpdateServer.cpp" diff --git a/dScripts/02_server/Map/General/SimpleOnceOnlyMoverSpinnerEvent.cpp b/dScripts/02_server/Map/General/SimpleOnceOnlyMoverSpinnerEvent.cpp new file mode 100644 index 000000000..81e0a232d --- /dev/null +++ b/dScripts/02_server/Map/General/SimpleOnceOnlyMoverSpinnerEvent.cpp @@ -0,0 +1,10 @@ +#include "SimpleOnceOnlyMoverSpinnerEvent.h" + +#include "Entity.h" +#include "MovingPlatformComponent.h" + +void SimpleOnceOnlyMoverSpinnerEvent::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { + const auto event = self->GetVarAsString(u"name_deactivated_event"); + if (event.empty() || args != event) return; + if (auto* const platform = self->GetComponent()) platform->GotoWaypoint(1); +} diff --git a/dScripts/02_server/Map/General/SimpleOnceOnlyMoverSpinnerEvent.h b/dScripts/02_server/Map/General/SimpleOnceOnlyMoverSpinnerEvent.h new file mode 100644 index 000000000..dfd39aa5f --- /dev/null +++ b/dScripts/02_server/Map/General/SimpleOnceOnlyMoverSpinnerEvent.h @@ -0,0 +1,10 @@ +#pragma once +#include "CppScripts.h" + +// L_SIMPLE_ONCE_ONLY_MOVER_SPINNER_EVENT.lua (02_server/Map/firetemple): a simple mover (or a mover on a two point +// path) that a spinner sends to its other end. It is put in the spinner's group_deactivated_event group with the +// spinner's name_deactivated_event, and goes to waypoint 1 when the spinner fires that event. +class SimpleOnceOnlyMoverSpinnerEvent : public CppScripts::Script { +public: + void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) override; +}; diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index c84075099..645792ad5 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -272,6 +272,7 @@ #include "NjNPCMissionSpinjitzuServer.h" #include "NjJayMissionItems.h" #include "FallingTile.h" +#include "SimpleOnceOnlyMoverSpinnerEvent.h" #include "ImaginationShrineServer.h" #include "Lieutenant.h" #include "RainOfArrows.h" @@ -679,6 +680,7 @@ namespace { {"scripts\\02_server\\Map\\General\\Ninjago\\L_RAIL_POST_SERVER.lua", []() {return new NjRailPostServer();}}, {"scripts\\02_server\\Map\\General\\Ninjago\\L_ICE_RAIL_ACTIVATOR_SERVER.lua", []() {return new NjIceRailActivator();}}, {"scripts\\02_server\\Map\\njhub\\L_FALLING_TILE.lua", []() {return new FallingTile();}}, + {"scripts\\02_server\\Map\\firetemple\\L_SIMPLE_ONCE_ONLY_MOVER_SPINNER_EVENT.lua", []() {return new SimpleOnceOnlyMoverSpinnerEvent();}}, {"scripts\\02_server\\Enemy\\General\\L_ENEMY_NJ_BUFF_STUN_IMMUNITY.lua", []() {return new EnemyNjBuff();}}, {"scripts\\02_server\\Map\\njhub\\L_IMAGINATION_SHRINE_SERVER.lua", []() {return new ImaginationShrineServer();}}, {"scripts\\02_server\\Map\\njhub\\L_LIEUTENANT.lua", []() {return new Lieutenant();}}, diff --git a/tests/dGameTests/dComponentsTests/MovingPlatformComponentTests.cpp b/tests/dGameTests/dComponentsTests/MovingPlatformComponentTests.cpp index 908255243..61d37ae36 100644 --- a/tests/dGameTests/dComponentsTests/MovingPlatformComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/MovingPlatformComponentTests.cpp @@ -8,9 +8,11 @@ #include "BitStream.h" #include "CDClientDatabase.h" #include "Entity.h" +#include "GameMessages.h" #include "LDFFormat.h" #include "MovementMessages.h" #include "MovingPlatformComponent.h" +#include "02_server/Map/General/SimpleOnceOnlyMoverSpinnerEvent.h" #include "SimplePhysicsComponent.h" #include "Zone.h" #include "dZoneManager.h" @@ -622,3 +624,22 @@ TEST_F(MovingPlatformComponentTest, SimpleMoverSetsOffOnLoadUnlessToldNotTo) { EXPECT_EQ(mover->mState, 12u); } } + +// L_SIMPLE_ONCE_ONLY_MOVER_SPINNER_EVENT: the platform goes to its waypoint 1 when the event named in its +// name_deactivated_event is fired at it, and at no other +TEST_F(MovingPlatformComponentTest, OnceOnlyMoverGoesOnItsSpinnersEvent) { + info.lot = 16141; + info.settings.Insert(u"startPathingOnLoad", false); + info.settings.Insert(u"name_deactivated_event", u"blades_off"); + Entity entity(288300744895900118, info); + info.settings.values.clear(); + auto* const platform = entity.AddComponent(41, ""); + auto* const mover = platform->GetSimpleMoverSubComponent(); + SimpleOnceOnlyMoverSpinnerEvent script; + + script.OnFireEventServerSide(&entity, &entity, "blades_on", 0, 0, 0); + EXPECT_EQ(mover->mState, 12u); + script.OnFireEventServerSide(&entity, &entity, "blades_off", 0, 0, 0); + EXPECT_EQ(mover->mState, 2u); + EXPECT_EQ(mover->mCurrentWaypointIndex, 0u); +}