mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 21:47:24 +00:00
0531365cb5
* loot fix (broken) * Fixed loot * Update SlashCommandHandler.cpp * Remove debug command * Roll loot command * Remove debug log * Added const references When this commit is applied it adds const references to the loot system avoid some unnecessary copies. Co-authored-by: wincent <wincent.holm@gmail.com> Co-authored-by: Avery <averysumner@gmail.com>
56 lines
2.0 KiB
C++
56 lines
2.0 KiB
C++
#include "MinigameTreasureChestServer.h"
|
|
#include "ScriptedActivityComponent.h"
|
|
#include "TeamManager.h"
|
|
#include "EntityManager.h"
|
|
#include "dZoneManager.h"
|
|
#include "dServer.h"
|
|
|
|
void MinigameTreasureChestServer::OnUse(Entity *self, Entity *user) {
|
|
auto* sac = self->GetComponent<ScriptedActivityComponent>();
|
|
if (sac == nullptr)
|
|
return;
|
|
|
|
if (self->GetVar<bool>(u"used"))
|
|
return;
|
|
self->SetVar<bool>(u"used", true);
|
|
|
|
if (!IsPlayerInActivity(self, user->GetObjectID()))
|
|
UpdatePlayer(self, user->GetObjectID());
|
|
|
|
auto* team = TeamManager::Instance()->GetTeam(user->GetObjectID());
|
|
if (team != nullptr) {
|
|
for (const auto& teamMemberID : team->members) {
|
|
auto* teamMember = EntityManager::Instance()->GetEntity(teamMemberID);
|
|
if (teamMember != nullptr)
|
|
LootGenerator::Instance().DropActivityLoot(teamMember, self, sac->GetActivityID(), CalculateActivityRating(self, teamMemberID));
|
|
}
|
|
} else {
|
|
LootGenerator::Instance().DropActivityLoot(user, self, sac->GetActivityID(), CalculateActivityRating(self, user->GetObjectID()));
|
|
}
|
|
|
|
sac->PlayerRemove(user->GetObjectID());
|
|
|
|
auto* zoneControl = dZoneManager::Instance()->GetZoneControlObject();
|
|
if (zoneControl != nullptr) {
|
|
zoneControl->OnFireEventServerSide(self, "Survival_Update", 0);
|
|
}
|
|
|
|
self->Smash(self->GetObjectID());
|
|
}
|
|
|
|
uint32_t MinigameTreasureChestServer::CalculateActivityRating(Entity *self, LWOOBJID playerID) {
|
|
auto* team = TeamManager::Instance()->GetTeam(playerID);
|
|
return team != nullptr ? team->members.size() * 100 : ActivityManager::CalculateActivityRating(self, playerID) * 100;
|
|
}
|
|
|
|
void MinigameTreasureChestServer::OnStartup(Entity *self) {
|
|
|
|
// BONS treasure chest thinks it's on FV, causing it to start a lobby
|
|
if (Game::server->GetZoneID() == 1204) {
|
|
auto* sac = self->GetComponent<ScriptedActivityComponent>();
|
|
if (sac != nullptr) {
|
|
sac->SetInstanceMapID(1204);
|
|
}
|
|
}
|
|
}
|