From b63492b38154f9205bef35d5ad92b8064344d453 Mon Sep 17 00:00:00 2001 From: Baptiste Marie Date: Thu, 11 Jul 2024 16:26:12 +0200 Subject: [PATCH] `ABrain.Stop`: Set FSM state to IDLE. * Fixes `/mob path` not making the target follow the path immediately. * It could result in various undesirable effects, but resetting the state makes sense to me. --- GameServer/ai/ABrain.cs | 1 + GameServer/ai/brain/Animist/TurretBrain.cs | 6 ++++-- GameServer/ai/brain/StandardMob/StandardMobBrain.cs | 10 ++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/GameServer/ai/ABrain.cs b/GameServer/ai/ABrain.cs index 9527cc7e25..f287ca7742 100644 --- a/GameServer/ai/ABrain.cs +++ b/GameServer/ai/ABrain.cs @@ -50,6 +50,7 @@ public virtual bool Stop() { bool wasReturningToSpawnPoint = Body.IsReturningToSpawnPoint; Body.StopMoving(); + FSM?.SetCurrentState(eFSMStateType.IDLE); // Without `IsActive` check, charming a NPC that's returning to spawn would teleport it. if (wasReturningToSpawnPoint && !IsActive) diff --git a/GameServer/ai/brain/Animist/TurretBrain.cs b/GameServer/ai/brain/Animist/TurretBrain.cs index 0066fb629d..5b3a654cd4 100644 --- a/GameServer/ai/brain/Animist/TurretBrain.cs +++ b/GameServer/ai/brain/Animist/TurretBrain.cs @@ -138,9 +138,11 @@ protected virtual bool TrustCast(Spell spell, eCheckSpellType type, GameLiving t public override bool Stop() { - ClearAggroList(); + if (!base.Stop()) + return false; + _defensiveSpellTargets.Clear(); - return base.Stop(); + return true; } #region AI diff --git a/GameServer/ai/brain/StandardMob/StandardMobBrain.cs b/GameServer/ai/brain/StandardMob/StandardMobBrain.cs index 383fe8d059..a113c339be 100644 --- a/GameServer/ai/brain/StandardMob/StandardMobBrain.cs +++ b/GameServer/ai/brain/StandardMob/StandardMobBrain.cs @@ -53,13 +53,11 @@ public override string ToString() public override bool Stop() { // tolakram - when the brain stops, due to either death or no players in the vicinity, clear the aggro list - if (base.Stop()) - { - ClearAggroList(); - return true; - } + if (!base.Stop()) + return false; - return false; + ClearAggroList(); + return true; } public override void KillFSM()