This commit is contained in:
David Markowitz 2023-08-12 00:40:18 -07:00
parent 84ba38bd1d
commit 56ab6bd4c3
3 changed files with 15 additions and 11 deletions

View File

@ -399,6 +399,9 @@ void MovementAIComponent::SetDestination(const NiPoint3& destination) {
std::vector<NiPoint3> computedPath; std::vector<NiPoint3> computedPath;
if (dpWorld::Instance().IsLoaded()) { if (dpWorld::Instance().IsLoaded()) {
computedPath = dpWorld::Instance().GetNavMesh()->GetPath(m_Parent->GetPosition(), destination, m_Info.wanderSpeed); computedPath = dpWorld::Instance().GetNavMesh()->GetPath(m_Parent->GetPosition(), destination, m_Info.wanderSpeed);
} else {
// If we do not have a navmesh, we do not want an AI to be going towards points that are far below or above the map.
//
} }
// Somehow failed // Somehow failed

View File

@ -223,8 +223,11 @@ public:
*/ */
static float GetBaseSpeed(LOT lot); static float GetBaseSpeed(LOT lot);
void SetCurrentPathWaypointIndex(uint32_t value) { m_CurrentPathWaypointIndex = value; }; private:
void SetNextPathWaypointIndex(uint32_t value) { m_NextPathWaypointIndex = value; };
// TODO: Advance properly
void SetCurrentPathWaypointIndex(uint32_t value) { };
void SetNextPathWaypointIndex(uint32_t value) { };
void HandleWaypointCommandGroupEmote(std::string data); void HandleWaypointCommandGroupEmote(std::string data);
void HandleWaypointCommandSetVariable(std::string data); void HandleWaypointCommandSetVariable(std::string data);
void HandleWaypointCommandCastSkill(std::string data); void HandleWaypointCommandCastSkill(std::string data);
@ -238,8 +241,6 @@ public:
void HandleWaypointCommandChangeWaypoint(std::string data); void HandleWaypointCommandChangeWaypoint(std::string data);
void HandleWaypointCommandSpawnObject(std::string data); void HandleWaypointCommandSpawnObject(std::string data);
private:
/** /**
* Sets the current position of the entity * Sets the current position of the entity
* @param value the position to set * @param value the position to set

View File

@ -7,8 +7,8 @@
void MovementAIComponent::HandleWaypointArrived() { void MovementAIComponent::HandleWaypointArrived() {
if (!m_Path) return; if (!m_Path) return;
if (m_Path->pathWaypoints[m_CurrentPathWaypointIndex].commands.empty()) return; if (m_Path->pathWaypoints.at(m_CurrentPathWaypointIndex).commands.empty()) return;
for(auto [command, data] : m_Path->pathWaypoints[m_CurrentPathWaypointIndex].commands){ for(auto [command, data] : m_Path->pathWaypoints.at(m_CurrentPathWaypointIndex).commands){
switch(command){ switch(command){
case eWaypointCommandType::STOP: case eWaypointCommandType::STOP:
Stop(); Stop();
@ -102,20 +102,20 @@ void MovementAIComponent::HandleWaypointCommandUnequipInventory(std::string data
} }
void MovementAIComponent::HandleWaypointCommandDelay(std::string data) { void MovementAIComponent::HandleWaypointCommandDelay(std::string data) {
Pause(); Pause();
std::remove_if(data.begin(), data.end(), isspace); std::remove_if(data.begin(), data.end(), ::isspace);
// delay for time // delay for time
} }
void MovementAIComponent::HandleWaypointCommandEmote(std::string data) { void MovementAIComponent::HandleWaypointCommandEmote(std::string data) {
// pause fore animation time // pause for animation time
auto delay = RenderComponent::PlayAnimation(m_Parent, data); auto delay = RenderComponent::PlayAnimation(m_Parent, data);
} }
void MovementAIComponent::HandleWaypointCommandTeleport(std::string data) { void MovementAIComponent::HandleWaypointCommandTeleport(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[0], newPos.x); if (posString.size() == 1) GeneralUtils::TryParse<float>(posString.at(0), newPos.x);
if (posString.size() == 2) GeneralUtils::TryParse<float>(posString[1], newPos.y); if (posString.size() == 2) GeneralUtils::TryParse<float>(posString.at(1), newPos.y);
if (posString.size() == 3) GeneralUtils::TryParse<float>(posString[2], newPos.z); if (posString.size() == 3) GeneralUtils::TryParse<float>(posString.at(2), newPos.z);
GameMessages::SendTeleport(m_Parent->GetObjectID(), newPos, NiQuaternion::IDENTITY, UNASSIGNED_SYSTEM_ADDRESS); GameMessages::SendTeleport(m_Parent->GetObjectID(), newPos, NiQuaternion::IDENTITY, UNASSIGNED_SYSTEM_ADDRESS);
} }
void MovementAIComponent::HandleWaypointCommandPathSpeed(std::string data) { void MovementAIComponent::HandleWaypointCommandPathSpeed(std::string data) {