Organize dScripts (#814)

* Organize dScripts

whitespace

Remove parent scope

Remove parent scope from initial setter

Remove debug

Remove helper programs

* Fix NtImagimeterVisibility script

Co-authored-by: aronwk-aaron <aronwk.aaron@gmail.com>
This commit is contained in:
David Markowitz
2022-11-03 10:57:54 -07:00
committed by GitHub
parent b974eed8f5
commit 8d37d9b681
567 changed files with 886 additions and 252 deletions

View File

@@ -0,0 +1,52 @@
#include "BootyDigServer.h"
#include "EntityManager.h"
#include "RenderComponent.h"
#include "MissionComponent.h"
#include "MissionTaskType.h"
void BootyDigServer::OnStartup(Entity* self) {
auto* zoneControlObject = EntityManager::Instance()->GetZoneControlEntity();
if (zoneControlObject != nullptr) {
zoneControlObject->OnFireEventServerSide(self, "CheckForPropertyOwner");
}
}
void BootyDigServer::OnPlayerLoaded(Entity* self, Entity* player) {
auto* zoneControlObject = EntityManager::Instance()->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(), 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() == MissionState::MISSION_STATE_ACTIVE || mission->GetMissionState() == MissionState::MISSION_STATE_COMPLETE_ACTIVE)) {
mission->Progress(MissionTaskType::MISSION_TASK_TYPE_SCRIPT, self->GetLOT());
auto* renderComponent = self->GetComponent<RenderComponent>();
if (renderComponent != nullptr)
renderComponent->PlayEffect(7730, u"cast", "bootyshine");
LootGenerator::Instance().DropLoot(player, self, 231, 75, 75);
}
}
} else if (args == "ChestDead") {
self->Smash(player->GetObjectID(), SILENT);
}
}

View File

@@ -0,0 +1,8 @@
#pragma once
#include "CppScripts.h"
class BootyDigServer : public CppScripts::Script {
void OnStartup(Entity* self) override;
void OnPlayerLoaded(Entity* self, Entity* player) override;
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) override;
};

View File

@@ -0,0 +1,4 @@
set(DSCRIPTS_SOURCES_02_SERVER_EQUIPMENT
"MaestromExtracticatorServer.cpp"
"BootyDigServer.cpp"
PARENT_SCOPE)

View File

@@ -0,0 +1,50 @@
#include "MaestromExtracticatorServer.h"
#include "GameMessages.h"
#include "GeneralUtils.h"
#include "EntityManager.h"
#include "MissionComponent.h"
void MaestromExtracticatorServer::OnStartup(Entity* self) {
//self:SetNetworkVar("current_anim", failAnim)
GameMessages::SendPlayAnimation(self, GeneralUtils::ASCIIToUTF16(failAnim));
self->AddTimer("PlayFail", defaultTime);
self->AddTimer("RemoveSample", destroyAfterNoSampleTime);
}
void MaestromExtracticatorServer::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1,
int32_t param2, int32_t param3) {
if (sender == nullptr)
return;
if (args == "attemptCollection") {
Entity* player = EntityManager::Instance()->GetEntity(self->GetSpawnerID());
if (!player) return;
auto missionComponent = player->GetComponent<MissionComponent>();
if (missionComponent == nullptr) return;
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_SMASH, 14718);
CollectSample(self, sender->GetObjectID());
sender->ScheduleKillAfterUpdate();
}
}
void MaestromExtracticatorServer::CollectSample(Entity* self, LWOOBJID sampleObj) {
PlayAnimAndReturnTime(self, collectAnim);
self->AddTimer("RemoveSample", defaultTime);
}
void MaestromExtracticatorServer::PlayAnimAndReturnTime(Entity* self, std::string animID) {
GameMessages::SendPlayAnimation(self, GeneralUtils::ASCIIToUTF16(animID));
}
void MaestromExtracticatorServer::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "RemoveSample") {
self->ScheduleKillAfterUpdate();
}
if (timerName == "PlayFail") {
GameMessages::SendPlayAnimation(self, GeneralUtils::ASCIIToUTF16(failAnim));
}
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include "CppScripts.h"
class MaestromExtracticatorServer : public CppScripts::Script {
public:
void OnStartup(Entity* self);
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
int32_t param3);
void CollectSample(Entity* self, LWOOBJID sampleObj);
void PlayAnimAndReturnTime(Entity* self, std::string animID);
void OnTimerDone(Entity* self, std::string timerName);
private:
const std::string failAnim = "idle_maelstrom";
const std::string collectAnim = "collect_maelstrom";
const float defaultTime = 4.0f;
const float destroyAfterNoSampleTime = 8.0f;
};