DarkflameServer/dScripts/02_server/Enemy/General/TreasureChestDragonServer.cpp

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

44 lines
1.0 KiB
C++
Raw Permalink Normal View History

#include "TreasureChestDragonServer.h"
#include "ScriptedActivityComponent.h"
#include "TeamManager.h"
#include "EntityManager.h"
#include "Loot.h"
void TreasureChestDragonServer::OnStartup(Entity* self) {
2022-07-28 13:39:57 +00:00
}
void TreasureChestDragonServer::OnUse(Entity* self, Entity* user) {
if (self->GetVar<bool>(u"bUsed")) {
return;
}
self->SetVar<bool>(u"bUsed", true);
auto* scriptedActivityComponent = self->GetComponent<ScriptedActivityComponent>();
if (scriptedActivityComponent == nullptr) {
return;
}
auto rating = 1;
auto* team = TeamManager::Instance()->GetTeam(user->GetObjectID());
if (team != nullptr) {
rating = team->members.size();
for (const auto member : team->members) {
auto* memberObject = Game::entityManager->GetEntity(member);
if (memberObject == nullptr) continue;
Loot::DropActivityLoot(memberObject, self, scriptedActivityComponent->GetActivityID(), rating);
}
} else {
Loot::DropActivityLoot(user, self, scriptedActivityComponent->GetActivityID(), rating);
}
self->Smash(self->GetObjectID());
}