mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-25 15:03:34 +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
55 lines
1.9 KiB
C++
55 lines
1.9 KiB
C++
#include "BootyDigServer.h"
|
|
#include "EntityManager.h"
|
|
#include "RenderComponent.h"
|
|
#include "MissionComponent.h"
|
|
#include "eMissionTaskType.h"
|
|
#include "eMissionState.h"
|
|
#include "Loot.h"
|
|
|
|
void BootyDigServer::OnStartup(Entity* self) {
|
|
auto* zoneControlObject = Game::entityManager->GetZoneControlEntity();
|
|
if (zoneControlObject != nullptr) {
|
|
zoneControlObject->OnFireEventServerSide(self, "CheckForPropertyOwner");
|
|
}
|
|
}
|
|
|
|
void BootyDigServer::OnPlayerLoaded(Entity* self, Entity* player) {
|
|
auto* zoneControlObject = Game::entityManager->GetZoneControlEntity();
|
|
if (zoneControlObject != nullptr) {
|
|
zoneControlObject->OnFireEventServerSide(self, "CheckForPropertyOwner");
|
|
}
|
|
}
|
|
|
|
void
|
|
BootyDigServer::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
|
|
int32_t param3) {
|
|
|
|
auto propertyOwner = self->GetNetworkVar<std::string>(u"PropertyOwnerID");
|
|
auto* player = self->GetParentEntity();
|
|
if (player == nullptr)
|
|
return;
|
|
|
|
if (args == "ChestReady" && (propertyOwner == std::to_string(LWOOBJID_EMPTY) || player->GetVar<bool>(u"bootyDug"))) {
|
|
self->Smash(self->GetObjectID(), eKillType::SILENT);
|
|
} else if (args == "ChestOpened") {
|
|
// Make sure players only dig up one booty per instance
|
|
player->SetVar<bool>(u"bootyDug", true);
|
|
|
|
auto* missionComponent = player->GetComponent<MissionComponent>();
|
|
if (missionComponent != nullptr) {
|
|
auto* mission = missionComponent->GetMission(1881);
|
|
if (mission != nullptr && (mission->GetMissionState() == eMissionState::ACTIVE || mission->GetMissionState() == eMissionState::COMPLETE_ACTIVE)) {
|
|
mission->Progress(eMissionTaskType::SCRIPT, self->GetLOT());
|
|
|
|
auto* renderComponent = self->GetComponent<RenderComponent>();
|
|
if (renderComponent != nullptr)
|
|
renderComponent->PlayEffect(7730, u"cast", "bootyshine");
|
|
|
|
Loot::DropLoot(player, self, 231, 75, 75);
|
|
}
|
|
}
|
|
} else if (args == "ChestDead") {
|
|
self->Smash(player->GetObjectID(), eKillType::SILENT);
|
|
}
|
|
}
|