From 0393034a02114183f7ffd87559d41eea7230e913 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Sat, 28 Nov 2026 11:56:07 -0600 Subject: [PATCH] feat(scripts): L_BOSS_GARMADON_TORNADO The Fire Temple boss's tornado: a moving platform on a random BossTornadoPath_ path, a new one at each path's end; it smashes the faction 130 quick builds it touches, casts skill 1741 on players it touches and drops bombs (LOT 16891) on a random player in the boss game space, sooner for the later elements. Its proximity is a 24 x 30 x 24 box for the Lua's cylinder (12 round, 30 high). Co-Authored-By: Claude Opus 5.5 --- .../Map/General/BossGarmadonTornado.cpp | 119 ++++++++++++++++++ .../Map/General/BossGarmadonTornado.h | 22 ++++ dScripts/02_server/Map/General/CMakeLists.txt | 1 + dScripts/CppScripts.cpp | 3 + tests/dGameTests/FireTempleScriptsTests.cpp | 20 +++ 5 files changed, 165 insertions(+) create mode 100644 dScripts/02_server/Map/General/BossGarmadonTornado.cpp create mode 100644 dScripts/02_server/Map/General/BossGarmadonTornado.h diff --git a/dScripts/02_server/Map/General/BossGarmadonTornado.cpp b/dScripts/02_server/Map/General/BossGarmadonTornado.cpp new file mode 100644 index 000000000..09e7b209d --- /dev/null +++ b/dScripts/02_server/Map/General/BossGarmadonTornado.cpp @@ -0,0 +1,119 @@ +#include "BossGarmadonTornado.h" +#include "Entity.h" +#include "EntityManager.h" +#include "EntityInfo.h" +#include "DestroyableComponent.h" +#include "MovingPlatformComponent.h" +#include "PhantomPhysicsComponent.h" +#include "QuickBuildComponent.h" +#include "RenderComponent.h" +#include "SkillComponent.h" +#include "dpEntity.h" +#include "eQuickBuildState.h" +#include "GeneralUtils.h" + +namespace { + const std::string PathString = "BossTornadoPath_"; + const std::vector ElementalOrder = { "earth", "ice", "lightning", "fire" }; + constexpr LOT BombLOT = 16891; + const std::string GameSpaceVolume = "BossGameSpace"; + constexpr uint32_t TouchSkill = 1741; +} + +int32_t BossGarmadonTornado::BombDelay(const std::string& element) { + int32_t delay = 0; + if (element == "earth") delay = 40; + else if (element == "ice") delay = 36; + else if (element == "lightning") delay = 32; + else if (element == "fire") delay = 28; + return GeneralUtils::GenerateRandomNumber(delay / 2, delay); +} + +void BossGarmadonTornado::OnStartup(Entity* self) { + // The Lua's proximity is a cylinder 12 round and 30 high + self->SetProximityRadius(new dpEntity(self->GetObjectID(), { 24.0f, 30.0f, 24.0f }), "TornadoProx"); + auto* const zoneControl = Game::entityManager->GetZoneControlEntity(); + if (zoneControl && zoneControl->GetVar(u"initialPlayerCount") > 2) self->SetVar(u"LargeTeam", true); +} + +void BossGarmadonTornado::OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) { + if (name == "FindAPath") { + PickPath(self); + self->SetVar(u"CurrentElement", ElementalOrder[0]); + StartBombTimer(self); + } else if (name == "NewElement") { + if (param1 < 1 || param1 > static_cast(ElementalOrder.size())) return; + self->SetVar(u"CurrentElement", ElementalOrder[param1 - 1]); + } else if (name == "StopPathing") { + if (auto* const platform = self->GetComponent()) platform->StopPathing(); + self->CancelTimer("BombPlayer"); + } +} + +void BossGarmadonTornado::OnPlatformAtLastWaypoint(Entity* self) { + PickPath(self); +} + +void BossGarmadonTornado::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) { + if (name != "TornadoProx" || status != "ENTER" || !entering) return; + auto* const destroyable = entering->GetComponent(); + if (!destroyable) return; + for (const auto faction : destroyable->GetFactionIDs()) { + auto* const quickBuild = entering->GetComponent(); + const auto state = quickBuild ? quickBuild->GetState() : eQuickBuildState::OPEN; + if (faction == 130 && (state == eQuickBuildState::COMPLETED || state == eQuickBuildState::INCOMPLETE)) { + entering->Smash(self->GetObjectID(), eKillType::VIOLENT); + break; + } else if (faction == 1) { + if (auto* const skill = self->GetComponent()) skill->CastSkill(TouchSkill, entering->GetObjectID()); + break; + } + } +} + +void BossGarmadonTornado::OnTimerDone(Entity* self, std::string timerName) { + if (timerName == "BombPlayer") PickAPlayer(self); +} + +void BossGarmadonTornado::PickPath(Entity* self) { + const auto totalPaths = self->GetVarAs(u"TotalPaths"); + const auto nextPath = PathString + std::to_string(GeneralUtils::GenerateRandomNumber(1, std::max(totalPaths, 1))); + if (auto* const platform = self->GetComponent()) { + platform->SetCurrentPath(nextPath, 0, false); + platform->StartPathing(); + } + self->SetVar(u"CurrentPath", nextPath); +} + +void BossGarmadonTornado::StartBombTimer(Entity* self) { + // (a timer with cancel) + self->CancelTimer("BombPlayer"); + self->AddTimer("BombPlayer", static_cast(BombDelay(self->GetVar(u"CurrentElement")))); +} + +void BossGarmadonTornado::PickAPlayer(Entity* self) { + for (auto* const trigger : Game::entityManager->GetEntitiesInGroup(GameSpaceVolume)) { + if (!trigger) continue; + StartBombTimer(self); + std::vector players; + auto* const phantom = trigger->GetComponent(); + if (phantom && phantom->GetdpEntity()) { + for (const auto id : phantom->GetdpEntity()->GetCurrentlyCollidingObjects()) { + if (auto* const object = Game::entityManager->GetEntity(id)) players.push_back(object); + } + } + if (players.empty()) return; + auto* const player = players[GeneralUtils::GenerateRandomNumber(0, players.size() - 1)]; + auto* const destroyable = player->GetComponent(); + if (destroyable && destroyable->GetIsDead()) return; + EntityInfo info{}; + info.lot = BombLOT; + info.pos = player->GetPosition(); + info.spawner = nullptr; + info.spawnerID = self->GetObjectID(); + auto* const bomb = Game::entityManager->CreateEntity(info, nullptr, self); + Game::entityManager->ConstructEntity(bomb); + RenderComponent::PlayAnimation(self, u"attack"); + break; + } +} diff --git a/dScripts/02_server/Map/General/BossGarmadonTornado.h b/dScripts/02_server/Map/General/BossGarmadonTornado.h new file mode 100644 index 000000000..6cc5ef527 --- /dev/null +++ b/dScripts/02_server/Map/General/BossGarmadonTornado.h @@ -0,0 +1,22 @@ +#pragma once +#include "CppScripts.h" + +// L_BOSS_GARMADON_TORNADO.lua (LOT 16807): the Fire Temple boss's tornado, a moving platform on the BossTornadoPath_ +// paths. The boss manager tells it to find a path (FindAPath), which element it is (NewElement) and to stop +// (StopPathing). It takes a random path at each path's end, smashes the built rails and other quick builds of faction +// 130 it touches, casts skill 1741 on the players it touches, and every so often (sooner the later the element) drops +// a bomb (LOT 16891) where a random player in the boss game space stands. +class BossGarmadonTornado : public CppScripts::Script { +public: + void OnStartup(Entity* self) override; + void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1 = 0, int32_t param2 = 0) override; + void OnPlatformAtLastWaypoint(Entity* self) override; + void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override; + void OnTimerDone(Entity* self, std::string timerName) override; + // The bomb wait for an element: a whole number of seconds from half its delay to its delay + static int32_t BombDelay(const std::string& element); +private: + static void PickPath(Entity* self); + static void StartBombTimer(Entity* self); + static void PickAPlayer(Entity* self); +}; diff --git a/dScripts/02_server/Map/General/CMakeLists.txt b/dScripts/02_server/Map/General/CMakeLists.txt index 926aa8535..cd14dbcfe 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" + "BossGarmadonTornado.cpp" "DoorIndicatorServer.cpp" "ElementalChestsServer.cpp" "EnemyClearThreat.cpp" diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index 2fd19524d..565b9a5ed 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -282,6 +282,7 @@ #include "ElementalChestsServer.h" #include "ZoneFireTempleServer.h" #include "EventCounterUtil.h" +#include "BossGarmadonTornado.h" #include "SimpleOnceOnlyMoverSpinnerEvent.h" #include "ImaginationShrineServer.h" #include "Lieutenant.h" @@ -702,6 +703,8 @@ namespace { {"scripts\\02_server\\Map\\firetemple\\L_DOOR_INDICATOR_SERVER.lua", []() {return new DoorIndicatorServer();}}, {"scripts\\02_server\\Map\\firetemple\\L_ELEMENTAL_CHESTS_SERVER.lua", []() {return new ElementalChestsServer();}}, {"scripts\\02_server\\Map\\firetemple\\L_ZONE_FIRE_TEMPLE_SERVER.lua", []() {return new ZoneFireTempleServer();}}, + // (the CDServer row writes this path with forward slashes) + {"scripts/02_server/Map/firetemple/L_BOSS_GARMADON_TORNADO.lua", []() {return new BossGarmadonTornado();}}, {"scripts\\02_server\\Map\\General\\L_KILL_COUNTER_UTIL.lua", []() {return new KillCounterUtil();}}, {"scripts\\02_server\\Map\\General\\L_EVENT_COUNTER_UTIL.lua", []() {return new EventCounterUtil();}}, {"scripts\\02_server\\Enemy\\General\\L_ENEMY_NJ_BUFF_STUN_IMMUNITY.lua", []() {return new EnemyNjBuff();}}, diff --git a/tests/dGameTests/FireTempleScriptsTests.cpp b/tests/dGameTests/FireTempleScriptsTests.cpp index d8856a63f..1b4f392ee 100644 --- a/tests/dGameTests/FireTempleScriptsTests.cpp +++ b/tests/dGameTests/FireTempleScriptsTests.cpp @@ -11,6 +11,7 @@ #include "02_server/Map/General/ZoneFireTempleServer.h" #include "EffectsMessages.h" #include "02_server/Map/General/EventCounterUtil.h" +#include "02_server/Map/General/BossGarmadonTornado.h" namespace { // A kill counter extension that records its limit events @@ -143,3 +144,22 @@ TEST_F(FireTempleScriptsTest, EventCounterFiresAtMax) { counter.OnFireEventServerSide(&entity, &entity, "hit", 0, 0, 0); EXPECT_EQ(entity.GetVar(u"counter"), 1); } + +// L_BOSS_GARMADON_TORNADO: the bomb wait is a whole number of seconds from half the element's delay to all of it, and +// the boss manager's NewElement picks the element by its place in the order +TEST_F(FireTempleScriptsTest, TornadoBombsSoonerForLaterElements) { + for (int32_t i = 0; i < 50; i++) { + const auto earth = BossGarmadonTornado::BombDelay("earth"); + EXPECT_GE(earth, 20); + EXPECT_LE(earth, 40); + const auto fire = BossGarmadonTornado::BombDelay("fire"); + EXPECT_GE(fire, 14); + EXPECT_LE(fire, 28); + } + Entity entity(288300744895900207, info); + BossGarmadonTornado tornado; + tornado.OnNotifyObject(&entity, &entity, "NewElement", 3); + EXPECT_EQ(entity.GetVar(u"CurrentElement"), "lightning"); + tornado.OnNotifyObject(&entity, &entity, "NewElement", 0); + EXPECT_EQ(entity.GetVar(u"CurrentElement"), "lightning"); +}