-
Notifications
You must be signed in to change notification settings - Fork 7
MobStuck AI improvement #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Mobstuck code - Successfully teleports mobs home Logic in place to prevent monsters from getting stuck, resets their AI properly.
WalkthroughThe changes introduce adaptive stuck detection logic for both player and monster movement. In the movement manager, stuck detection thresholds are now dynamic and movement is canceled after repeated failures. For monsters, a new stuck detection and recovery system is added, along with cooperative AI behaviors, null safety improvements, and placeholder logic for fast healing. Changes
Sequence Diagram(s)sequenceDiagram
participant Creature
participant MoveToManager
participant Target
Creature->>MoveToManager: Initiate movement
loop Movement update
MoveToManager->>MoveToManager: CheckProgressMade()
alt Progress insufficient
MoveToManager->>MoveToManager: Increment FailProgressCount
alt FailProgressCount >= 5
MoveToManager->>Creature: CancelMoveTo(ActionCancelled)
Creature->>Creature: HandleStuck()
alt Can find new target
Creature->>Target: Switch to new target
else
Creature->>Creature: ForceHome()
end
end
end
end
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
Source/ACE.Server/Physics/Managers/MoveToManager.cs (2)
462-466: Consider making the stuck threshold configurable.The hard-coded value of 5 for the maximum fail count works well, but consider extracting it to a constant or configurable property for better maintainability and flexibility across different movement scenarios.
+private const int MaxFailProgressCount = 5; + // Enhanced stuck detection with better thresholds -if (FailProgressCount >= 5) +if (FailProgressCount >= MaxFailProgressCount) { CancelMoveTo(WeenieError.ActionCancelled); return; }
683-696: Good implementation of adaptive stuck detection thresholds.The dynamic progress rate thresholds based on movement type and distance are well-designed. This prevents false positives when monsters move longer distances where progress naturally appears slower.
Consider adding a comment explaining the rationale behind the specific threshold values (0.15f, 0.20f, 0.25f) for future maintainers.
Source/ACE.Server/WorldObjects/Monster_Navigation.cs (2)
290-301: Document the placeholder implementation.The
ApplyFastHealingmethod is currently a placeholder. Consider adding a TODO comment or tracking this in an issue for future implementation.public void ApplyFastHealing() { if (MonsterState == State.Return) { + // TODO: Implement fast healing for monsters returning home // Increase vital regen when returning home // This is handled by the existing vital regen system // The actual implementation would be in the vital regen logic } }
303-347: Excellent implementation of cooperative AI behavior.The distress call system is well-designed with proper faction/type checking and uses the existing aural awareness range. The use of
WakeUp(false)to prevent chain reactions is particularly clever.Consider caching
objMaint.GetVisibleTargetsValuesOfTypeCreature()if this method is called frequently to avoid repeated visibility calculations.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
Source/ACE.Server/Physics/Managers/MoveToManager.cs(2 hunks)Source/ACE.Server/WorldObjects/Monster_Navigation.cs(8 hunks)
🔇 Additional comments (8)
Source/ACE.Server/Physics/Managers/MoveToManager.cs (1)
704-704: Correct calculation of original progress rate.Using
PhysicsTimer.CurrentTimedirectly provides a more accurate measurement of overall movement progress since the start.Source/ACE.Server/WorldObjects/Monster_Navigation.cs (7)
68-74: Well-structured stuck detection properties.The stuck detection constants are reasonable and well-documented. The 2-second check interval and 3-attempt threshold provide a good balance between responsiveness and avoiding false positives.
111-112: Proper initialization of stuck detection timer.The stuck check timer is correctly initialized when movement begins, ensuring accurate tracking from the start.
183-187: Excellent null safety improvements and performance optimization.Caching the physics object references and adding null checks prevents potential crashes. Returning
float.MaxValuefor invalid physics objects is the correct approach.
222-231: Well-integrated movement failure detection and recovery methods.The null-safe access to
MoveToManagerand the integration of stuck detection with the existing cancel mechanism work well together. The three new method calls are appropriately placed.
233-281: Robust stuck detection and recovery implementation.The stuck detection system is well-designed with appropriate guard clauses, interval checks, and state-based recovery logic. The bypass for immobile monsters is a crucial detail that prevents false positives.
351-352: Comprehensive null safety improvements.The added null checks throughout the navigation methods prevent potential crashes. The warning log in
ForceHomeis particularly helpful for debugging physics object issues.Also applies to: 384-385, 627-631
612-613: Proper reset of stuck detection state.Resetting
StuckAttemptswhen movement is cancelled ensures clean state for the next movement operation.
Utilizes MoveToManager to reduce server impact while improving MoveHome when stuck.
Fails gracefully if ever it does fail.
Built on the commits to ACE from Vanguish:
ACEmulator/ACE#4306
Summary by CodeRabbit
New Features
Bug Fixes
Refactor