Skip to content

Commit

Permalink
fix: add Nexus Tower missing scripts (#1349)
Browse files Browse the repository at this point in the history
add final missing scripts for nt

also fix the turnin for the breadcrumb missions not showing the completion window.

Fix another missing script

Add another script

fix include guards

Fix dirt clouds not appearing on mission accept
  • Loading branch information
EmosewaMC authored Dec 23, 2023
1 parent c07c909 commit c1e8546
Show file tree
Hide file tree
Showing 38 changed files with 334 additions and 17 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ set(INCLUDED_DIRECTORIES
"dScripts/ai/GENERAL"
"dScripts/ai/GF"
"dScripts/ai/MINIGAME"
"dScripts/ai/MINIGAME/Objects"
"dScripts/ai/NP"
"dScripts/ai/NS"
"dScripts/ai/PETS"
Expand Down
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
9 changes: 9 additions & 0 deletions dGame/dComponents/MissionComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,3 +621,12 @@ bool MissionComponent::HasCollectible(int32_t collectibleID) {
bool MissionComponent::HasMission(uint32_t missionId) {
return GetMission(missionId) != nullptr;
}

void MissionComponent::ResetMission(const int32_t missionId) {
auto* mission = GetMission(missionId);

if (!mission) return;

m_Missions.erase(missionId);
GameMessages::SendResetMissions(m_Parent, m_Parent->GetSystemAddress(), missionId);
}
1 change: 1 addition & 0 deletions dGame/dComponents/MissionComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class MissionComponent : public Component
*/
bool HasMission(uint32_t missionId);

void ResetMission(const int32_t missionId);
private:
/**
* All the missions owned by this entity, mapped by mission ID
Expand Down
9 changes: 6 additions & 3 deletions dGame/dComponents/MissionOfferComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ uint32_t OfferedMission::GetMissionId() const {
return this->missionId;
}

bool OfferedMission::GetOfferMission() const {
bool OfferedMission::GetOffersMission() const {
return this->offersMission;
}

bool OfferedMission::GetAcceptMission() const {
bool OfferedMission::GetAcceptsMission() const {
return this->acceptsMission;
}

Expand Down Expand Up @@ -203,7 +203,10 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi
const auto selected = canAcceptPool[GeneralUtils::GenerateRandomNumber<int>(0, canAcceptPool.size() - 1)];

GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), selected, m_Parent->GetObjectID());
} else if (std::find(offered.begin(), offered.end(), missionId) == offered.end() && offeredMission->GetOfferMission()) {
} else if (
std::find(offered.begin(), offered.end(), missionId) == offered.end()
&&
(offeredMission->GetOffersMission() || offeredMission->GetAcceptsMission())) {
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), missionId, m_Parent->GetObjectID());
}
}
Expand Down
4 changes: 2 additions & 2 deletions dGame/dComponents/MissionOfferComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ struct OfferedMission {
* Returns if this mission is offered by the entity
* @return true if this mission is offered by the entity, false otherwise
*/
bool GetOfferMission() const;
bool GetOffersMission() const;

/**
* Returns if this mission may be accepted by the entity (currently unused)
* @return true if this mission may be accepted by the entity, false otherwise
*/
bool GetAcceptMission() const;
bool GetAcceptsMission() const;

private:

Expand Down
13 changes: 13 additions & 0 deletions dGame/dGameMessages/GameMessages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,19 @@ void GameMessages::SendStartPathing(Entity* entity) {
SEND_PACKET_BROADCAST;
}

void GameMessages::SendResetMissions(Entity* entity, const SystemAddress& sysAddr, const int32_t missionid) {
CBITSTREAM;
CMSGHEADER;

bitStream.Write(entity->GetObjectID());
bitStream.Write(eGameMessageType::RESET_MISSIONS);

bitStream.Write(missionid != -1);
if (missionid != -1) bitStream.Write(missionid);

SEND_PACKET;
}

void GameMessages::SendPlatformResync(Entity* entity, const SystemAddress& sysAddr, bool bStopAtDesiredWaypoint,
int iIndex, int iDesiredWaypointIndex, int nextIndex,
eMovementPlatformState movementState) {
Expand Down
1 change: 1 addition & 0 deletions dGame/dGameMessages/GameMessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ namespace GameMessages {
int iIndex = 0, int iDesiredWaypointIndex = 1, int nextIndex = 1,
eMovementPlatformState movementState = eMovementPlatformState::Moving);

void SendResetMissions(Entity* entity, const SystemAddress& sysAddr, const int32_t missionid = -1);
void SendRestoreToPostLoadStats(Entity* entity, const SystemAddress& sysAddr);
void SendServerDoneLoadingAllObjects(Entity* entity, const SystemAddress& sysAddr);
void SendGMLevelBroadcast(const LWOOBJID& objectID, eGameMasterLevel level);
Expand Down
11 changes: 11 additions & 0 deletions dGame/dUtilities/SlashCommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,17 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
});
}

if (chatCommand == "resetmission") {
uint32_t missionId;
if (!GeneralUtils::TryParse(args[0], missionId)) {
ChatPackets::SendSystemMessage(sysAddr, u"Invalid mission ID.");
return;
}
auto* missionComponent = entity->GetComponent<MissionComponent>();
if (!missionComponent) return;
missionComponent->ResetMission(missionId);
}

if (user->GetMaxGMLevel() == eGameMasterLevel::CIVILIAN || entity->GetGMLevel() >= eGameMasterLevel::CIVILIAN) {
if (chatCommand == "die") {
entity->Smash(entity->GetObjectID());
Expand Down
2 changes: 1 addition & 1 deletion dNet/AuthPackets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd
server->Send(&packet, sysAddr, false);

//Inform the master server that we've created a session for this user:
{
if (responseCode == eLoginResponse::SUCCESS) {
CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SET_SESSION_KEY);
bitStream.Write(sessionKey);
Expand Down
3 changes: 3 additions & 0 deletions dScripts/02_server/Map/General/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL
"BaseInteractDropLootServer.cpp"
"Binoculars.cpp"
"ExplodingAsset.cpp"
"FrictionVolumeServer.cpp"
"ForceVolumeServer.cpp"
"GrowingFlower.cpp"
"ImaginationBackpackHealServer.cpp"
Expand All @@ -17,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
19 changes: 19 additions & 0 deletions dScripts/02_server/Map/General/FrictionVolumeServer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "FrictionVolumeServer.h"
#include "PhantomPhysicsComponent.h"
#include "ePhysicsEffectType.h"
#include "Game.h"
#include "EntityManager.h"

void FrictionVolumeServer::OnStartup(Entity* self) {
auto frictionAmount = self->GetVar<float>(u"FrictionAmt");
if (frictionAmount == 0.0f) frictionAmount = DefaultFrictionAmount;

auto* phantomPhysicsComponent = self->GetComponent<PhantomPhysicsComponent>();
if (!phantomPhysicsComponent) return;

phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::FRICTION);
phantomPhysicsComponent->SetDirectionalMultiplier(frictionAmount);
phantomPhysicsComponent->SetPhysicsEffectActive(true);

Game::entityManager->SerializeEntity(self);
}
13 changes: 13 additions & 0 deletions dScripts/02_server/Map/General/FrictionVolumeServer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef __FRICTIONVOLUMESERVER__H__
#define __FRICTIONVOLUMESERVER__H__

#include "CppScripts.h"

class FrictionVolumeServer : public CppScripts::Script {
public:
void OnStartup(Entity* self) override;
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__
3 changes: 3 additions & 0 deletions dScripts/02_server/Map/NT/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_NT
"NtXRayServer.cpp"
"NtSleepingGuard.cpp"
"NtImagimeterVisibility.cpp"
"NTPipeVisibilityServer.cpp"
"NtSentinelWalkwayServer.cpp"
"NtDarkitectRevealServer.cpp"
"NtParadoxTeleServer.cpp"
"NtVentureSpeedPadServer.cpp"
"NtVentureCannonServer.cpp"
"NtBcSubmitServer.cpp"
"NtNaomiBreadcrumbServer.cpp"
PARENT_SCOPE)
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__
34 changes: 34 additions & 0 deletions dScripts/02_server/Map/NT/NtBcSubmitServer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "NtBcSubmitServer.h"

#include <cstdint>
#include <map>

#include "Entity.h"
#include "MissionComponent.h"

// https://explorer.lu/missions/
// Key is the main mission, value is the breadcrumb mission to reset upon Mission Dialogue Ok.
// To see the actual missions, just append the number to the end of the URL.
namespace {
std::map<uint32_t, uint32_t> ResetMissionsTable = {
{999, 1335},
{1002, 1355},
{1006, 1349},
{1009, 1348},
{1379, 1335},
{1380, 1355},
{1378, 1349},
{1377, 1348},
};
}

void NtBcSubmitServer::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) {
auto* missionComponent = target->GetComponent<MissionComponent>();
if (!missionComponent) return;

auto it = ResetMissionsTable.find(missionID);
if (it == ResetMissionsTable.end()) return;

const auto missionToReset = it->second;
missionComponent->ResetMission(missionToReset);
}
11 changes: 11 additions & 0 deletions dScripts/02_server/Map/NT/NtBcSubmitServer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef __NTBCSUBMITSERVER__H__
#define __NTBCSUBMITSERVER__H__

#include "CppScripts.h"

class NtBcSubmitServer : public virtual CppScripts::Script {
public:
void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) override;
};

#endif //!__NTBCSUBMITSERVER__H__
1 change: 1 addition & 0 deletions dScripts/02_server/Map/NT/NtDukeServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ void NtDukeServer::OnMissionDialogueOK(Entity* self, Entity* target, int mission
inventoryComponent->RemoveItem(m_SwordLot, lotCount);
}
}
NtBcSubmitServer::OnMissionDialogueOK(self, target, missionID, missionState);
}
3 changes: 2 additions & 1 deletion dScripts/02_server/Map/NT/NtDukeServer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once
#include "NtFactionSpyServer.h"
#include "NtBcSubmitServer.h"

class NtDukeServer : public NtFactionSpyServer {
class NtDukeServer : public NtFactionSpyServer, public NtBcSubmitServer {
void SetVariables(Entity* self) override;
void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) override;
const uint32_t m_SwordMissionID = 1448;
Expand Down
3 changes: 2 additions & 1 deletion dScripts/02_server/Map/NT/NtHaelServer.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include "NtFactionSpyServer.h"
#include "NtBcSubmitServer.h"

class NtHaelServer : public NtFactionSpyServer {
class NtHaelServer : public NtFactionSpyServer, public NtBcSubmitServer {
void SetVariables(Entity* self) override;
};
Loading

0 comments on commit c1e8546

Please sign in to comment.