mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 09:44:10 +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:
5
dScripts/02_server/Map/PR/CMakeLists.txt
Normal file
5
dScripts/02_server/Map/PR/CMakeLists.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
set(DSCRIPTS_SOURCES_02_SERVER_MAP_PR
|
||||
"HydrantBroken.cpp"
|
||||
"PrSeagullFly.cpp"
|
||||
"SpawnGryphonServer.cpp"
|
||||
PARENT_SCOPE)
|
37
dScripts/02_server/Map/PR/HydrantBroken.cpp
Normal file
37
dScripts/02_server/Map/PR/HydrantBroken.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "HydrantBroken.h"
|
||||
#include "EntityManager.h"
|
||||
#include "GameMessages.h"
|
||||
|
||||
void HydrantBroken::OnStartup(Entity* self) {
|
||||
self->AddTimer("playEffect", 1);
|
||||
|
||||
const auto hydrant = "hydrant" + self->GetVar<std::string>(u"hydrant");
|
||||
|
||||
const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant);
|
||||
|
||||
for (auto* bouncer : bouncers) {
|
||||
self->SetVar<LWOOBJID>(u"bouncer", bouncer->GetObjectID());
|
||||
|
||||
GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), true, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"enableCollision", UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
|
||||
self->AddTimer("KillBroken", 25);
|
||||
}
|
||||
|
||||
void HydrantBroken::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "KillBroken") {
|
||||
auto* bouncer = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"bouncer"));
|
||||
|
||||
if (bouncer != nullptr) {
|
||||
GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), false, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"disableCollision", UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
|
||||
self->Kill();
|
||||
} else if (timerName == "playEffect") {
|
||||
GameMessages::SendPlayFXEffect(self->GetObjectID(), 384, u"water", "water", LWOOBJID_EMPTY, 1, 1, true);
|
||||
}
|
||||
}
|
9
dScripts/02_server/Map/PR/HydrantBroken.h
Normal file
9
dScripts/02_server/Map/PR/HydrantBroken.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class HydrantBroken : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||
};
|
19
dScripts/02_server/Map/PR/PrSeagullFly.cpp
Normal file
19
dScripts/02_server/Map/PR/PrSeagullFly.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "PrSeagullFly.h"
|
||||
#include "Entity.h"
|
||||
|
||||
void PrSeagullFly::OnStartup(Entity* self) {
|
||||
self->SetVar<int32_t>(u"playersNear", 0);
|
||||
self->SetProximityRadius(15, "birdMonitor");
|
||||
}
|
||||
|
||||
void PrSeagullFly::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
|
||||
if (!entering->IsPlayer()) return;
|
||||
|
||||
if (status == "ENTER") {
|
||||
self->SetVar<int32_t>(u"playersNear", self->GetVar<int32_t>(u"playersNear") + 1);
|
||||
} else if (status == "LEAVE") {
|
||||
self->SetVar<int32_t>(u"playersNear", self->GetVar<int32_t>(u"playersNear") - 1);
|
||||
}
|
||||
|
||||
self->SetNetworkVar(u"BirdLanded", self->GetVar<int32_t>(u"playersNear") == 0);
|
||||
}
|
10
dScripts/02_server/Map/PR/PrSeagullFly.h
Normal file
10
dScripts/02_server/Map/PR/PrSeagullFly.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class PrSeagullFly : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override;
|
||||
};
|
||||
|
27
dScripts/02_server/Map/PR/SpawnGryphonServer.cpp
Normal file
27
dScripts/02_server/Map/PR/SpawnGryphonServer.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "SpawnGryphonServer.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "GameMessages.h"
|
||||
#include "MissionComponent.h"
|
||||
|
||||
void SpawnGryphonServer::SetVariables(Entity* self) {
|
||||
self->SetVar<LOT>(u"petLOT", 12433);
|
||||
self->SetVar<std::string>(u"petType", "gryphon");
|
||||
self->SetVar<uint32_t>(u"maxPets", 2);
|
||||
self->SetVar<std::u16string>(u"spawnAnim", u"spawn");
|
||||
self->SetVar<std::u16string>(u"spawnCinematic", u"SentinelPet");
|
||||
}
|
||||
|
||||
void SpawnGryphonServer::OnUse(Entity* self, Entity* user) {
|
||||
auto* missionComponent = user->GetComponent<MissionComponent>();
|
||||
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
|
||||
|
||||
// Little extra for handling the case of the egg being placed the first time
|
||||
if (missionComponent != nullptr && inventoryComponent != nullptr
|
||||
&& missionComponent->GetMissionState(1391) == MissionState::MISSION_STATE_ACTIVE) {
|
||||
inventoryComponent->RemoveItem(12483, inventoryComponent->GetLotCount(12483));
|
||||
GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID());
|
||||
return;
|
||||
}
|
||||
|
||||
SpawnPetBaseServer::OnUse(self, user);
|
||||
}
|
7
dScripts/02_server/Map/PR/SpawnGryphonServer.h
Normal file
7
dScripts/02_server/Map/PR/SpawnGryphonServer.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
#include "SpawnPetBaseServer.h"
|
||||
|
||||
class SpawnGryphonServer : public SpawnPetBaseServer {
|
||||
void SetVariables(Entity* self) override;
|
||||
void OnUse(Entity* self, Entity* user) override;
|
||||
};
|
Reference in New Issue
Block a user