2021-12-05 17:54:36 +00:00
|
|
|
#include "BootyDigServer.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "RenderComponent.h"
|
2022-07-05 06:00:10 +00:00
|
|
|
#include "MissionComponent.h"
|
2023-01-22 23:38:47 +00:00
|
|
|
#include "eMissionTaskType.h"
|
|
|
|
#include "eMissionState.h"
|
2023-01-07 05:17:05 +00:00
|
|
|
#include "Loot.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void BootyDigServer::OnStartup(Entity* self) {
|
|
|
|
auto* zoneControlObject = EntityManager::Instance()->GetZoneControlEntity();
|
|
|
|
if (zoneControlObject != nullptr) {
|
|
|
|
zoneControlObject->OnFireEventServerSide(self, "CheckForPropertyOwner");
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void BootyDigServer::OnPlayerLoaded(Entity* self, Entity* player) {
|
|
|
|
auto* zoneControlObject = EntityManager::Instance()->GetZoneControlEntity();
|
|
|
|
if (zoneControlObject != nullptr) {
|
|
|
|
zoneControlObject->OnFireEventServerSide(self, "CheckForPropertyOwner");
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2022-07-28 13:39:57 +00:00
|
|
|
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"))) {
|
2023-05-02 22:39:21 +00:00
|
|
|
self->Smash(self->GetObjectID(), eKillType::SILENT);
|
2022-07-28 13:39:57 +00:00
|
|
|
} else if (args == "ChestOpened") {
|
|
|
|
// Make sure players only dig up one booty per instance
|
|
|
|
player->SetVar<bool>(u"bootyDug", true);
|
|
|
|
|
2023-06-09 08:27:05 +00:00
|
|
|
auto* missionComponent = player->GetComponent<MissionComponent>();
|
2022-07-28 13:39:57 +00:00
|
|
|
if (missionComponent != nullptr) {
|
|
|
|
auto* mission = missionComponent->GetMission(1881);
|
2023-01-22 23:38:47 +00:00
|
|
|
if (mission != nullptr && (mission->GetMissionState() == eMissionState::ACTIVE || mission->GetMissionState() == eMissionState::COMPLETE_ACTIVE)) {
|
|
|
|
mission->Progress(eMissionTaskType::SCRIPT, self->GetLOT());
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-06-09 08:27:05 +00:00
|
|
|
auto* renderComponent = self->GetComponent<RenderComponent>();
|
2022-07-28 13:39:57 +00:00
|
|
|
if (renderComponent != nullptr)
|
|
|
|
renderComponent->PlayEffect(7730, u"cast", "bootyshine");
|
|
|
|
|
|
|
|
LootGenerator::Instance().DropLoot(player, self, 231, 75, 75);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (args == "ChestDead") {
|
2023-05-02 22:39:21 +00:00
|
|
|
self->Smash(player->GetObjectID(), eKillType::SILENT);
|
2022-07-28 13:39:57 +00:00
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|