Merge branch 'main' into movingPlatformWork

This commit is contained in:
David Markowitz
2024-02-10 19:10:55 -08:00
810 changed files with 18865 additions and 15976 deletions

View File

@@ -22,7 +22,7 @@ void BaseInteractDropLootServer::BaseUse(Entity* self, Entity* user) {
self->SetNetworkVar(u"bInUse", true);
LootGenerator::Instance().DropLoot(user, self, lootMatrix, 0, 0);
Loot::DropLoot(user, self, lootMatrix, 0, 0);
self->AddCallbackTimer(cooldownTime, [this, self]() {
self->SetNetworkVar(u"bInUse", false);

View File

@@ -3,10 +3,10 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL
"BaseInteractDropLootServer.cpp"
"Binoculars.cpp"
"ExplodingAsset.cpp"
"FrictionVolumeServer.cpp"
"ForceVolumeServer.cpp"
"GrowingFlower.cpp"
"ImaginationBackpackHealServer.cpp"
"InvalidScript.cpp"
"MailBoxServer.cpp"
"NjRailSwitch.cpp"
"PetDigServer.cpp"
@@ -17,6 +17,8 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL
"StoryBoxInteractServer.cpp"
"TokenConsoleServer.cpp"
"TouchMissionUpdateServer.cpp"
"VisToggleNotifierServer.cpp"
"NTNaomiDirtServer.cpp"
"WishingWellServer.cpp")
add_subdirectory(Ninjago)
@@ -25,4 +27,6 @@ foreach(file ${DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL_NINJAGO})
set(DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL ${DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL} "Ninjago/${file}")
endforeach()
set(DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL ${DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL} PARENT_SCOPE)
add_library(dScriptsServerMapGeneral ${DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL})
target_include_directories(dScriptsServerMapGeneral PUBLIC "." "Ninjago")
target_precompile_headers(dScriptsServerMapGeneral REUSE_FROM dScriptsBase)

View File

@@ -4,6 +4,8 @@
#include "MissionComponent.h"
#include "SkillComponent.h"
#include "eMissionTaskType.h"
#include "CDClientManager.h"
#include "CDObjectSkillsTable.h"
#include "RenderComponent.h"
//TODO: this has to be updated so that you only get killed if you're in a certain radius.
@@ -39,9 +41,11 @@ void ExplodingAsset::OnHit(Entity* self, Entity* attacker) {
self->SetOwnerOverride(attacker->GetObjectID());
GameMessages::SendPlayEmbeddedEffectOnAllClientsNearObject(self, u"camshake", self->GetObjectID(), 16);
self->Smash(attacker->GetObjectID());
auto* skillComponent = self->GetComponent<SkillComponent>();
if (skillComponent != nullptr) {
// Technically supposed to get first skill in the skill component but only 1 object in the live game used this.
skillComponent->CalculateBehavior(147, 4721, LWOOBJID_EMPTY, true);
}
@@ -65,8 +69,6 @@ void ExplodingAsset::OnHit(Entity* self, Entity* attacker) {
}
}
}
self->ScheduleKillAfterUpdate();
}
void ExplodingAsset::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {

View File

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

View File

@@ -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__

View File

@@ -13,7 +13,7 @@ void GrowingFlower::OnSkillEventFired(Entity* self, Entity* target, const std::s
const auto mission1 = self->GetVar<int32_t>(u"missionID");
const auto mission2 = self->GetVar<int32_t>(u"missionID2");
LootGenerator::Instance().DropActivityLoot(target, self, self->GetLOT(), 0);
Loot::DropActivityLoot(target, self, self->GetLOT(), 0);
auto* missionComponent = target->GetComponent<MissionComponent>();
if (missionComponent != nullptr) {

View File

@@ -1 +0,0 @@
#include "InvalidScript.h"

View File

@@ -1,6 +0,0 @@
#pragma once
#include "CppScripts.h"
class InvalidScript : public CppScripts::Script
{
};

View File

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

View File

@@ -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__

View File

@@ -1,13 +1,13 @@
#include "NjRailActivatorsServer.h"
#include "RebuildComponent.h"
#include "QuickBuildComponent.h"
#include "Character.h"
void NjRailActivatorsServer::OnUse(Entity* self, Entity* user) {
const auto flag = self->GetVar<int32_t>(u"RailFlagNum");
auto* rebuildComponent = self->GetComponent<RebuildComponent>();
auto* quickBuildComponent = self->GetComponent<QuickBuildComponent>();
// Only allow use if this is not a quick build or the quick build is built
if (rebuildComponent == nullptr || rebuildComponent->GetState() == eRebuildState::COMPLETED) {
if (quickBuildComponent == nullptr || quickBuildComponent->GetState() == eQuickBuildState::COMPLETED) {
auto* character = user->GetCharacter();
if (character != nullptr) {
character->SetPlayerFlag(flag, true);

View File

@@ -1,10 +1,10 @@
#include "NjRailPostServer.h"
#include "RebuildComponent.h"
#include "QuickBuildComponent.h"
#include "EntityManager.h"
void NjRailPostServer::OnStartup(Entity* self) {
auto* rebuildComponent = self->GetComponent<RebuildComponent>();
if (rebuildComponent != nullptr) {
auto* quickBuildComponent = self->GetComponent<QuickBuildComponent>();
if (quickBuildComponent != nullptr) {
self->SetNetworkVar<bool>(NetworkNotActiveVariable, true);
}
}
@@ -18,8 +18,8 @@ void NjRailPostServer::OnNotifyObject(Entity* self, Entity* sender, const std::s
}
}
void NjRailPostServer::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == eRebuildState::COMPLETED) {
void NjRailPostServer::OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) {
if (state == eQuickBuildState::COMPLETED) {
auto* relatedRail = GetRelatedRail(self);
if (relatedRail == nullptr)
return;
@@ -30,7 +30,7 @@ void NjRailPostServer::OnRebuildNotifyState(Entity* self, eRebuildState state) {
return;
self->SetNetworkVar(NetworkNotActiveVariable, false);
} else if (state == eRebuildState::RESETTING) {
} else if (state == eQuickBuildState::RESETTING) {
auto* relatedRail = GetRelatedRail(self);
if (relatedRail == nullptr)
return;

View File

@@ -4,7 +4,7 @@
class NjRailPostServer : public CppScripts::Script {
void OnStartup(Entity* self) override;
void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) override;
void OnRebuildNotifyState(Entity* self, eRebuildState state) override;
void OnQuickBuildNotifyState(Entity* self, eQuickBuildState state) override;
private:
Entity* GetRelatedRail(Entity* self);
const std::u16string NetworkNotActiveVariable = u"NetworkNotActive";

View File

@@ -107,7 +107,7 @@ void PetDigServer::HandleXBuildDig(const Entity* self, Entity* owner, Entity* pe
return;
auto* playerEntity = Game::entityManager->GetEntity(playerID);
if (!playerEntity || !playerEntity->GetParentUser() || !playerEntity->GetParentUser()->GetLastUsedChar())
if (!playerEntity || !playerEntity->GetCharacter())
return;
auto* player = playerEntity->GetCharacter();

View File

@@ -11,7 +11,7 @@ void PropertyDevice::OnStartup(Entity* self) {
}
}
void PropertyDevice::OnRebuildComplete(Entity* self, Entity* target) {
void PropertyDevice::OnQuickBuildComplete(Entity* self, Entity* target) {
auto propertyOwnerID = self->GetNetworkVar<std::string>(m_PropertyOwnerVariable);
if (propertyOwnerID == std::to_string(LWOOBJID_EMPTY))
return;

View File

@@ -3,7 +3,7 @@
class PropertyDevice : public CppScripts::Script {
void OnStartup(Entity* self) override;
void OnRebuildComplete(Entity* self, Entity* target) override;
void OnQuickBuildComplete(Entity* self, Entity* target) override;
const std::u16string m_PropertyOwnerVariable = u"PropertyOwnerID";
const uint32_t m_PropertyMissionID = 1291;
};

View File

@@ -1,5 +1,5 @@
#include "PropertyPlatform.h"
#include "RebuildComponent.h"
#include "QuickBuildComponent.h"
#include "GameMessages.h"
#include "MovingPlatformComponent.h"

View File

@@ -4,7 +4,7 @@
class PropertyPlatform : public CppScripts::Script {
public:
void OnUse(Entity* self, Entity* user) override;
void OnRebuildComplete(Entity* self, Entity* target) override;
void OnQuickBuildComplete(Entity* self, Entity* target) override;
private:
float_t movementDelay = 10.0f;
float_t effectDelay = 5.0f;

View File

@@ -6,7 +6,7 @@
#include "CDObjectSkillsTable.h"
#include "CDSkillBehaviorTable.h"
void QbEnemyStunner::OnRebuildComplete(Entity* self, Entity* target) {
void QbEnemyStunner::OnQuickBuildComplete(Entity* self, Entity* target) {
auto* destroyable = self->GetComponent<DestroyableComponent>();
if (destroyable != nullptr) {
@@ -17,12 +17,12 @@ void QbEnemyStunner::OnRebuildComplete(Entity* self, Entity* target) {
if (!skillComponent) return;
// Get the skill IDs of this object.
CDObjectSkillsTable* skillsTable = CDClientManager::Instance().GetTable<CDObjectSkillsTable>();
CDObjectSkillsTable* skillsTable = CDClientManager::GetTable<CDObjectSkillsTable>();
auto skills = skillsTable->Query([=](CDObjectSkills entry) {return (entry.objectTemplate == self->GetLOT()); });
std::map<uint32_t, uint32_t> skillBehaviorMap;
// For each skill, cast it with the associated behavior ID.
for (auto skill : skills) {
CDSkillBehaviorTable* skillBehaviorTable = CDClientManager::Instance().GetTable<CDSkillBehaviorTable>();
CDSkillBehaviorTable* skillBehaviorTable = CDClientManager::GetTable<CDSkillBehaviorTable>();
CDSkillBehavior behaviorData = skillBehaviorTable->GetSkillByID(skill.skillID);
skillBehaviorMap.insert(std::make_pair(skill.skillID, behaviorData.behaviorID));

View File

@@ -4,6 +4,6 @@
class QbEnemyStunner : public CppScripts::Script
{
public:
void OnRebuildComplete(Entity* self, Entity* target) override;
void OnQuickBuildComplete(Entity* self, Entity* target) override;
void OnTimerDone(Entity* self, std::string timerName) override;
};

View File

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

View File

@@ -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__

View File

@@ -21,7 +21,7 @@ void WishingWellServer::OnUse(Entity* self, Entity* user) {
GameMessages::SendPlayNDAudioEmitter(self, user->GetSystemAddress(), audio);
}
LootGenerator::Instance().DropActivityLoot(
Loot::DropActivityLoot(
user,
self,
static_cast<uint32_t>(scriptedActivity->GetActivityID()),