Use better height and path checking

Fix issue with paths entering infinite loop
fix default position height being at height 0.
This commit is contained in:
David Markowitz 2023-08-24 03:40:10 -07:00
parent dd2338601e
commit 458db4682b
2 changed files with 4 additions and 2 deletions

View File

@ -648,7 +648,7 @@ void BaseCombatAIComponent::Wander() {
const NiPoint3 delta =
{
radius * cos(theta),
0,
m_Parent->GetPosition().y,
radius * sin(theta)
};

View File

@ -197,6 +197,7 @@ void MovementAIComponent::ReversePath() {
}
bool MovementAIComponent::AdvancePathWaypointIndex() {
if (m_CurrentPath.empty()) return false;
m_CurrentPathWaypointIndex = m_NextPathWaypointIndex;
if (m_IsInReverse) {
if (m_CurrentPathWaypointIndex >= 0) m_NextPathWaypointIndex--;
@ -469,7 +470,8 @@ void MovementAIComponent::HandleWaypointArrived(uint32_t commandIndex) {
m_Parent->TriggerEvent(eTriggerEventType::ARRIVED_AT_DESIRED_WAYPOINT);
if (!m_Path || commandIndex >= m_Path->pathWaypoints.at(m_CurrentPathWaypointIndex).commands.size()) {
if (!AdvancePathWaypointIndex()) {
if (m_Path) {
// We only want to handle path logic if we actually have a path setup for following
if (m_Path && !m_CurrentPath.empty()) {
if (m_Path->pathBehavior == PathBehavior::Bounce) {
ReversePath();
} else if (m_Path->pathBehavior == PathBehavior::Loop) {