diff --git a/dGame/dComponents/BaseCombatAIComponent.cpp b/dGame/dComponents/BaseCombatAIComponent.cpp index acdc9112d..1cfbf5be0 100644 --- a/dGame/dComponents/BaseCombatAIComponent.cpp +++ b/dGame/dComponents/BaseCombatAIComponent.cpp @@ -677,6 +677,10 @@ void BaseCombatAIComponent::Wander() { const auto div = static_cast(info.wanderDelayMax); m_Timer = (div == 0 ? 0 : GeneralUtils::GenerateRandomNumber(0, div)) + info.wanderDelayMin; //set a random timer to stay put. + // WanderChance is the percent chance to move each time the timer runs out (90 or 100 in the MovementAIComponent + // rows); an enemy with no row has 0 and only moves to fight and to return + if (info.wanderChance <= 0.0f || GeneralUtils::GenerateRandomNumber(0, 100) > info.wanderChance) return; + const float radius = info.wanderRadius * sqrt(static_cast(GeneralUtils::GenerateRandomNumber(0, 1))); //our wander radius + a bit of random range const float theta = ((static_cast(GeneralUtils::GenerateRandomNumber(0, 1)) * 2 * PI)); diff --git a/dGame/dComponents/MovementAIComponent.h b/dGame/dComponents/MovementAIComponent.h index 159c4d17c..61f312089 100644 --- a/dGame/dComponents/MovementAIComponent.h +++ b/dGame/dComponents/MovementAIComponent.h @@ -41,7 +41,7 @@ struct MovementAIInfo { float wanderSpeed{}; /** - * This is only used for the emotes + * The percent chance to move each time the wander timer runs out */ float wanderChance{};