mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-15 04:38:21 +00:00
this took 4 eons to get compiling again
Update Zone.cpp Update Zone.h Update Zone.h Update MovingPlatformComponent.cpp Update ProximityMonitorComponent.cpp quick cleanup Use correct logging
This commit is contained in:
parent
6863ee9d76
commit
772ac06e94
@ -19,7 +19,7 @@ INCLUDE_BACKTRACE=0
|
|||||||
COMPILE_BACKTRACE=0
|
COMPILE_BACKTRACE=0
|
||||||
|
|
||||||
# Set to the number of jobs (make -j equivalent) to compile the mariadbconn files with.
|
# Set to the number of jobs (make -j equivalent) to compile the mariadbconn files with.
|
||||||
MARIADB_CONNECTOR_COMPILE_JOBS=1
|
MARIADB_CONNECTOR_COMPILE_JOBS=
|
||||||
|
|
||||||
# When set to 1 and uncommented, compiling and linking testing folders and libraries will be done.
|
# When set to 1 and uncommented, compiling and linking testing folders and libraries will be done.
|
||||||
ENABLE_TESTING=1
|
ENABLE_TESTING=1
|
||||||
|
@ -2125,9 +2125,7 @@ void Entity::ProcessPositionUpdate(PositionUpdate& update) {
|
|||||||
possessedControllablePhysicsComponent->SetIsOnGround(update.onGround);
|
possessedControllablePhysicsComponent->SetIsOnGround(update.onGround);
|
||||||
possessedControllablePhysicsComponent->SetIsOnRail(update.onRail);
|
possessedControllablePhysicsComponent->SetIsOnRail(update.onRail);
|
||||||
possessedControllablePhysicsComponent->SetVelocity(update.velocity);
|
possessedControllablePhysicsComponent->SetVelocity(update.velocity);
|
||||||
possessedControllablePhysicsComponent->SetDirtyVelocity(update.velocity != NiPoint3Constant::ZERO);
|
|
||||||
possessedControllablePhysicsComponent->SetAngularVelocity(update.angularVelocity);
|
possessedControllablePhysicsComponent->SetAngularVelocity(update.angularVelocity);
|
||||||
possessedControllablePhysicsComponent->SetDirtyAngularVelocity(update.angularVelocity != NiPoint3Constant::ZERO);
|
|
||||||
}
|
}
|
||||||
Game::entityManager->SerializeEntity(possassableEntity);
|
Game::entityManager->SerializeEntity(possassableEntity);
|
||||||
}
|
}
|
||||||
@ -2149,9 +2147,7 @@ void Entity::ProcessPositionUpdate(PositionUpdate& update) {
|
|||||||
controllablePhysicsComponent->SetIsOnGround(update.onGround);
|
controllablePhysicsComponent->SetIsOnGround(update.onGround);
|
||||||
controllablePhysicsComponent->SetIsOnRail(update.onRail);
|
controllablePhysicsComponent->SetIsOnRail(update.onRail);
|
||||||
controllablePhysicsComponent->SetVelocity(update.velocity);
|
controllablePhysicsComponent->SetVelocity(update.velocity);
|
||||||
controllablePhysicsComponent->SetDirtyVelocity(update.velocity != NiPoint3Constant::ZERO);
|
|
||||||
controllablePhysicsComponent->SetAngularVelocity(update.angularVelocity);
|
controllablePhysicsComponent->SetAngularVelocity(update.angularVelocity);
|
||||||
controllablePhysicsComponent->SetDirtyAngularVelocity(update.angularVelocity != NiPoint3Constant::ZERO);
|
|
||||||
|
|
||||||
auto* ghostComponent = GetComponent<GhostComponent>();
|
auto* ghostComponent = GetComponent<GhostComponent>();
|
||||||
if (ghostComponent) ghostComponent->SetGhostReferencePoint(update.position);
|
if (ghostComponent) ghostComponent->SetGhostReferencePoint(update.position);
|
||||||
|
@ -22,7 +22,6 @@ ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Phy
|
|||||||
m_IsOnGround = true;
|
m_IsOnGround = true;
|
||||||
m_IsOnRail = false;
|
m_IsOnRail = false;
|
||||||
m_DirtyVelocity = true;
|
m_DirtyVelocity = true;
|
||||||
m_DirtyAngularVelocity = true;
|
|
||||||
m_dpEntity = nullptr;
|
m_dpEntity = nullptr;
|
||||||
m_Static = false;
|
m_Static = false;
|
||||||
m_SpeedMultiplier = 1;
|
m_SpeedMultiplier = 1;
|
||||||
@ -68,7 +67,7 @@ ControllablePhysicsComponent::~ControllablePhysicsComponent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::Update(float deltaTime) {
|
void ControllablePhysicsComponent::Update(float deltaTime) {
|
||||||
if (m_Velocity == NiPoint3::ZERO) return;
|
if (m_Velocity == NiPoint3Constant::ZERO) return;
|
||||||
SetPosition(m_Position + (m_Velocity * deltaTime));
|
SetPosition(m_Position + (m_Velocity * deltaTime));
|
||||||
Game::entityManager->SerializeEntity(m_Parent);
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
}
|
}
|
||||||
@ -117,8 +116,8 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
|||||||
if (!bIsInitialUpdate) m_DirtyBubble = false;
|
if (!bIsInitialUpdate) m_DirtyBubble = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isVelocityZero = m_Velocity != NiPoint3::ZERO;
|
bool isVelocityZero = m_Velocity != NiPoint3Constant::ZERO;
|
||||||
bool isAngularVelocityZero = m_AngularVelocity != NiPoint3::ZERO;
|
bool isAngularVelocityZero = m_AngularVelocity != NiPoint3Constant::ZERO;
|
||||||
bool shouldWriteFrameStats = m_DirtyPosition || bIsInitialUpdate || isVelocityZero || isAngularVelocityZero;
|
bool shouldWriteFrameStats = m_DirtyPosition || bIsInitialUpdate || isVelocityZero || isAngularVelocityZero;
|
||||||
outBitStream->Write(m_DirtyPosition || bIsInitialUpdate);
|
outBitStream->Write(m_DirtyPosition || bIsInitialUpdate);
|
||||||
if (m_DirtyPosition || bIsInitialUpdate) {
|
if (m_DirtyPosition || bIsInitialUpdate) {
|
||||||
|
@ -67,7 +67,7 @@ void HavokVehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
|||||||
outBitStream->Write(m_IsOnGround);
|
outBitStream->Write(m_IsOnGround);
|
||||||
outBitStream->Write(m_IsOnRail);
|
outBitStream->Write(m_IsOnRail);
|
||||||
|
|
||||||
bool isVelocityZero = m_Velocity == NiPoint3::ZERO;
|
bool isVelocityZero = m_Velocity == NiPoint3Constant::ZERO;
|
||||||
|
|
||||||
outBitStream->Write(isVelocityZero);
|
outBitStream->Write(isVelocityZero);
|
||||||
if (isVelocityZero) {
|
if (isVelocityZero) {
|
||||||
@ -76,7 +76,7 @@ void HavokVehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
|||||||
outBitStream->Write(m_Velocity.z);
|
outBitStream->Write(m_Velocity.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAngularVelocityZero = m_AngularVelocity == NiPoint3::ZERO;
|
bool isAngularVelocityZero = m_AngularVelocity == NiPoint3Constant::ZERO;
|
||||||
outBitStream->Write(isAngularVelocityZero);
|
outBitStream->Write(isAngularVelocityZero);
|
||||||
if (isAngularVelocityZero) {
|
if (isAngularVelocityZero) {
|
||||||
outBitStream->Write(m_AngularVelocity.x);
|
outBitStream->Write(m_AngularVelocity.x);
|
||||||
|
@ -73,30 +73,30 @@ float MovementAIComponent::GetCurrentPathWaypointSpeed() const {
|
|||||||
|
|
||||||
void MovementAIComponent::SetupPath(const std::string& pathname) {
|
void MovementAIComponent::SetupPath(const std::string& pathname) {
|
||||||
std::string path = pathname;
|
std::string path = pathname;
|
||||||
if (path.empty()) path = m_Parent->GetVarAsString(u"attached_path");
|
|
||||||
if (path.empty()) {
|
if (path.empty()) {
|
||||||
Game::logger->Log("MovementAIComponent", "No path to load for %i:%llu", m_Parent->GetLOT(), m_Parent->GetObjectID());
|
path = m_Parent->GetVarAsString(u"attached_path");
|
||||||
|
if (path.empty()) {
|
||||||
|
LOG("No path to load for %i:%llu", m_Parent->GetLOT(), m_Parent->GetObjectID());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
const Path* pathData = Game::zoneManager->GetZone()->GetPath(path);
|
const Path* pathData = Game::zoneManager->GetZone()->GetPath(path);
|
||||||
if (pathData) {
|
if (pathData) {
|
||||||
Game::logger->Log("MovementAIComponent", "found path %i %s", m_Parent->GetLOT(), path.c_str());
|
LOG("found path %i %s", m_Parent->GetLOT(), path.c_str());
|
||||||
m_Path = pathData;
|
m_Path = pathData;
|
||||||
if (!HasAttachedPathStart() && m_Parent->HasVar(u"attached_path_start")) m_StartingWaypointIndex = m_Parent->GetVar<uint32_t>(u"attached_path_start");
|
if (!HasAttachedPathStart() && m_Parent->HasVar(u"attached_path_start")) m_StartingWaypointIndex = m_Parent->GetVar<uint32_t>(u"attached_path_start");
|
||||||
if (m_Path && HasAttachedPathStart() && (m_StartingWaypointIndex < 0 || m_StartingWaypointIndex >= m_Path->pathWaypoints.size())) {
|
if (m_Path && HasAttachedPathStart() && (m_StartingWaypointIndex < 0 || m_StartingWaypointIndex >= m_Path->pathWaypoints.size())) {
|
||||||
Game::logger->Log(
|
LOG("WARNING: attached path start is out of bounds for %i:%llu, defaulting path start to 0",
|
||||||
"MovementAIComponent",
|
|
||||||
"WARNING: attached path start is out of bounds for %i:%llu, defaulting path start to 0",
|
|
||||||
m_Parent->GetLOT(), m_Parent->GetObjectID());
|
m_Parent->GetLOT(), m_Parent->GetObjectID());
|
||||||
m_StartingWaypointIndex = 0;
|
m_StartingWaypointIndex = 0;
|
||||||
}
|
}
|
||||||
std::vector<NiPoint3> waypoints;
|
std::vector<NiPoint3> waypoints;
|
||||||
for (auto& waypoint : m_Path->pathWaypoints) {
|
for (const auto& waypoint : m_Path->pathWaypoints) {
|
||||||
waypoints.push_back(waypoint.position);
|
waypoints.push_back(waypoint.position);
|
||||||
}
|
}
|
||||||
SetPath(waypoints);
|
SetPath(waypoints);
|
||||||
} else {
|
} else {
|
||||||
Game::logger->Log("MovementAIComponent", "No path found for %i:%llu", m_Parent->GetLOT(), m_Parent->GetObjectID());
|
LOG("No path found for %i:%llu", m_Parent->GetLOT(), m_Parent->GetObjectID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +270,7 @@ bool MovementAIComponent::Warp(const NiPoint3& point) {
|
|||||||
void MovementAIComponent::Pause() {
|
void MovementAIComponent::Pause() {
|
||||||
if (AtFinalWaypoint() || IsPaused()) return;
|
if (AtFinalWaypoint() || IsPaused()) return;
|
||||||
SetPosition(ApproximateLocation());
|
SetPosition(ApproximateLocation());
|
||||||
SetVelocity(NiPoint3::ZERO);
|
SetVelocity(NiPoint3Constant::ZERO);
|
||||||
|
|
||||||
// Clear this as we may be somewhere else when we resume movement.
|
// Clear this as we may be somewhere else when we resume movement.
|
||||||
m_InterpolatedWaypoints.clear();
|
m_InterpolatedWaypoints.clear();
|
||||||
@ -325,7 +325,7 @@ const NiPoint3& MovementAIComponent::GetCurrentPathWaypoint() const {
|
|||||||
return m_CurrentPath.at(m_CurrentPathWaypointIndex);
|
return m_CurrentPath.at(m_CurrentPathWaypointIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovementAIComponent::SetPath(std::vector<NiPoint3> path, bool startInReverse) {
|
void MovementAIComponent::SetPath(const std::vector<NiPoint3>& path, bool startInReverse) {
|
||||||
if (path.empty()) return;
|
if (path.empty()) return;
|
||||||
m_CurrentPath = path;
|
m_CurrentPath = path;
|
||||||
m_IsInReverse = startInReverse;
|
m_IsInReverse = startInReverse;
|
||||||
@ -549,11 +549,11 @@ void MovementAIComponent::HandleWaypointArrived(uint32_t commandIndex) {
|
|||||||
GameMessages::SendPlayNDAudioEmitter(m_Parent, UNASSIGNED_SYSTEM_ADDRESS, data);
|
GameMessages::SendPlayNDAudioEmitter(m_Parent, UNASSIGNED_SYSTEM_ADDRESS, data);
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::BOUNCE:
|
case eWaypointCommandType::BOUNCE:
|
||||||
Game::logger->LogDebug("MovementAIComponent", "Unable to process bounce waypoint command server side!");
|
LOG("Unable to process bounce waypoint command server side!");
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::INVALID:
|
case eWaypointCommandType::INVALID:
|
||||||
default:
|
default:
|
||||||
Game::logger->LogDebug("MovementAIComponent", "Got invalid waypoint command %i", command);
|
LOG("Got invalid waypoint command %i", command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -583,20 +583,18 @@ void MovementAIComponent::HandleWaypointCommandCastSkill(const std::string& data
|
|||||||
if (data.empty()) return;
|
if (data.empty()) return;
|
||||||
auto* skillComponent = m_Parent->GetComponent<SkillComponent>();
|
auto* skillComponent = m_Parent->GetComponent<SkillComponent>();
|
||||||
if (!skillComponent) {
|
if (!skillComponent) {
|
||||||
Game::logger->LogDebug("MovementAIComponent::HandleWaypointCommandCastSkill", "Skill component not found!");
|
LOG("Skill component not found!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint32_t skillId = 0;
|
auto skillId = GeneralUtils::TryParse<uint32_t>(data);
|
||||||
if (!GeneralUtils::TryParse<uint32_t>(data, skillId)) return;
|
if (skillId && skillId != 0) skillComponent->CastSkill(skillId.value());
|
||||||
if (skillId != 0) skillComponent->CastSkill(skillId);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovementAIComponent::HandleWaypointCommandEquipInventory(const std::string& data) {
|
void MovementAIComponent::HandleWaypointCommandEquipInventory(const std::string& data) {
|
||||||
if (data.empty()) return;
|
if (data.empty()) return;
|
||||||
auto* inventoryComponent = m_Parent->GetComponent<InventoryComponent>();
|
auto* inventoryComponent = m_Parent->GetComponent<InventoryComponent>();
|
||||||
if (!inventoryComponent) {
|
if (!inventoryComponent) {
|
||||||
Game::logger->LogDebug("MovementAIComponent::HandleWaypointCommandEquipInventory", "Inventory component not found!");
|
LOG("Inventory component not found!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// the client says use slot 0 of items
|
// the client says use slot 0 of items
|
||||||
@ -611,7 +609,7 @@ void MovementAIComponent::HandleWaypointCommandUnequipInventory(const std::strin
|
|||||||
if (data.empty()) return;
|
if (data.empty()) return;
|
||||||
auto* inventoryComponent = m_Parent->GetComponent<InventoryComponent>();
|
auto* inventoryComponent = m_Parent->GetComponent<InventoryComponent>();
|
||||||
if (!inventoryComponent) {
|
if (!inventoryComponent) {
|
||||||
Game::logger->LogDebug("MovementAIComponent::HandleWaypointCommandEquipInventory", "Inventory component not found!");
|
LOG("Inventory component not found!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// the client says use slot 0 of items
|
// the client says use slot 0 of items
|
||||||
@ -623,35 +621,50 @@ void MovementAIComponent::HandleWaypointCommandUnequipInventory(const std::strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
float MovementAIComponent::HandleWaypointCommandDelay(const std::string& data) {
|
float MovementAIComponent::HandleWaypointCommandDelay(const std::string& data) {
|
||||||
float delay = 0.0f;
|
auto delay = GeneralUtils::TryParse<float>(data);
|
||||||
std::string delayString = data;
|
if (!delay) {
|
||||||
if (!GeneralUtils::TryParse<float>(delayString, delay)) {
|
LOG("Failed to parse delay %s", data.c_str());
|
||||||
Game::logger->LogDebug("MovementAIComponentAronwk", "Failed to parse delay %s", data.c_str());
|
|
||||||
}
|
}
|
||||||
return delay;
|
return delay.value_or(0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovementAIComponent::HandleWaypointCommandTeleport(const std::string& data) {
|
void MovementAIComponent::HandleWaypointCommandTeleport(const std::string& data) {
|
||||||
auto posString = GeneralUtils::SplitString(data, ',');
|
auto posString = GeneralUtils::SplitString(data, ',');
|
||||||
if (posString.size() == 0) return;
|
if (posString.size() == 0) return;
|
||||||
auto newPos = NiPoint3();
|
auto newPos = NiPoint3();
|
||||||
if (posString.size() == 1 && !GeneralUtils::TryParse<float>(posString.at(0), newPos.x)) return;
|
std::optional<float> intermediate;
|
||||||
if (posString.size() == 2 && !GeneralUtils::TryParse<float>(posString.at(1), newPos.y)) return;
|
if (posString.size() >= 1) {
|
||||||
if (posString.size() == 3 && !GeneralUtils::TryParse<float>(posString.at(2), newPos.z)) return;
|
intermediate = GeneralUtils::TryParse<float>(posString.at(0));
|
||||||
GameMessages::SendTeleport(m_Parent->GetObjectID(), newPos, NiQuaternion::IDENTITY, UNASSIGNED_SYSTEM_ADDRESS);
|
if (!intermediate) return;
|
||||||
|
|
||||||
|
newPos.x = intermediate.value();
|
||||||
|
if (posString.size() >= 2) {
|
||||||
|
intermediate = GeneralUtils::TryParse<float>(posString.at(1));
|
||||||
|
if (!intermediate) return;
|
||||||
|
|
||||||
|
newPos.y = intermediate.value();
|
||||||
|
if (posString.size() >= 3) {
|
||||||
|
intermediate = GeneralUtils::TryParse<float>(posString.at(2));
|
||||||
|
if (!intermediate) return;
|
||||||
|
|
||||||
|
newPos.z = intermediate.value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GameMessages::SendTeleport(m_Parent->GetObjectID(), newPos, NiQuaternionConstant::IDENTITY, UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovementAIComponent::HandleWaypointCommandPathSpeed(const std::string& data) {
|
void MovementAIComponent::HandleWaypointCommandPathSpeed(const std::string& data) {
|
||||||
float speed = 0.0;
|
auto speed = GeneralUtils::TryParse<float>(data);
|
||||||
if (!GeneralUtils::TryParse<float>(data, speed)) return;
|
if (!speed) return;
|
||||||
SetMaxSpeed(speed);
|
SetMaxSpeed(speed.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovementAIComponent::HandleWaypointCommandRemoveNPC(const std::string& data) {
|
void MovementAIComponent::HandleWaypointCommandRemoveNPC(const std::string& data) {
|
||||||
if (data.empty()) return;
|
if (data.empty()) return;
|
||||||
auto* proximityMonitorComponent = m_Parent->GetComponent<ProximityMonitorComponent>();
|
auto* proximityMonitorComponent = m_Parent->GetComponent<ProximityMonitorComponent>();
|
||||||
if (!proximityMonitorComponent) {
|
if (!proximityMonitorComponent) {
|
||||||
Game::logger->LogDebug("MovementAIComponent::HandleWaypointCommandRemoveNPC", "Proximity monitor component not found!");
|
LOG("Proximity monitor component not found!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto foundObjs = proximityMonitorComponent->GetProximityObjects("KillOBJS");
|
const auto foundObjs = proximityMonitorComponent->GetProximityObjects("KillOBJS");
|
||||||
@ -660,11 +673,13 @@ void MovementAIComponent::HandleWaypointCommandRemoveNPC(const std::string& data
|
|||||||
if (!entity) return;
|
if (!entity) return;
|
||||||
auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
|
auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
|
||||||
if (!destroyableComponent) {
|
if (!destroyableComponent) {
|
||||||
Game::logger->LogDebug("MovementAIComponent::HandleWaypointCommandRemoveNPC", "Destroyable component not found!");
|
LOG("Destroyable component not found!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint32_t factionID = -1;
|
int32_t factionID = -1;
|
||||||
if (!GeneralUtils::TryParse<uint32_t>(data, factionID)) return;
|
auto parsed = GeneralUtils::TryParse<uint32_t>(data);
|
||||||
|
if (!parsed) return;
|
||||||
|
factionID = parsed.value();
|
||||||
if (destroyableComponent->BelongsToFaction(factionID)) m_Parent->Kill();
|
if (destroyableComponent->BelongsToFaction(factionID)) m_Parent->Kill();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -676,7 +691,9 @@ void MovementAIComponent::HandleWaypointCommandChangeWaypoint(const std::string&
|
|||||||
if (data.find(",") != std::string::npos) {
|
if (data.find(",") != std::string::npos) {
|
||||||
auto datas = GeneralUtils::SplitString(data, ',');
|
auto datas = GeneralUtils::SplitString(data, ',');
|
||||||
path_string = datas.at(0);
|
path_string = datas.at(0);
|
||||||
if (!GeneralUtils::TryParse(datas.at(1), index)) return;
|
auto parsed = GeneralUtils::TryParse<int32_t>(datas.at(1));
|
||||||
|
if (!parsed) return;
|
||||||
|
index = parsed.value();
|
||||||
} else path_string = data;
|
} else path_string = data;
|
||||||
|
|
||||||
if (path_string != "") {
|
if (path_string != "") {
|
||||||
@ -687,7 +704,9 @@ void MovementAIComponent::HandleWaypointCommandChangeWaypoint(const std::string&
|
|||||||
|
|
||||||
void MovementAIComponent::HandleWaypointCommandSpawnObject(const std::string& data) {
|
void MovementAIComponent::HandleWaypointCommandSpawnObject(const std::string& data) {
|
||||||
LOT newObjectLOT = 0;
|
LOT newObjectLOT = 0;
|
||||||
if (!GeneralUtils::TryParse(data, newObjectLOT)) return;
|
auto parsed = GeneralUtils::TryParse<LOT>(data);
|
||||||
|
if (!parsed) return;
|
||||||
|
newObjectLOT = parsed.value();
|
||||||
EntityInfo info{};
|
EntityInfo info{};
|
||||||
info.lot = newObjectLOT;
|
info.lot = newObjectLOT;
|
||||||
info.pos = m_Parent->GetPosition();
|
info.pos = m_Parent->GetPosition();
|
||||||
|
@ -224,7 +224,7 @@ public:
|
|||||||
* Sets a path to follow for the AI
|
* Sets a path to follow for the AI
|
||||||
* @param path the path to follow
|
* @param path the path to follow
|
||||||
*/
|
*/
|
||||||
void SetPath(std::vector<NiPoint3> path, bool startsInReverse = false);
|
void SetPath(const std::vector<NiPoint3>& path, bool startsInReverse = false);
|
||||||
|
|
||||||
// Advance the path waypoint index and return if there is a next waypoint
|
// Advance the path waypoint index and return if there is a next waypoint
|
||||||
bool AdvancePathWaypointIndex();
|
bool AdvancePathWaypointIndex();
|
||||||
|
@ -162,7 +162,7 @@ void MovingPlatformComponent::StartPathing() {
|
|||||||
const auto& nextWaypoint = m_Path->pathWaypoints[subComponent->mNextWaypointIndex];
|
const auto& nextWaypoint = m_Path->pathWaypoints[subComponent->mNextWaypointIndex];
|
||||||
|
|
||||||
subComponent->mPosition = currentWaypoint.position;
|
subComponent->mPosition = currentWaypoint.position;
|
||||||
subComponent->mSpeed = currentWaypoint.speed;
|
subComponent->mSpeed = currentWaypoint.movingPlatform.speed;
|
||||||
subComponent->mWaitTime = currentWaypoint.movingPlatform.wait;
|
subComponent->mWaitTime = currentWaypoint.movingPlatform.wait;
|
||||||
|
|
||||||
targetPosition = nextWaypoint.position;
|
targetPosition = nextWaypoint.position;
|
||||||
@ -213,7 +213,7 @@ void MovingPlatformComponent::ContinuePathing() {
|
|||||||
const auto& nextWaypoint = m_Path->pathWaypoints[subComponent->mNextWaypointIndex];
|
const auto& nextWaypoint = m_Path->pathWaypoints[subComponent->mNextWaypointIndex];
|
||||||
|
|
||||||
subComponent->mPosition = currentWaypoint.position;
|
subComponent->mPosition = currentWaypoint.position;
|
||||||
subComponent->mSpeed = currentWaypoint.speed;
|
subComponent->mSpeed = currentWaypoint.movingPlatform.speed;
|
||||||
subComponent->mWaitTime = currentWaypoint.movingPlatform.wait; // + 2;
|
subComponent->mWaitTime = currentWaypoint.movingPlatform.wait; // + 2;
|
||||||
|
|
||||||
pathSize = m_Path->pathWaypoints.size() - 1;
|
pathSize = m_Path->pathWaypoints.size() - 1;
|
||||||
|
@ -61,17 +61,17 @@ bool ProximityMonitorComponent::IsInProximity(const std::string& name, LWOOBJID
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ProximityMonitorComponent::Update(float deltaTime) {
|
void ProximityMonitorComponent::Update(float deltaTime) {
|
||||||
for (const auto& [name, dpentity] : m_ProximitiesData) {
|
for (const auto& prox : m_ProximitiesData) {
|
||||||
if (!dpentity) continue;
|
if (!prox.second) continue;
|
||||||
dpentity->SetPosition(m_Parent->GetPosition());
|
prox.second->SetPosition(m_Parent->GetPosition());
|
||||||
//Process enter events
|
//Process enter events
|
||||||
for (auto* en : dpentity->GetNewObjects()) {
|
for (auto* en : prox.second->GetNewObjects()) {
|
||||||
m_Parent->OnCollisionProximity(en->GetObjectID(), name, "ENTER");
|
m_Parent->OnCollisionProximity(en->GetObjectID(), prox.first, "ENTER");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Process exit events
|
//Process exit events
|
||||||
for (auto* en : dpentity->GetRemovedObjects()) {
|
for (auto* en : prox.second->GetRemovedObjects()) {
|
||||||
m_Parent->OnCollisionProximity(en->GetObjectID(), name, "LEAVE");
|
m_Parent->OnCollisionProximity(en->GetObjectID(), prox.first, "LEAVE");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,9 +227,9 @@ void TriggerComponent::HandleSetPath(Entity* targetEntity, std::vector<std::stri
|
|||||||
if (!movementAIComponent) return;
|
if (!movementAIComponent) return;
|
||||||
movementAIComponent->SetupPath(argArray.at(0));
|
movementAIComponent->SetupPath(argArray.at(0));
|
||||||
if (argArray.size() >= 2) {
|
if (argArray.size() >= 2) {
|
||||||
int32_t index = 0;
|
auto index = GeneralUtils::TryParse<int32_t>(argArray.at(1));
|
||||||
if (!GeneralUtils::TryParse(argArray.at(1), index)) return;
|
if (!index) return;
|
||||||
movementAIComponent->SetPathStartingWaypointIndex(index);
|
movementAIComponent->SetPathStartingWaypointIndex(index.value());
|
||||||
}
|
}
|
||||||
if (argArray.size() >= 3 && argArray.at(2) == "1") movementAIComponent->ReversePath();
|
if (argArray.size() >= 3 && argArray.at(2) == "1") movementAIComponent->ReversePath();
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_AM
|
|||||||
"AmBlueX.cpp"
|
"AmBlueX.cpp"
|
||||||
"AmTeapotServer.cpp"
|
"AmTeapotServer.cpp"
|
||||||
"WanderingVendor.cpp"
|
"WanderingVendor.cpp"
|
||||||
PARENT_SCOPE)
|
)
|
||||||
|
|
||||||
add_library(dScriptsServerMapAM ${DSCRIPTS_SOURCES_02_SERVER_MAP_AM})
|
add_library(dScriptsServerMapAM ${DSCRIPTS_SOURCES_02_SERVER_MAP_AM})
|
||||||
target_include_directories(dScriptsServerMapAM PUBLIC ".")
|
target_include_directories(dScriptsServerMapAM PUBLIC ".")
|
||||||
|
@ -18,7 +18,7 @@ void WanderingVendor::OnProximityUpdate(Entity* self, Entity* entering, std::str
|
|||||||
} else if (status == "LEAVE") {
|
} else if (status == "LEAVE") {
|
||||||
auto* proximityMonitorComponent = self->GetComponent<ProximityMonitorComponent>();
|
auto* proximityMonitorComponent = self->GetComponent<ProximityMonitorComponent>();
|
||||||
if (!proximityMonitorComponent) {
|
if (!proximityMonitorComponent) {
|
||||||
Game::logger->LogDebug("MovementAIComponent::HandleWaypointCommandRemoveNPC", "Proximity monitor component not found!");
|
LOG("Proximity monitor component not found!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto proxObjs = proximityMonitorComponent->GetProximityObjects("playermonitor");
|
const auto proxObjs = proximityMonitorComponent->GetProximityObjects("playermonitor");
|
||||||
|
@ -22,6 +22,7 @@ add_library(dScriptsZone STATIC ${DSCRIPTS_SOURCES_ZONE})
|
|||||||
target_include_directories(dScriptsZone PUBLIC "."
|
target_include_directories(dScriptsZone PUBLIC "."
|
||||||
"AG"
|
"AG"
|
||||||
"LUPs"
|
"LUPs"
|
||||||
|
"LUPs/RobotCity_Intro"
|
||||||
"PROPERTY"
|
"PROPERTY"
|
||||||
"PROPERTY/FV"
|
"PROPERTY/FV"
|
||||||
"PROPERTY/GF"
|
"PROPERTY/GF"
|
||||||
|
@ -420,7 +420,7 @@ void Zone::LoadPath(std::istream& file) {
|
|||||||
|
|
||||||
if (path.pathType == PathType::MovingPlatform) {
|
if (path.pathType == PathType::MovingPlatform) {
|
||||||
BinaryIO::BinaryRead(file, waypoint.movingPlatform.lockPlayer);
|
BinaryIO::BinaryRead(file, waypoint.movingPlatform.lockPlayer);
|
||||||
BinaryIO::BinaryRead(file, waypoint.speed);
|
BinaryIO::BinaryRead(file, waypoint.movingPlatform.speed);
|
||||||
BinaryIO::BinaryRead(file, waypoint.movingPlatform.wait);
|
BinaryIO::BinaryRead(file, waypoint.movingPlatform.wait);
|
||||||
if (path.pathVersion >= 13) {
|
if (path.pathVersion >= 13) {
|
||||||
BinaryIO::ReadString<uint8_t>(file, waypoint.movingPlatform.departSound, BinaryIO::ReadType::WideString);
|
BinaryIO::ReadString<uint8_t>(file, waypoint.movingPlatform.departSound, BinaryIO::ReadType::WideString);
|
||||||
@ -439,7 +439,7 @@ void Zone::LoadPath(std::istream& file) {
|
|||||||
BinaryIO::BinaryRead(file, waypoint.racing.planeHeight);
|
BinaryIO::BinaryRead(file, waypoint.racing.planeHeight);
|
||||||
BinaryIO::BinaryRead(file, waypoint.racing.shortestDistanceToEnd);
|
BinaryIO::BinaryRead(file, waypoint.racing.shortestDistanceToEnd);
|
||||||
} else if (path.pathType == PathType::Rail) {
|
} else if (path.pathType == PathType::Rail) {
|
||||||
if (path.pathVersion > 16) BinaryIO::BinaryRead(file, waypoint.speed);
|
if (path.pathVersion > 16) BinaryIO::BinaryRead(file, waypoint.rail.speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// object LDF configs
|
// object LDF configs
|
||||||
@ -460,7 +460,7 @@ void Zone::LoadPath(std::istream& file) {
|
|||||||
auto waypointCommand = WaypointCommandType::StringToWaypointCommandType(parameter);
|
auto waypointCommand = WaypointCommandType::StringToWaypointCommandType(parameter);
|
||||||
if (waypointCommand == eWaypointCommandType::DELAY) value.erase(std::remove_if(value.begin(), value.end(), ::isspace), value.end());
|
if (waypointCommand == eWaypointCommandType::DELAY) value.erase(std::remove_if(value.begin(), value.end(), ::isspace), value.end());
|
||||||
if (waypointCommand != eWaypointCommandType::INVALID) waypoint.commands.push_back(WaypointCommand(waypointCommand, value));
|
if (waypointCommand != eWaypointCommandType::INVALID) waypoint.commands.push_back(WaypointCommand(waypointCommand, value));
|
||||||
else Game::logger->Log("Zone", "Tried to load invalid waypoint command '%s'", parameter.c_str());
|
else LOG("Tried to load invalid waypoint command '%s'", parameter.c_str());
|
||||||
} else {
|
} else {
|
||||||
ldfConfig = LDFBaseData::DataFromString(parameter + "=" + value);
|
ldfConfig = LDFBaseData::DataFromString(parameter + "=" + value);
|
||||||
if (ldfConfig) waypoint.config.push_back(ldfConfig);
|
if (ldfConfig) waypoint.config.push_back(ldfConfig);
|
||||||
|
@ -50,6 +50,7 @@ struct SceneTransition {
|
|||||||
|
|
||||||
struct MovingPlatformPathWaypoint {
|
struct MovingPlatformPathWaypoint {
|
||||||
uint8_t lockPlayer;
|
uint8_t lockPlayer;
|
||||||
|
float speed;
|
||||||
float wait;
|
float wait;
|
||||||
std::string departSound;
|
std::string departSound;
|
||||||
std::string arriveSound;
|
std::string arriveSound;
|
||||||
@ -71,13 +72,17 @@ struct RacingPathWaypoint {
|
|||||||
float shortestDistanceToEnd;
|
float shortestDistanceToEnd;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct RailPathWaypoint {
|
||||||
|
float speed;
|
||||||
|
};
|
||||||
|
|
||||||
struct PathWaypoint {
|
struct PathWaypoint {
|
||||||
NiPoint3 position;
|
NiPoint3 position;
|
||||||
NiQuaternion rotation; // not included in all, but it's more convenient here
|
NiQuaternion rotation; // not included in all, but it's more convenient here
|
||||||
MovingPlatformPathWaypoint movingPlatform;
|
MovingPlatformPathWaypoint movingPlatform;
|
||||||
CameraPathWaypoint camera;
|
CameraPathWaypoint camera;
|
||||||
RacingPathWaypoint racing;
|
RacingPathWaypoint racing;
|
||||||
float speed = 1.0f;
|
RailPathWaypoint rail;
|
||||||
std::vector<LDFBaseData*> config;
|
std::vector<LDFBaseData*> config;
|
||||||
std::vector<WaypointCommand> commands;
|
std::vector<WaypointCommand> commands;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user