DarkflameServer/dScripts/ai/NS/NsQbImaginationStatue.cpp

41 lines
1007 B
C++
Raw Permalink Normal View History

#include "NsQbImaginationStatue.h"
#include "EntityManager.h"
#include "GameMessages.h"
2022-07-28 13:39:57 +00:00
void NsQbImaginationStatue::OnStartup(Entity* self) {
}
void NsQbImaginationStatue::OnQuickBuildComplete(Entity* self, Entity* target) {
2022-07-28 13:39:57 +00:00
if (target == nullptr) return;
self->SetVar(u"Player", target->GetObjectID());
2022-07-28 13:39:57 +00:00
SpawnLoot(self);
2022-07-28 13:39:57 +00:00
self->AddTimer("SpawnDelay", 1.5f);
2022-07-28 13:39:57 +00:00
self->AddTimer("StopSpawner", 10.0f);
}
2022-07-28 13:39:57 +00:00
void NsQbImaginationStatue::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "SpawnDelay") {
SpawnLoot(self);
self->AddTimer("SpawnDelay", 1.5f);
} else if (timerName == "StopSpawner") {
self->CancelAllTimers();
}
}
2022-07-28 13:39:57 +00:00
void NsQbImaginationStatue::SpawnLoot(Entity* self) {
const auto playerId = self->GetVar<LWOOBJID>(u"Player");
auto* player = Game::entityManager->GetEntity(playerId);
2022-07-28 13:39:57 +00:00
if (player == nullptr) return;
2022-07-28 13:39:57 +00:00
GameMessages::SendDropClientLoot(player, self->GetObjectID(), 935, 0);
GameMessages::SendDropClientLoot(player, self->GetObjectID(), 935, 0);
}