mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-14 07:47:13 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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<MovingPlatformComponent>()) platform->GotoWaypoint(1);
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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();}},
|
||||
|
||||
@@ -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<bool>(u"startPathingOnLoad", false);
|
||||
info.settings.Insert<std::u16string>(u"name_deactivated_event", u"blades_off");
|
||||
Entity entity(288300744895900118, info);
|
||||
info.settings.values.clear();
|
||||
auto* const platform = entity.AddComponent<MovingPlatformComponent>(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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user