Fix Npc Attacking - #406
Conversation
No more spazzing out npcs attack you!
WalkthroughThis pull request updates the navigation and movement logic within the game server. It adds a new overload for updating an agent's position, renames a method to better reflect its behavior, and streamlines error logging. Additionally, death state handling and movement update logic in actor state components have been simplified. Minor cleanups include removing redundant return statements and unused using directives, and refining conditional syntax in the NPC update method. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant AgentNav as AgentNavigation
participant Field
participant NPC
Caller->>AgentNav: UpdatePosition(newPosition)
AgentNav->>Field: FindNearestPoly(newPosition)
alt Valid position found
Field-->>AgentNav: PolyData
AgentNav->>NPC: Update npc.Position
AgentNav->>AgentNav: Update agent.npos
AgentNav-->>Caller: Return true
else No valid position
AgentNav->>Logger: Log error message
AgentNav-->>Caller: Return false
end
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (7)
💤 Files with no reviewable changes (2)
🧰 Additional context used🧬 Code Definitions (1)Maple2.Server.Game/Model/Field/Actor/FieldNpc.cs (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (8)
✨ 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:
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.
Pull Request Overview
This PR aims to fix erratic NPC attacking behavior by refining movement, state management, and navigation logic. Key changes include:
- Removing unused dependencies and consolidating usings.
- Updating state checks using pattern matching and streamlining NPC spawning logic.
- Refactoring navigation updates and renaming helper functions to better reflect their purpose.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Maple2.Server.Game/Packets/NpcControlPacket.cs | Removed unused using statements to clean up dependencies. |
| Maple2.Server.Game/Model/Field/Actor/FieldNpc.cs | Updated the NPC spawning check to use pattern matching. |
| Maple2.Server.Game/Model/Field/Actor/ActorStateComponent/MovementStateTasks/MovementState.SkillCastTask.cs | Removed a redundant return statement in a void method. |
| Maple2.Server.Game/Model/Field/Actor/ActorStateComponent/MovementStateStates/MovementState.Walk.cs | Simplified navigation update by integrating the position directly. |
| Maple2.Server.Game/Model/Field/Actor/ActorStateComponent/MovementStateStates/MovementState.SkillCast.cs | Improved safety by using TryGetValue for attack point lookup and simplified navigation update logic. |
| Maple2.Server.Game/Model/Field/Actor/ActorStateComponent/MovementState.cs | Removed the Died method and replaced health checks with an IsDead property. |
| Maple2.Server.Game/Manager/Field/AgentNavigation.cs | Introduced an overloaded UpdatePosition method and renamed functions to better reflect their functionality. |
No more spazzing out npcs attack you!
Summary by CodeRabbit
New Features
Refactor
Chore