DarkflameServer/dScripts/NsQbImaginationStatue.cpp

41 lines
1010 B
C++
Raw 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) {
}
2022-07-28 13:39:57 +00:00
void NsQbImaginationStatue::OnRebuildComplete(Entity* self, Entity* target) {
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 = EntityManager::Instance()->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);
}