mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-30 01:41:40 +00:00
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>
120 lines
4.8 KiB
C++
120 lines
4.8 KiB
C++
#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;
|
|
}
|
|
}
|