From 5996f3cbf4df8e72de2b04e371a6fb563ca5b196 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 30 Mar 2024 06:17:56 -0700 Subject: [PATCH] fix stewblaster stopping for non-players (#1521) fixes an issue when stew blaster would stop for non-players and would stand still permanently due to enemy hitboxes being removed. Tested that stewblaster only stops for players and starts moving when there are no players in the vicinity --- dGame/dComponents/MovementAIComponent.cpp | 2 ++ dScripts/02_server/Map/AM/WanderingVendor.cpp | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/dGame/dComponents/MovementAIComponent.cpp b/dGame/dComponents/MovementAIComponent.cpp index 358d8d11..b6a16803 100644 --- a/dGame/dComponents/MovementAIComponent.cpp +++ b/dGame/dComponents/MovementAIComponent.cpp @@ -68,6 +68,7 @@ void MovementAIComponent::SetPath(const std::string pathName) { } void MovementAIComponent::Pause() { + if (m_Paused) return; m_Paused = true; SetPosition(ApproximateLocation()); m_SavedVelocity = GetVelocity(); @@ -76,6 +77,7 @@ void MovementAIComponent::Pause() { } void MovementAIComponent::Resume() { + if (!m_Paused) return; m_Paused = false; SetVelocity(m_SavedVelocity); m_SavedVelocity = NiPoint3Constant::ZERO; diff --git a/dScripts/02_server/Map/AM/WanderingVendor.cpp b/dScripts/02_server/Map/AM/WanderingVendor.cpp index 77259e2f..742741d3 100644 --- a/dScripts/02_server/Map/AM/WanderingVendor.cpp +++ b/dScripts/02_server/Map/AM/WanderingVendor.cpp @@ -1,6 +1,7 @@ #include "WanderingVendor.h" #include "MovementAIComponent.h" #include "ProximityMonitorComponent.h" +#include void WanderingVendor::OnStartup(Entity* self) { auto movementAIComponent = self->GetComponent(); @@ -19,7 +20,16 @@ void WanderingVendor::OnProximityUpdate(Entity* self, Entity* entering, std::str if (!proximityMonitorComponent) self->AddComponent(); const auto proxObjs = proximityMonitorComponent->GetProximityObjects("playermonitor"); - if (proxObjs.empty()) self->AddTimer("startWalking", 1.5); + bool foundPlayer = false; + for (const auto id : proxObjs | std::views::keys) { + auto* entity = Game::entityManager->GetEntity(id); + if (entity && entity->IsPlayer()) { + foundPlayer = true; + break; + } + } + + if (!foundPlayer) self->AddTimer("startWalking", 1.5); } }