Merge branch 'main' into fix/cmake-libs-2

This commit is contained in:
David Markowitz
2024-03-03 04:17:27 -08:00
committed by GitHub
475 changed files with 5755 additions and 6213 deletions

View File

@@ -1,3 +1,3 @@
set(DSCRIPTS_SOURCES_02_SERVER_DLU
"DLUVanityNPC.cpp"
"DLUVanityTeleportingObject.cpp"
PARENT_SCOPE)

View File

@@ -1,24 +1,21 @@
#include "DLUVanityNPC.h"
#include "DLUVanityTeleportingObject.h"
#include "GameMessages.h"
#include "dServer.h"
#include "VanityUtilities.h"
#include "RenderComponent.h"
void DLUVanityNPC::OnStartup(Entity* self) {
m_NPC = VanityUtilities::GetNPC("averysumner - Destroyer of Worlds");
void DLUVanityTeleportingObject::OnStartup(Entity* self) {
if (!self->HasVar(u"npcName")) return;
if (m_NPC == nullptr) {
return;
}
m_Object = VanityUtilities::GetObject(self->GetVarAsString(u"npcName"));
if (!m_Object) return;
if (self->HasVar(u"teleportInterval")) m_TeleportInterval = self->GetVar<float>(u"teleportInterval");
if (self->GetVar<bool>(u"teleport")) {
self->AddTimer("setupTeleport", 15.0f);
}
self->AddTimer("setupTeleport", m_TeleportInterval);
}
void DLUVanityNPC::OnTimerDone(Entity* self, std::string timerName) {
void DLUVanityTeleportingObject::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "setupTeleport") {
RenderComponent::PlayAnimation(self, u"interact");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportBeam", "teleportBeam");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportRings", "teleportRings");
@@ -28,13 +25,14 @@ void DLUVanityNPC::OnTimerDone(Entity* self, std::string timerName) {
GameMessages::SendStopFXEffect(self, true, "teleportBeam");
GameMessages::SendStopFXEffect(self, true, "teleportRings");
} else if (timerName == "teleport") {
std::vector<VanityNPCLocation>& locations = m_NPC->m_Locations[Game::server->GetZoneID()];
std::vector<VanityObjectLocation>& locations = m_Object->m_Locations[Game::server->GetZoneID()];
selectLocation:
VanityNPCLocation& newLocation = locations[GeneralUtils::GenerateRandomNumber<size_t>(0, locations.size() - 1)];
VanityObjectLocation& newLocation = locations[GeneralUtils::GenerateRandomNumber<size_t>(0, locations.size() - 1)];
// try to get not the same position, but if we get the same one twice, it's fine
if (self->GetPosition() == newLocation.m_Position) {
goto selectLocation; // cry about it
VanityObjectLocation& newLocation = locations[GeneralUtils::GenerateRandomNumber<size_t>(0, locations.size() - 1)];
}
self->SetPosition(newLocation.m_Position);
@@ -42,6 +40,6 @@ void DLUVanityNPC::OnTimerDone(Entity* self, std::string timerName) {
GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportBeam", "teleportBeam");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportRings", "teleportRings");
self->AddTimer("stopFX", 2.0f);
self->AddTimer("setupTeleport", 15.0f);
self->AddTimer("setupTeleport", m_TeleportInterval);
}
}

View File

@@ -1,13 +1,14 @@
#pragma once
#include "CppScripts.h"
class VanityNPC;
class DLUVanityNPC : public CppScripts::Script
class VanityObject;
class DLUVanityTeleportingObject : public CppScripts::Script
{
public:
void OnStartup(Entity* self) override;
void OnTimerDone(Entity* self, std::string timerName) override;
private:
VanityNPC* m_NPC;
VanityObject* m_Object;
float m_TeleportInterval = 15.0f;
};

View File

@@ -85,7 +85,7 @@ void BossSpiderQueenEnemyServer::WithdrawSpider(Entity* self, const bool withdra
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"SetColGroup", 10, 0, 0, "", UNASSIGNED_SYSTEM_ADDRESS);
//First rotate for anim
NiQuaternion rot = NiQuaternion::IDENTITY;
NiQuaternion rot = NiQuaternionConstant::IDENTITY;
controllable->SetStatic(false);
@@ -179,7 +179,7 @@ void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) {
std::vector<LWOOBJID> spiderEggs{};
auto spooders = Game::entityManager->GetEntitiesInGroup("EGG");
auto spooders = Game::entityManager->GetEntitiesInGroup("SpiderEggs");
for (auto spodder : spooders) {
spiderEggs.push_back(spodder->GetObjectID());
}
@@ -402,7 +402,7 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
const auto withdrawn = self->GetBoolean(u"isWithdrawn");
if (!withdrawn) return;
NiQuaternion rot = NiQuaternion::IDENTITY;
NiQuaternion rot = NiQuaternionConstant::IDENTITY;
//First rotate for anim
controllable->SetStatic(false);
@@ -597,12 +597,12 @@ void BossSpiderQueenEnemyServer::OnUpdate(Entity* self) {
if (!isWithdrawn) return;
if (controllable->GetRotation() == NiQuaternion::IDENTITY) {
if (controllable->GetRotation() == NiQuaternionConstant::IDENTITY) {
return;
}
controllable->SetStatic(false);
controllable->SetRotation(NiQuaternion::IDENTITY);
controllable->SetRotation(NiQuaternionConstant::IDENTITY);
controllable->SetStatic(true);
Game::entityManager->SerializeEntity(self);

View File

@@ -13,7 +13,7 @@ void AgLaserSensorServer::OnStartup(Entity* self) {
phantomPhysicsComponent->SetPhysicsEffectActive(true);
phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::REPULSE);
phantomPhysicsComponent->SetDirectionalMultiplier(repelForce);
phantomPhysicsComponent->SetDirection(NiPoint3::UNIT_Y);
phantomPhysicsComponent->SetDirection(NiPoint3Constant::UNIT_Y);
}

View File

@@ -1,6 +1,7 @@
#include "NpcCowboyServer.h"
#include "eMissionState.h"
#include "InventoryComponent.h"
#include "dZoneManager.h"
void NpcCowboyServer::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) {
if (missionID != 1880) {
@@ -23,4 +24,17 @@ void NpcCowboyServer::OnMissionDialogueOK(Entity* self, Entity* target, int miss
} else if (missionState == eMissionState::READY_TO_COMPLETE || missionState == eMissionState::COMPLETE_READY_TO_COMPLETE) {
inventoryComponent->RemoveItem(14378, 1);
}
// Next up hide or show the samples based on the mission state
int32_t visible = 1;
if (missionState == eMissionState::READY_TO_COMPLETE || missionState == eMissionState::COMPLETE_READY_TO_COMPLETE) {
visible = 0;
}
auto spawners = Game::zoneManager->GetSpawnersByName("PlungerGunTargets");
for (auto* spawner : spawners) {
for (const auto entity : spawner->GetSpawnedObjectIDs())
GameMessages::SendNotifyClientObject(entity, u"SetVisibility", visible, 0,
target->GetObjectID(), "", target->GetSystemAddress());
}
}

View File

@@ -1,9 +1,10 @@
#include "NpcWispServer.h"
#include "InventoryComponent.h"
#include "EntityManager.h"
#include "dZoneManager.h"
#include "Entity.h"
#include "GameMessages.h"
#include "eMissionState.h"
#include "Spawner.h"
void NpcWispServer::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) {
if (missionID != 1849 && missionID != 1883)
@@ -25,7 +26,7 @@ void NpcWispServer::OnMissionDialogueOK(Entity* self, Entity* target, int missio
}
// Next up hide or show the samples based on the mission state
auto visible = 1;
int32_t visible = 1;
if (missionState == eMissionState::READY_TO_COMPLETE || missionState == eMissionState::COMPLETE_READY_TO_COMPLETE) {
visible = 0;
}
@@ -35,9 +36,10 @@ void NpcWispServer::OnMissionDialogueOK(Entity* self, Entity* target, int missio
: std::vector<std::string>{ "MaelstromSamples", "MaelstromSamples2ndary1", "MaelstromSamples2ndary2" };
for (const auto& group : groups) {
auto samples = Game::entityManager->GetEntitiesInGroup(group);
for (auto* sample : samples) {
GameMessages::SendNotifyClientObject(sample->GetObjectID(), u"SetVisibility", visible, 0,
auto spawners = Game::zoneManager->GetSpawnersByName(group);
for (const auto* spawner : spawners) {
for (const auto objId : spawner->GetSpawnedObjectIDs())
GameMessages::SendNotifyClientObject(objId, u"SetVisibility", visible, 0,
target->GetObjectID(), "", target->GetSystemAddress());
}
}

View File

@@ -66,7 +66,7 @@ void AmDrawBridge::OnTimerDone(Entity* self, std::string timerName) {
return;
}
simplePhysicsComponent->SetAngularVelocity(NiPoint3::ZERO);
simplePhysicsComponent->SetAngularVelocity(NiPoint3Constant::ZERO);
Game::entityManager->SerializeEntity(bridge);
}

View File

@@ -12,16 +12,12 @@ void AmDropshipComputer::OnStartup(Entity* self) {
void AmDropshipComputer::OnUse(Entity* self, Entity* user) {
auto* quickBuildComponent = self->GetComponent<QuickBuildComponent>();
if (quickBuildComponent == nullptr || quickBuildComponent->GetState() != eQuickBuildState::COMPLETED) {
return;
}
if (!quickBuildComponent || quickBuildComponent->GetState() != eQuickBuildState::COMPLETED) return;
auto* missionComponent = user->GetComponent<MissionComponent>();
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
if (missionComponent == nullptr || inventoryComponent == nullptr) {
return;
}
if (!missionComponent || !inventoryComponent) return;
if (inventoryComponent->GetLotCount(m_NexusTalonDataCard) != 0 || missionComponent->GetMission(979)->GetMissionState() == eMissionState::COMPLETE) {
return;
@@ -33,14 +29,12 @@ void AmDropshipComputer::OnUse(Entity* self, Entity* user) {
void AmDropshipComputer::OnDie(Entity* self, Entity* killer) {
const auto myGroup = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"spawner_name"));
int32_t pipeNum = 0;
if (!GeneralUtils::TryParse<int32_t>(myGroup.substr(10, 1), pipeNum)) {
return;
}
const auto pipeNum = GeneralUtils::TryParse<int32_t>(myGroup.substr(10, 1));
if (!pipeNum) return;
const auto pipeGroup = myGroup.substr(0, 10);
const auto nextPipeNum = pipeNum + 1;
const auto nextPipeNum = pipeNum.value() + 1;
const auto samePipeSpawners = Game::zoneManager->GetSpawnersByName(myGroup);
@@ -70,11 +64,9 @@ void AmDropshipComputer::OnDie(Entity* self, Entity* killer) {
}
void AmDropshipComputer::OnTimerDone(Entity* self, std::string timerName) {
auto* quickBuildComponent = self->GetComponent<QuickBuildComponent>();
const auto* const quickBuildComponent = self->GetComponent<QuickBuildComponent>();
if (quickBuildComponent == nullptr) {
return;
}
if (!quickBuildComponent) return;
if (timerName == "reset" && quickBuildComponent->GetState() == eQuickBuildState::OPEN) {
self->Smash(self->GetObjectID(), eKillType::SILENT);

View File

@@ -144,13 +144,10 @@ void AmSkullkinTower::OnChildRemoved(Entity* self, Entity* child) {
);
for (const auto& mission : missions) {
int32_t missionID = 0;
const auto missionID = GeneralUtils::TryParse<int32_t>(mission);
if (!missionID) continue;
if (!GeneralUtils::TryParse(mission, missionID)) {
continue;
}
missionIDs.push_back(missionID);
missionIDs.push_back(missionID.value());
}
}

View File

@@ -12,12 +12,9 @@ void AmTemplateSkillVolume::OnSkillEventFired(Entity* self, Entity* caster, cons
const auto missionIDs = GeneralUtils::SplitString(missionIDsVariable, '_');
for (const auto& missionIDStr : missionIDs) {
int32_t missionID = 0;
const auto missionID = GeneralUtils::TryParse<uint32_t>(missionIDStr);
if (!missionID) continue;
if (!GeneralUtils::TryParse(missionIDStr, missionID)) {
continue;
}
missionComponent->ForceProgressTaskType(missionID, 1, 1, false);
missionComponent->ForceProgressTaskType(missionID.value(), 1, 1, false);
}
}

View File

@@ -15,7 +15,9 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_AM
"AmSkullkinDrillStand.cpp"
"AmSkullkinTower.cpp"
"AmBlueX.cpp"
"AmTeapotServer.cpp")
"AmTeapotServer.cpp"
"WanderingVendor.cpp"
)
add_library(dScriptsServerMapAM OBJECT ${DSCRIPTS_SOURCES_02_SERVER_MAP_AM})
target_include_directories(dScriptsServerMapAM PUBLIC ".")

View File

@@ -0,0 +1,33 @@
#include "WanderingVendor.h"
#include "MovementAIComponent.h"
#include "ProximityMonitorComponent.h"
void WanderingVendor::OnStartup(Entity* self) {
auto movementAIComponent = self->GetComponent<MovementAIComponent>();
if (!movementAIComponent) return;
// movementAIComponent->Resume();
self->SetProximityRadius(10, "playermonitor");
}
void WanderingVendor::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
if (status == "ENTER" && entering->IsPlayer()) {
auto movementAIComponent = self->GetComponent<MovementAIComponent>();
if (!movementAIComponent) return;
// movementAIComponent->Pause();
self->CancelTimer("startWalking");
} else if (status == "LEAVE") {
auto* proximityMonitorComponent = self->GetComponent<ProximityMonitorComponent>();
if (!proximityMonitorComponent) self->AddComponent<ProximityMonitorComponent>();
const auto proxObjs = proximityMonitorComponent->GetProximityObjects("playermonitor");
if (proxObjs.empty()) self->AddTimer("startWalking", 1.5);
}
}
void WanderingVendor::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "startWalking") {
auto movementAIComponent = self->GetComponent<MovementAIComponent>();
if (!movementAIComponent) return;
// movementAIComponent->Resume();
}
}

View File

@@ -0,0 +1,13 @@
#ifndef __WANDERINGVENDOR__H__
#define __WANDERINGVENDOR__H__
#include "CppScripts.h"
class WanderingVendor : public CppScripts::Script {
public:
void OnStartup(Entity* self) override;
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override;
void OnTimerDone(Entity* self, std::string timerName) override;
};
#endif //!__WANDERINGVENDOR__H__

View File

@@ -81,7 +81,7 @@ void MastTeleport::OnTimerDone(Entity* self, std::string timerName) {
GameMessages::SendOrientToAngle(playerId, true, rads, player->GetSystemAddress());
GameMessages::SendTeleport(playerId, position, NiQuaternion::IDENTITY, player->GetSystemAddress());
GameMessages::SendTeleport(playerId, position, NiQuaternionConstant::IDENTITY, player->GetSystemAddress());
GameMessages::SendSetStunned(playerId, eStateChangeType::POP, player->GetSystemAddress(),
LWOOBJID_EMPTY, true, true, true, true, true, true, true

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

@@ -17,12 +17,12 @@ void QbEnemyStunner::OnQuickBuildComplete(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

@@ -40,6 +40,6 @@ void PetFromDigServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eP
return;
// TODO: Remove custom group?
// Command the pet to the player as it may otherwise go to its spawn point which is non existant
// petComponent->Command(NiPoint3::ZERO, LWOOBJID_EMPTY, 6, 202, true);
// petComponent->Command(NiPoint3Constant::ZERO, LWOOBJID_EMPTY, 6, 202, true);
}
}