mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-30 01:41:40 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
119
dScripts/02_server/Map/General/BossGarmadonTornado.cpp
Normal file
119
dScripts/02_server/Map/General/BossGarmadonTornado.cpp
Normal file
@@ -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<std::string> 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<int32_t>(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<int32_t>(u"initialPlayerCount") > 2) self->SetVar<bool>(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<std::string>(u"CurrentElement", ElementalOrder[0]);
|
||||
StartBombTimer(self);
|
||||
} else if (name == "NewElement") {
|
||||
if (param1 < 1 || param1 > static_cast<int32_t>(ElementalOrder.size())) return;
|
||||
self->SetVar<std::string>(u"CurrentElement", ElementalOrder[param1 - 1]);
|
||||
} else if (name == "StopPathing") {
|
||||
if (auto* const platform = self->GetComponent<MovingPlatformComponent>()) 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<DestroyableComponent>();
|
||||
if (!destroyable) return;
|
||||
for (const auto faction : destroyable->GetFactionIDs()) {
|
||||
auto* const quickBuild = entering->GetComponent<QuickBuildComponent>();
|
||||
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<SkillComponent>()) 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<int32_t>(u"TotalPaths");
|
||||
const auto nextPath = PathString + std::to_string(GeneralUtils::GenerateRandomNumber<int32_t>(1, std::max(totalPaths, 1)));
|
||||
if (auto* const platform = self->GetComponent<MovingPlatformComponent>()) {
|
||||
platform->SetCurrentPath(nextPath, 0, false);
|
||||
platform->StartPathing();
|
||||
}
|
||||
self->SetVar<std::string>(u"CurrentPath", nextPath);
|
||||
}
|
||||
|
||||
void BossGarmadonTornado::StartBombTimer(Entity* self) {
|
||||
// (a timer with cancel)
|
||||
self->CancelTimer("BombPlayer");
|
||||
self->AddTimer("BombPlayer", static_cast<float>(BombDelay(self->GetVar<std::string>(u"CurrentElement"))));
|
||||
}
|
||||
|
||||
void BossGarmadonTornado::PickAPlayer(Entity* self) {
|
||||
for (auto* const trigger : Game::entityManager->GetEntitiesInGroup(GameSpaceVolume)) {
|
||||
if (!trigger) continue;
|
||||
StartBombTimer(self);
|
||||
std::vector<Entity*> players;
|
||||
auto* const phantom = trigger->GetComponent<PhantomPhysicsComponent>();
|
||||
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<size_t>(0, players.size() - 1)];
|
||||
auto* const destroyable = player->GetComponent<DestroyableComponent>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
22
dScripts/02_server/Map/General/BossGarmadonTornado.h
Normal file
22
dScripts/02_server/Map/General/BossGarmadonTornado.h
Normal file
@@ -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);
|
||||
};
|
||||
@@ -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"
|
||||
|
||||
@@ -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();}},
|
||||
|
||||
@@ -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<int32_t>(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<std::string>(u"CurrentElement"), "lightning");
|
||||
tornado.OnNotifyObject(&entity, &entity, "NewElement", 0);
|
||||
EXPECT_EQ(entity.GetVar<std::string>(u"CurrentElement"), "lightning");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user