mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-24 06:27:24 +00:00
c6087ce77a
* Move away from constructor queries Fix up other large tables to have proper backup lookups Revert "idk im just dumb ig" This reverts commit 5d5be5df53b8959b42b291613d7db749a65a3585. idk im just dumb ig * Fix slow components registry lookup * add define for cdclient cache all * Huge loot namespace rework - Remove all excess memory usage - do not cache components registry - cache loot matrices on startup of the destroyable component - convert loot singleton class to a namespace - rework loot cdclient tables to operate closer to how someone would actually use them (basically doing the previous LootGenerator::LootGenerator caching but in those tables) - Memory usage reduced by 10%+ across the board * cache rebuild matrix * Database: move reading to own function Also change name of cache to PascalCase * Database: Move common function rading
66 lines
2.0 KiB
C++
66 lines
2.0 KiB
C++
#include "MinigameTreasureChestServer.h"
|
|
#include "ScriptedActivityComponent.h"
|
|
#include "TeamManager.h"
|
|
#include "EntityManager.h"
|
|
#include "dZoneManager.h"
|
|
#include "Loot.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());
|
|
uint32_t activityRating = 0;
|
|
if (team != nullptr) {
|
|
for (const auto& teamMemberID : team->members) {
|
|
auto* teamMember = Game::entityManager->GetEntity(teamMemberID);
|
|
if (teamMember != nullptr) {
|
|
activityRating = CalculateActivityRating(self, teamMemberID);
|
|
|
|
if (self->GetLOT() == frakjawChestId) activityRating = team->members.size();
|
|
|
|
Loot::DropActivityLoot(teamMember, self, sac->GetActivityID(), activityRating);
|
|
}
|
|
}
|
|
} else {
|
|
activityRating = CalculateActivityRating(self, user->GetObjectID());
|
|
|
|
if (self->GetLOT() == frakjawChestId) activityRating = 1;
|
|
|
|
Loot::DropActivityLoot(user, self, sac->GetActivityID(), activityRating);
|
|
}
|
|
|
|
sac->PlayerRemove(user->GetObjectID());
|
|
|
|
auto* zoneControl = Game::zoneManager->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::zoneManager->GetZoneID().GetMapID() == 1204) {
|
|
auto* sac = self->GetComponent<ScriptedActivityComponent>();
|
|
if (sac != nullptr) {
|
|
sac->SetInstanceMapID(1204);
|
|
}
|
|
}
|
|
}
|