Fix Spider Queen boss battle crash (#1034)

This commit is contained in:
David Markowitz 2023-03-30 06:01:15 -07:00 committed by GitHub
parent c415d0520a
commit cbef4a140e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,8 +48,6 @@ void BossSpiderQueenEnemyServer::OnStartup(Entity* self) {
m_CurrentBossStage = 1;
// Obtain faction and collision group to save for subsequent resets
//self : SetVar("SBFactionList", self:GetFaction().factionList)
//self : SetVar("SBCollisionGroup", self:GetCollisionGroup().colGroup)
}
void BossSpiderQueenEnemyServer::OnDie(Entity* self, Entity* killer) {
@ -61,8 +59,6 @@ void BossSpiderQueenEnemyServer::OnDie(Entity* self, Entity* killer) {
missionComponent->CompleteMission(instanceMissionID);
}
Game::logger->Log("BossSpiderQueenEnemyServer", "Starting timer...");
// There is suppose to be a 0.1 second delay here but that may be admitted?
auto* controller = EntityManager::Instance()->GetZoneControlEntity();
@ -165,9 +161,6 @@ void BossSpiderQueenEnemyServer::SpawnSpiderWave(Entity* self, int spiderCount)
// The Spider Queen Boss is withdrawing and requesting the spawn
// of a hatchling wave
/*auto SpiderEggNetworkID = self->GetI64(u"SpiderEggNetworkID");
if (SpiderEggNetworkID == 0) return;*/
// Clamp invalid Spiderling number requests to the maximum amount of eggs available
if ((spiderCount > maxSpiderEggCnt) || (spiderCount < 0))
spiderCount = maxSpiderEggCnt;
@ -176,44 +169,13 @@ void BossSpiderQueenEnemyServer::SpawnSpiderWave(Entity* self, int spiderCount)
hatchCounter = spiderCount;
hatchList = {};
Game::logger->Log("SpiderQueen", "Trying to spawn %i spiders", hatchCounter);
// Run the wave manager
SpiderWaveManager(self);
}
void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) {
auto SpiderEggNetworkID = self->GetI64(u"SpiderEggNetworkID");
// Reset the spider egg spawner network to ensure a maximum number of eggs
//SpiderEggNetworkID:SpawnerReset()
// Obtain a list of all the eggs on the egg spawner network
//auto spiderEggList = SpiderEggNetworkID:SpawnerGetAllObjectIDsSpawned().objects;
//if (table.maxn(spiderEggList) <= 0) {
// self->AddTimer("PollSpiderWaveManager", 1.0f);
// return;
//}
//
//// A check for (wave mangement across multiple spawn iterations
//if(hatchCounter < spiderWaveCnt) {
// // We have already prepped some objects for (hatching,
// // remove them from our list for (random egg pulls
// for (i, sVal in ipairs(spiderEggList) {
// if(hatchList[sVal:GetID()]) {
// // We have found a prepped egg, remove it from the spiderEggList
// spiderEggList[i] = nil
// }
// }
//}
std::vector<LWOOBJID> spiderEggs{};
auto spooders = EntityManager::Instance()->GetEntitiesInGroup("EGG");
@ -223,6 +185,7 @@ void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) {
// Select a number of random spider eggs from the list equal to the
// current number needed to complete the current wave
if (!spiderEggs.empty()) {
for (int i = 0; i < hatchCounter; i++) {
// Select a random spider egg
auto randomEggLoc = GeneralUtils::GenerateRandomNumber<int>(0, spiderEggs.size() - 1);
@ -244,9 +207,7 @@ void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) {
}
// Prep the selected spider egg
//randomEgg:FireEvent{s}erID=self, args="prepEgg"}
eggEntity->OnFireEventServerSide(self, "prepEgg");
Game::logger->Log("SpiderQueen", "Prepping egg %llu", eggEntity->GetObjectID());
// Add the prepped egg to our hatchList
hatchList.push_back(eggEntity->GetObjectID());
@ -256,13 +217,13 @@ void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) {
}
// Remove it from our spider egg list
//table.remove(spiderEggList, randomEggLoc);
spiderEggs[randomEggLoc] = LWOOBJID_EMPTY;
if (spiderEggs.size() <= 0 || (hatchCounter <= 0)) {
break;
}
}
}
if (hatchCounter > 0) {
// We still have more eggs to hatch, poll the SpiderWaveManager again
@ -279,14 +240,12 @@ void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) {
}
eggEntity->OnFireEventServerSide(self, "hatchEgg");
Game::logger->Log("SpiderQueen", "hatching egg %llu", eggEntity->GetObjectID());
auto time = PlayAnimAndReturnTime(self, spiderWithdrawIdle);
combat->SetStunImmune(false);
combat->Stun(time += 6.0f);
combat->SetStunImmune(true);
//self->AddTimer("disableWaitForIdle", defaultAnimPause);
self->AddTimer("checkForSpiders", 6.0f);
}
@ -397,10 +356,6 @@ void BossSpiderQueenEnemyServer::RapidFireShooterManager(Entity* self) {
}
void BossSpiderQueenEnemyServer::RunRapidFireShooter(Entity* self) {
/*
const auto targets = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::CHARACTER);
*/
const auto targets = self->GetTargetsInPhantom();
if (self->GetBoolean(u"stoppedFlag")) {
@ -433,8 +388,6 @@ void BossSpiderQueenEnemyServer::RunRapidFireShooter(Entity* self) {
PlayAnimAndReturnTime(self, spiderSingleShot);
Game::logger->Log("BossSpiderQueenEnemyServer", "Ran RFS");
self->AddTimer("RFS", GeneralUtils::GenerateRandomNumber<float>(10, 15));
}
@ -556,26 +509,6 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
GameMessages::SendPlayEmbeddedEffectOnAllClientsNearObject(self, u"camshake-bridge", self->GetObjectID(), 100.0f);
} else if (timerName == "AdvanceComplete") {
//Reset faction and collision
/*local SBFactionList = self:GetVar("SBFactionList")
local SBCollisionGroup = self:GetVar("SBCollisionGroup")
for i, fVal in ipairs(SBFactionList) {
if(i == 1) {
//Our first faction - flush and add
self:SetFaction{faction = fVal}
else
//Add
self:ModifyFaction{factionID = fVal, bAddFaction = true}
}
}*/
/*
auto SBCollisionGroup = self->GetI32(u"SBCollisionGroup");
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"SetColGroup", SBCollisionGroup, 0, LWOOBJID_EMPTY, "", UNASSIGNED_SYSTEM_ADDRESS);
*/
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"SetColGroup", 11, 0, 0, "", UNASSIGNED_SYSTEM_ADDRESS);
//Wind up, telegraphing next round
@ -625,7 +558,6 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
//Did we queue a spcial attack?
if (self->GetBoolean(u"bSpecialQueued")) {
self->SetBoolean(u"bSpecialQueued", false);
//SpiderSkillManager(self, true);
}
}
}
@ -673,17 +605,6 @@ void BossSpiderQueenEnemyServer::OnUpdate(Entity* self) {
controllable->SetStatic(true);
EntityManager::Instance()->SerializeEntity(self);
//if (waitForIdle) return;
////Play the Spider Boss' mountain idle anim
//PlayAnimAndReturnTime(self, spiderWithdrawIdle);
////If there are still baby spiders, don't do anyhting either
//auto spooders = EntityManager::Instance()->GetEntitiesInGroup("BabySpider");
//if (spooders.size() > 0) return;
//else
// WithdrawSpider(self, false);
}
//----------------------------------------------