diff --git a/dScripts/02_server/Map/General/CMakeLists.txt b/dScripts/02_server/Map/General/CMakeLists.txt index b17a27cbc..ed8920ee0 100644 --- a/dScripts/02_server/Map/General/CMakeLists.txt +++ b/dScripts/02_server/Map/General/CMakeLists.txt @@ -2,6 +2,7 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL "BankInteractServer.cpp" "BaseInteractDropLootServer.cpp" "Binoculars.cpp" + "DoorIndicatorServer.cpp" "EnemyClearThreat.cpp" "ExplodingAsset.cpp" "FrictionVolumeServer.cpp" diff --git a/dScripts/02_server/Map/General/DoorIndicatorServer.cpp b/dScripts/02_server/Map/General/DoorIndicatorServer.cpp new file mode 100644 index 000000000..fe3b14a63 --- /dev/null +++ b/dScripts/02_server/Map/General/DoorIndicatorServer.cpp @@ -0,0 +1,8 @@ +#include "DoorIndicatorServer.h" +#include "Entity.h" + +void DoorIndicatorServer::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { + const bool deactivated = self->HasVar(u"name_deactivated_event") && args == self->GetVarAsString(u"name_deactivated_event"); + const bool activated = self->HasVar(u"name_activated_event") && args == self->GetVarAsString(u"name_activated_event"); + if (deactivated || activated) self->SetNetworkVar(u"FlameOn", true); +} diff --git a/dScripts/02_server/Map/General/DoorIndicatorServer.h b/dScripts/02_server/Map/General/DoorIndicatorServer.h new file mode 100644 index 000000000..20bd2efc6 --- /dev/null +++ b/dScripts/02_server/Map/General/DoorIndicatorServer.h @@ -0,0 +1,9 @@ +#pragma once +#include "CppScripts.h" + +// L_DOOR_INDICATOR_SERVER.lua (Fire Temple): the event named by name_activated_event or name_deactivated_event lights +// the indicator's flame (FlameOn). The Lua sets it true for both. +class DoorIndicatorServer : 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 a743f1dce..d16409874 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -278,6 +278,7 @@ #include "SimpleMoverSwitch.h" #include "KillCounterUtil.h" #include "SpinnersVol.h" +#include "DoorIndicatorServer.h" #include "SimpleOnceOnlyMoverSpinnerEvent.h" #include "ImaginationShrineServer.h" #include "Lieutenant.h" @@ -695,6 +696,7 @@ namespace { {"scripts\\02_server\\Map\\firetemple\\L_SIMPLE_ONCE_ONLY_MOVER_SPINNER_EVENT.lua", []() {return new SimpleOnceOnlyMoverSpinnerEvent();}}, {"scripts\\02_server\\Map\\firetemple\\L_BSPINNERS_VOL.lua", []() {return new BSpinnersVol();}}, {"scripts\\02_server\\Map\\firetemple\\L_DSPINNERS_VOL.lua", []() {return new DSpinnersVol();}}, + {"scripts\\02_server\\Map\\firetemple\\L_DOOR_INDICATOR_SERVER.lua", []() {return new DoorIndicatorServer();}}, {"scripts\\02_server\\Map\\General\\L_KILL_COUNTER_UTIL.lua", []() {return new KillCounterUtil();}}, {"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();}}, diff --git a/tests/dGameTests/FireTempleScriptsTests.cpp b/tests/dGameTests/FireTempleScriptsTests.cpp index dca9c0d51..4a6a7dbbd 100644 --- a/tests/dGameTests/FireTempleScriptsTests.cpp +++ b/tests/dGameTests/FireTempleScriptsTests.cpp @@ -5,6 +5,7 @@ #include "GameMessages.h" #include "02_server/Map/General/KillCounterUtil.h" #include "02_server/Map/General/SpinnersVol.h" +#include "02_server/Map/General/DoorIndicatorServer.h" namespace { // A kill counter extension that records its limit events @@ -81,3 +82,15 @@ TEST_F(FireTempleScriptsTest, SpinnersVolStartsItsRailTimerAtMax) { blades.OnTimerDone(&entity, "SpawnIceRail"); } +// L_DOOR_INDICATOR_SERVER: either named event lights the flame; any other does nothing +TEST_F(FireTempleScriptsTest, DoorIndicatorLightsOnEitherEvent) { + info.settings.Insert(u"name_activated_event", u"DoorOpen"); + info.settings.Insert(u"name_deactivated_event", u"DoorClose"); + Entity entity(288300744895900203, info); + info.settings.values.clear(); + DoorIndicatorServer indicator; + indicator.OnFireEventServerSide(&entity, &entity, "Other", 0, 0, 0); + EXPECT_FALSE(entity.GetNetworkVar(u"FlameOn")); + indicator.OnFireEventServerSide(&entity, &entity, "DoorClose", 0, 0, 0); + EXPECT_TRUE(entity.GetNetworkVar(u"FlameOn")); +}