DarkflameServer/dScripts/NsQbImaginationStatue.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1010 B
C++
Raw Normal View History

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