mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 21:47:24 +00:00
8cdb388915
* Implement Precompiled Headers * First volume of optimizations * Scripts A-B Gonna be doing this in alphabetical order now. * C Scripts and remove unneeded includes from base cppscripts header Remove the MissionComponent and Loot includes from all base scripts and place their needed includes in the respective scripts. * D scripts * F scripts * F scripts 2 Finish up removing extraneous includes from scripts that start with the letter F * G scripts Removing extraneous includes from scripts that start with the letter G * I scripts Removing extraneous includes from scripts that start with the letter I * M-Z scripts Removing extraneous includes from scripts that start with the letter M-Z * Revert "Implement Precompiled Headers" This reverts commitd79d8d4991
. * Revert "Revert "Implement Precompiled Headers"" This reverts commit0597faf308
. * Add back in PCH Add back in PCH * Fix CMake Whitespace Remove duplicate file glob Remove newline
73 lines
2.6 KiB
C++
73 lines
2.6 KiB
C++
#include "EnemySpiderSpawner.h"
|
|
#include "GameMessages.h"
|
|
#include "EntityManager.h"
|
|
#include "DestroyableComponent.h"
|
|
|
|
//----------------------------------------------
|
|
//--Initiate egg hatching on call
|
|
//----------------------------------------------
|
|
void EnemySpiderSpawner::OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1,
|
|
int32_t param2, int32_t param3) {
|
|
if (args == "prepEgg") {
|
|
// Highlight eggs about to hatch with Maelstrom effect
|
|
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2856, u"maelstrom", "test", LWOOBJID_EMPTY, 1.0f, 1.0f, true);
|
|
|
|
// Make indestructible
|
|
auto dest = static_cast<DestroyableComponent*>(self->GetComponent(COMPONENT_TYPE_DESTROYABLE));
|
|
if (dest) {
|
|
dest->SetFaction(-1);
|
|
}
|
|
EntityManager::Instance()->SerializeEntity(self);
|
|
|
|
// Keep track of who prepped me
|
|
self->SetI64(u"SpawnOwner", sender->GetObjectID());
|
|
|
|
} else if (args == "hatchEgg") {
|
|
// Final countdown to pop
|
|
self->AddTimer("StartSpawnTime", hatchTime);
|
|
}
|
|
}
|
|
|
|
//----------------------------------------------------------------
|
|
//--Called when timers are done
|
|
//----------------------------------------------------------------
|
|
void EnemySpiderSpawner::OnTimerDone(Entity* self, std::string timerName) {
|
|
if (timerName == "StartSpawnTime") {
|
|
SpawnSpiderling(self);
|
|
} else if (timerName == "SpawnSpiderling") {
|
|
GameMessages::SendPlayFXEffect(self->GetObjectID(), 644, u"create", "egg_puff_b", LWOOBJID_EMPTY, 1.0f, 1.0f, true);
|
|
|
|
//TODO: set the aggro radius larger
|
|
|
|
EntityInfo info {};
|
|
info.lot = 16197;
|
|
info.pos = self->GetPosition();
|
|
info.spawner = nullptr;
|
|
info.spawnerID = self->GetI64(u"SpawnOwner");
|
|
info.spawnerNodeID = 0;
|
|
|
|
Entity* newEntity = EntityManager::Instance()->CreateEntity(info, nullptr);
|
|
if (newEntity) {
|
|
EntityManager::Instance()->ConstructEntity(newEntity);
|
|
newEntity->GetGroups().push_back("BabySpider");
|
|
|
|
/*
|
|
auto* movementAi = newEntity->GetComponent<MovementAIComponent>();
|
|
|
|
movementAi->SetDestination(newEntity->GetPosition());
|
|
*/
|
|
}
|
|
|
|
self->ScheduleKillAfterUpdate();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------
|
|
//Called when it is finally time to release the Spiderlings
|
|
//--------------------------------------------------------------
|
|
void EnemySpiderSpawner::SpawnSpiderling(Entity* self) {
|
|
//Initiate the actual spawning
|
|
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2260, u"rebuild_medium", "dropdustmedium", LWOOBJID_EMPTY, 1.0f, 1.0f, true);
|
|
self->AddTimer("SpawnSpiderling", spawnTime);
|
|
}
|