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,5 @@
set(DSCRIPTS_SOURCES_02_SERVER_MAP_PR
"HydrantBroken.cpp"
"PrSeagullFly.cpp"
"SpawnGryphonServer.cpp"
PARENT_SCOPE)

View 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);
}
}

View 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;
};

View 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);
}

View 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;
};

View 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);
}

View 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;
};