mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-15 00:07:13 +00:00
fix(combat-ai): wander only as often as the movement row's WanderChance
An enemy moved every time its wander timer ran out. The MovementAIComponent rows give a percent chance (90 or 100) to move each time; enemies with no row (survival and instance enemies, bosses, behavior spawns) get 0 and now only move to fight and to return. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -677,6 +677,10 @@ void BaseCombatAIComponent::Wander() {
|
||||
const auto div = static_cast<int>(info.wanderDelayMax);
|
||||
m_Timer = (div == 0 ? 0 : GeneralUtils::GenerateRandomNumber<int>(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<float>(0, 100) > info.wanderChance) return;
|
||||
|
||||
const float radius = info.wanderRadius * sqrt(static_cast<double>(GeneralUtils::GenerateRandomNumber<float>(0, 1))); //our wander radius + a bit of random range
|
||||
const float theta = ((static_cast<double>(GeneralUtils::GenerateRandomNumber<float>(0, 1)) * 2 * PI));
|
||||
|
||||
|
||||
@@ -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{};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user