mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-05 02:04:04 +00:00
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:
52
dScripts/02_server/Equipment/BootyDigServer.cpp
Normal file
52
dScripts/02_server/Equipment/BootyDigServer.cpp
Normal 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);
|
||||
}
|
||||
}
|
8
dScripts/02_server/Equipment/BootyDigServer.h
Normal file
8
dScripts/02_server/Equipment/BootyDigServer.h
Normal 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;
|
||||
};
|
4
dScripts/02_server/Equipment/CMakeLists.txt
Normal file
4
dScripts/02_server/Equipment/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
set(DSCRIPTS_SOURCES_02_SERVER_EQUIPMENT
|
||||
"MaestromExtracticatorServer.cpp"
|
||||
"BootyDigServer.cpp"
|
||||
PARENT_SCOPE)
|
50
dScripts/02_server/Equipment/MaestromExtracticatorServer.cpp
Normal file
50
dScripts/02_server/Equipment/MaestromExtracticatorServer.cpp
Normal 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));
|
||||
}
|
||||
}
|
18
dScripts/02_server/Equipment/MaestromExtracticatorServer.h
Normal file
18
dScripts/02_server/Equipment/MaestromExtracticatorServer.h
Normal 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;
|
||||
};
|
Reference in New Issue
Block a user