Skip to content

Commit

Permalink
Add another script
Browse files Browse the repository at this point in the history
fix include guards

Fix dirt clouds not appearing on mission accept
  • Loading branch information
EmosewaMC committed Nov 25, 2023
1 parent 19b415a commit 2cff7fb
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 6 deletions.
4 changes: 0 additions & 4 deletions dGame/EntityManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ std::vector<LWOMAPID> EntityManager::m_GhostingExcludedZones = {

// Configure some exceptions for ghosting, nessesary for some special objects.
std::vector<LOT> EntityManager::m_GhostingExcludedLOTs = {
// NT - Pipes
9524,
12408,

// AG - Footrace
4967
};
Expand Down
2 changes: 2 additions & 0 deletions dScripts/02_server/Map/General/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL
"StoryBoxInteractServer.cpp"
"TokenConsoleServer.cpp"
"TouchMissionUpdateServer.cpp"
"VisToggleNotifierServer.cpp"
"NTNaomiDirtServer.cpp"
"WishingWellServer.cpp")

add_subdirectory(Ninjago)
Expand Down
5 changes: 5 additions & 0 deletions dScripts/02_server/Map/General/FrictionVolumeServer.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef __FRICTIONVOLUMESERVER__H__
#define __FRICTIONVOLUMESERVER__H__

#include "CppScripts.h"

class FrictionVolumeServer : public CppScripts::Script {
Expand All @@ -6,3 +9,5 @@ class FrictionVolumeServer : public CppScripts::Script {
private:
const float DefaultFrictionAmount = 1.5f;
};

#endif //!__FRICTIONVOLUMESERVER__H__
14 changes: 14 additions & 0 deletions dScripts/02_server/Map/General/NTNaomiDirtServer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "NTNaomiDirtServer.h"

namespace {
std::map<int32_t, std::string> VisibilityMissionTable = {
{1253, std::string("Dirt_Clouds_Sent")},
{1276, std::string("Dirt_Clouds_Assem")},
{1277, std::string("Dirt_Clouds_Para")},
{1283, std::string("Dirt_Clouds_Halls")}
};
};

void NTNaomiDirtServer::OnStartup(Entity* self) {
SetGameVariables(VisibilityMissionTable);
}
11 changes: 11 additions & 0 deletions dScripts/02_server/Map/General/NTNaomiDirtServer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef __NTNAOMIDIRTSERVER__H__
#define __NTNAOMIDIRTSERVER__H__

#include "VisToggleNotifierServer.h"

class NTNaomiDirtServer : public VisToggleNotifierServer {
public:
void OnStartup(Entity* self) override;
};

#endif //!__NTNAOMIDIRTSERVER__H__
23 changes: 23 additions & 0 deletions dScripts/02_server/Map/General/VisToggleNotifierServer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "VisToggleNotifierServer.h"
#include "eMissionState.h"
#include "Game.h"
#include "dZoneManager.h"

void VisToggleNotifierServer::OnMissionDialogueOK(Entity* self, Entity* target, int missionId, eMissionState missionState) {
auto itr = m_GameVariables.find(missionId);
if (itr != m_GameVariables.end()) {
bool visible = true;
if (missionState == eMissionState::READY_TO_COMPLETE || missionState == eMissionState::COMPLETE_READY_TO_COMPLETE) {
visible = false;
}

auto spawners = Game::zoneManager->GetSpawnersByName(itr->second);
if (spawners.empty()) return;
for (const auto spawner : spawners) {
auto spawnedObjIds = spawner->GetSpawnedObjectIDs();
for (const auto& objId : spawnedObjIds) {
GameMessages::SendNotifyClientObject(objId, u"SetVisibility", visible);
}
}
}
}
15 changes: 15 additions & 0 deletions dScripts/02_server/Map/General/VisToggleNotifierServer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef __VISTOGGLENOTIFIERSERVER__H__
#define __VISTOGGLENOTIFIERSERVER__H__

#include "CppScripts.h"

class VisToggleNotifierServer : public CppScripts::Script {
public:
void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) override;
protected:
void SetGameVariables(std::map<int32_t, std::string>& gameVariables) { m_GameVariables = gameVariables; }
private:
std::map<int32_t, std::string> m_GameVariables;
};

#endif //!__VISTOGGLENOTIFIERSERVER__H__
1 change: 1 addition & 0 deletions dScripts/02_server/Map/NT/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_NT
"NtXRayServer.cpp"
"NtSleepingGuard.cpp"
"NtImagimeterVisibility.cpp"
"NTPipeVisibilityServer.cpp"
"NtSentinelWalkwayServer.cpp"
"NtDarkitectRevealServer.cpp"
"NtParadoxTeleServer.cpp"
Expand Down
15 changes: 15 additions & 0 deletions dScripts/02_server/Map/NT/NTPipeVisibilityServer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "NTPipeVisibilityServer.h"
#include "Entity.h"
#include "Character.h"

void NTPipeVisibilityServer::OnRebuildComplete(Entity* self, Entity* target) {
const auto flag = self->GetVar<int32_t>(u"flag");
if (flag == 0) return;

auto* character = target->GetCharacter();
if (!character) return;

character->SetPlayerFlag(flag, true);

GameMessages::SendNotifyClientObject(self->GetObjectID(), u"PipeBuilt");
}
11 changes: 11 additions & 0 deletions dScripts/02_server/Map/NT/NTPipeVisibilityServer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef __NTPIPEVISIBILITYSERVER__H__
#define __NTPIPEVISIBILITYSERVER__H__

#include "CppScripts.h"

class NTPipeVisibilityServer : public CppScripts::Script {
public:
void OnRebuildComplete(Entity* self, Entity* target) override;
};

#endif //!__NTPIPEVISIBILITYSERVER__H__
10 changes: 8 additions & 2 deletions dScripts/CppScripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@
#include "NtSleepingGuard.h"
#include "NtImagimeterVisibility.h"
#include "FrictionVolumeServer.h"
#include "NTPipeVisibilityServer.h"
#include "NTNaomiDirtServer.h"

// DLU Scripts
#include "DLUVanityNPC.h"
Expand Down Expand Up @@ -312,6 +314,7 @@
#include "WildNinjaStudent.h"
#include "WildNinjaSensei.h"
#include "WildNinjaBricks.h"
#include "VisToggleNotifierServer.h"

namespace {
InvalidScript* invalidToReturn = new InvalidScript();
Expand Down Expand Up @@ -707,9 +710,12 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
script = new NtXRayServer();
else if (scriptName == "scripts\\02_server\\Map\\NT\\L_NT_SLEEPING_GUARD.lua")
script = new NtSleepingGuard();
else if (scriptName == "scripts\\02_server\\Map\\NT\\L_NT_IMAGIMETER_VISIBILITY_SERVER.lua") {
else if (scriptName == "scripts\\02_server\\Map\\NT\\L_NT_IMAGIMETER_VISIBILITY_SERVER.lua")
script = new NTImagimeterVisibility();
}
else if (scriptName == "scripts\\02_server\\Map\\NT\\L_NT_PIPE_VISIBILITY_SERVER.lua")
script = new NTPipeVisibilityServer();
else if (scriptName == "scripts\\02_server\\Map\\NT\\L_NT_NAOMI_DIRT_SERVER.lua")
script = new NTNaomiDirtServer();

//AM:
else if (scriptName == "scripts\\02_server\\Map\\AM\\L_AM_CONSOLE_TELEPORT_SERVER.lua")
Expand Down
9 changes: 9 additions & 0 deletions dZoneManager/Spawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ void Spawner::Update(const float deltaTime) {
}
}

std::vector<LWOOBJID> Spawner::GetSpawnedObjectIDs() const {
std::vector<LWOOBJID> ids;
ids.reserve(m_Entities.size());
for (const auto& [objId, spawnerNode] : m_Entities) {
ids.push_back(objId);
}
return ids;
}

void Spawner::NotifyOfEntityDeath(const LWOOBJID& objectID) {
for (std::function<void()> cb : m_SpawnedEntityDieCallbacks) {
cb();
Expand Down
1 change: 1 addition & 0 deletions dZoneManager/Spawner.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class Spawner {
void SetRespawnTime(float time);
void SetNumToMaintain(int32_t value);
bool GetIsSpawnSmashGroup() const { return m_SpawnSmashFoundGroup; };
std::vector<LWOOBJID> GetSpawnedObjectIDs() const;

SpawnerInfo m_Info;
bool m_Active = true;
Expand Down

0 comments on commit 2cff7fb

Please sign in to comment.