Skip to content

Sync Skills & State Skills & Misc - #445

Merged
AngeloTadeucci merged 4 commits into
masterfrom
skills
May 14, 2025
Merged

Sync Skills & State Skills & Misc#445
AngeloTadeucci merged 4 commits into
masterfrom
skills

Conversation

@Zintixx

@Zintixx Zintixx commented May 14, 2025

Copy link
Copy Markdown
Collaborator
  • Fixed sync skill casting and looping
  • Fixed State skills (really just fast swimming)
  • Improved job command. Will now complete the awakening quest line and the master skill quest line
  • Improved trophy command. Using it to unlock all trophies should now unlock ALL trophies
  • Fixed exp command not giving exp
  • Fixed RB's Rune Balance not giving proper SP on tick.
  • Minor adjustments on buffs. This might break some skills in the meantime but once region skills are properly implemented, this will make more sense.

Summary by CodeRabbit

  • New Features

    • Added commands and methods to instantly complete all quests in a chapter and unlock all trophies for debugging purposes.
    • Introduced new enums and constants for skill and buff categorization, including bounce types and super armor states.
    • Enhanced skill casting and handling, including new parameters for skill position, timing, and direction.
    • Added tracking for state-related skills in skill queue and skill records.
    • Added method to retrieve quests by chapter.
  • Improvements

    • Refined job advancement and awakening commands for clearer flow and validation.
    • Improved stat regeneration logic and ensured stats cannot become negative.
    • Updated skill and buff systems to use more descriptive and strongly typed enums.
    • Enhanced cutscene handling to include map identifiers.
    • Reorganized player update flow to better handle state skills and regeneration.
    • Improved skill consumption and synchronization logic in handlers.
    • Simplified buff management by updating compulsion event types.
    • Enhanced NPC talk cutscene packets to include map IDs.
  • Bug Fixes

    • Prevented negative stat values during updates.
    • Ensured regeneration intervals do not drop below a minimum threshold.
    • Added error logging for invalid motion points during skill casting.
  • Refactor

    • Unified and renamed skill handler logic for clarity.
    • Simplified trophy unlocking and error handling in commands.
    • Streamlined error handling in channel heartbeat responses.
    • Replaced exception throwing with logging and graceful failure in heartbeat.
    • Updated enum references and removed deprecated enums for consistency.

@coderabbitai

coderabbitai Bot commented May 14, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This update introduces new enums and constants, refactors skill and buff handling to use strongly typed enums, and enhances quest, skill, and achievement management. It adds new utility and debugging methods, restructures skill casting interfaces and logic, and improves regeneration and state skill handling. Several method signatures and internal logic were updated for clarity and robustness.

Changes

File(s) Change Summary
Maple2.Database/Storage/Metadata/QuestMetadataStorage.cs Added GetQuestsByChapter(int chapterId) method to filter quests by chapter.
Maple2.File.Ingest/Mapper/AdditionalEffectMapper.cs Replaced CompulsionEventType with BuffCompulsionEventType in mapping logic.
Maple2.File.Ingest/Mapper/SkillMapper.cs Added unused lists, improved enum parsing for State, added explicit enum casts, and updated region mapping logic.
Maple2.Model/Enum/Buff.cs, Maple2.Model/Metadata/AdditionalEffectMetadata.cs, Maple2.Server.Game/Manager/Config/BuffManager.cs, Maple2.Server.Game/Util/DamageCalculator.cs Introduced BuffCompulsionEventType enum and replaced all usages of CompulsionEventType with it.
Maple2.Model/Enum/CompulsionEventType.cs Deleted the CompulsionEventType enum.
Maple2.Model/Enum/Skill.cs, Maple2.Model/Metadata/SkillMetadata.cs Modified CompulsionType enum, added BounceType and [Flags] SuperArmor enums, and updated corresponding record fields to use enums.
Maple2.Model/Metadata/Constants.cs Added new constant MinStatIntervalTick = 100.
Maple2.Server.Game/Commands/PlayerCommand.cs Refactored job advancement and awakening logic, improved trophy unlocking, and updated experience addition.
Maple2.Server.Game/Manager/AchievementManager.cs Added DebugCompleteAllTrophies() to complete all trophies for debugging.
Maple2.Server.Game/Manager/QuestManager.cs Added DebugCompleteChapter(int chapterId) for debugging chapter completion.
Maple2.Server.Game/Manager/NpcScriptManager.cs, Maple2.Server.Game/Packets/NpcTalkPacket.cs Modified cutscene packet to include mapId parameter.
Maple2.Server.Game/Manager/StatsManager.cs Renamed loop variable and added a comment regarding regen intervals.
Maple2.Server.Game/Model/Field/Actor/Actor.cs, Maple2.Server.Game/Model/Field/Actor/FieldNpc.cs, Maple2.Server.Game/Model/Field/Actor/IActor.cs Refactored CastSkill method signatures, added local ID counter, improved splash skill effect handling, and added SkillAttackPoint method.
Maple2.Server.Game/Model/Field/Actor/FieldPlayer.cs Refactored update logic for state skills and regeneration, added UpdateStateSkill() local method, and improved stat handling.
Maple2.Server.Game/Model/Field/Actor/ActorStateComponent/MovementStateTasks/MovementState.SkillCastTask.cs Updated CastSkill call to include castTick and motionPoint.
Maple2.Server.Game/Model/Skill/SkillQueue.cs, Maple2.Server.Game/Model/Skill/SkillRecord.cs Added StateSkill field to SkillQueue and StateNextTick to SkillRecord for state skill tracking.
Maple2.Server.Game/Model/Stats.cs Ensured stat values do not drop below zero in addition methods.
Maple2.Server.Game/PacketHandlers/SkillHandler.cs Refactored skill handling logic, renamed Splash to CubeMagicPath, unified skill record handling, and improved method naming.
Maple2.Server.Game/PacketHandlers/StateSkillHandler.cs Improved state skill handling, added validation, and enhanced logging and skill record management.
Maple2.Server.Game/Service/ChannelService.Heartbeat.cs Replaced exceptions with warnings and graceful failure responses in heartbeat handling.

Sequence Diagram(s)

sequenceDiagram
    participant Player
    participant JobCommand
    participant QuestManager
    participant AchievementManager

    Player->>JobCommand: Request job change/awakening
    alt Awakening
        JobCommand->>QuestManager: DebugCompleteChapter(chapterId)
        QuestManager-->>JobCommand: Complete all quests in chapter
        JobCommand->>JobCommand: Advance to awakened job
        JobCommand->>JobCommand: UnlockMasterSkills()
    else Normal job change
        JobCommand->>JobCommand: JobAdvance(job)
    end
    JobCommand-->>Player: Update job, stats, and skills

    Player->>AchievementManager: UnlockAllTrophies (debug)
    AchievementManager->>AchievementManager: DebugCompleteAllTrophies()
    AchievementManager-->>Player: All trophies unlocked
Loading

Suggested labels

Skill / Buff

Suggested reviewers

  • AngeloTadeucci

Poem

A bunny hops through fields anew,
With enums strong and methods true.
Skills now cast with structured might,
Quests and trophies debugged right.
Regeneration ticks in time,
And jobs awaken—oh, how sublime!
Code carrots for all, in every line. 🥕

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cbb8f6b and 4db21ce.

📒 Files selected for processing (1)
  • Maple2.Server.Game/Model/Field/Actor/FieldNpc.cs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Maple2.Server.Game/Model/Field/Actor/FieldNpc.cs
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🧹 Nitpick comments (8)
Maple2.Server.Game/Manager/QuestManager.cs (1)

593-593: Consider error handling for invalid chapter IDs.

The method assumes that session.QuestMetadata.GetQuestsByChapter(chapterId) will always return a valid collection, but doesn't handle the case where an invalid chapter ID is provided.

-        IEnumerable<int> questIds = session.QuestMetadata.GetQuestsByChapter(chapterId).Select(q => q.Id);
+        var questMetadata = session.QuestMetadata.GetQuestsByChapter(chapterId);
+        if (!questMetadata.Any()) {
+            logger.Warning("No quests found for chapter ID: {chapterId}", chapterId);
+            return;
+        }
+        IEnumerable<int> questIds = questMetadata.Select(q => q.Id);
Maple2.Server.Game/Manager/AchievementManager.cs (1)

270-279: Minor perf/readability tweak – capture DateTime.Now once per trophy

DateTime.Now is evaluated for every single grade.
Grabbing it once per trophy avoids redundant sys-calls and keeps all grades in the same millisecond.

-            for (int grade = achievement.CurrentGrade; grade <= maxGrade; grade++) {
-                if (achievement.Grades.ContainsKey(grade)) {
-                    achievement.Grades[grade] = DateTime.Now.ToEpochSeconds();
+            long now = DateTime.Now.ToEpochSeconds();
+            for (int grade = achievement.CurrentGrade; grade <= maxGrade; grade++) {
+                if (achievement.Grades.ContainsKey(grade)) {
+                    achievement.Grades[grade] = now;
                     GiveReward(achievement);
                     continue;
                 }
-                achievement.Grades.Add(grade, DateTime.Now.ToEpochSeconds());
+                achievement.Grades.Add(grade, now);
                 GiveReward(achievement);
             }
Maple2.Server.Game/Manager/Config/BuffManager.cs (2)

29-39: Expose concurrency intent in the public type

Compulsions is initialised with a ConcurrentDictionary but typed as plain IDictionary.
Down-casting loses compile-time guarantees and invites accidental non-thread-safe replacements.

-    public IDictionary<BuffCompulsionEventType, IDictionary<int, AdditionalEffectMetadataStatus.CompulsionEvent>> Compulsions { get; init; }
+    public ConcurrentDictionary<BuffCompulsionEventType, IDictionary<int, AdditionalEffectMetadataStatus.CompulsionEvent>> Compulsions { get; init; }

Mirror this change in the constructor to avoid the extra generic cast.
(No functional change, but reinforces the contract to future maintainers.)


302-309: Thread safety when summing compulsion rates

nestedCompulsionDic.Values can be mutated concurrently by other threads.
Consider snapshotting the collection (e.g., ToArray()) before summing or locking the dictionary to avoid InvalidOperationException.

Maple2.Server.Game/Model/Field/Actor/FieldPlayer.cs (1)

186-202: Broadcast regen updates so nearby clients stay in sync

RecoverHp/Sp/Stamina only Session.Send(...) to the owner.
Other players never receive the updated stats, so party frames & damage
calculations drift.

Consider broadcasting after a successful regen tick:

     case BasicAttribute.Health:
         RecoverHp((int) regen.Total);
+        Field.Broadcast(StatsPacket.Update(this, BasicAttribute.Health));
         continue;

Apply the same pattern for Spirit and Stamina.

Maple2.Server.Game/Model/Field/Actor/Actor.cs (2)

337-339: Consider moving the broadcast out of CastSkill for clearer separation of concerns

CastSkill both creates a record and broadcasts it.
Handlers now need to remember not to broadcast again (bug above). Extracting the broadcast keeps Actor free of networking code and avoids future duplication.

If you keep it here, at least document it prominently.


201-206: Potential N² splash-effect loop

foreach target ➜ foreach effect ➜ AddSkill can create one skill entity per target × effect.
Large AoE skills with many targets & splash effects will scale poorly.

Consider:

• Deduplicating identical skill placements.
• Caching effect positions when multiples overlap.

Not urgent, but keep an eye on profiler data.

Maple2.Server.Game/Commands/PlayerCommand.cs (1)

141-155: Verbose switch duplication – maintainability concern

The giant JobCodeJob mapping appears three times (normal, awakened, base).
A single static Dictionary<JobCode, (Job Base, Job Awakened)> would:

• Remove copy-paste errors
• Make future job additions one-liner changes

Not blocking, but worth refactoring.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e1bbc6 and dd365f8.

⛔ Files ignored due to path filters (1)
  • Maple2.Server.World/Migrations/20250304061437_InteractCubeFix.cs is excluded by !Maple2.Server.World/Migrations/*
📒 Files selected for processing (28)
  • Maple2.Database/Storage/Metadata/QuestMetadataStorage.cs (1 hunks)
  • Maple2.File.Ingest/Mapper/AdditionalEffectMapper.cs (1 hunks)
  • Maple2.File.Ingest/Mapper/SkillMapper.cs (6 hunks)
  • Maple2.Model/Enum/Buff.cs (2 hunks)
  • Maple2.Model/Enum/CompulsionEventType.cs (0 hunks)
  • Maple2.Model/Enum/Skill.cs (2 hunks)
  • Maple2.Model/Metadata/AdditionalEffectMetadata.cs (1 hunks)
  • Maple2.Model/Metadata/Constants.cs (1 hunks)
  • Maple2.Model/Metadata/SkillMetadata.cs (2 hunks)
  • Maple2.Server.Game/Commands/PlayerCommand.cs (3 hunks)
  • Maple2.Server.Game/Manager/AchievementManager.cs (1 hunks)
  • Maple2.Server.Game/Manager/Config/BuffManager.cs (4 hunks)
  • Maple2.Server.Game/Manager/NpcScriptManager.cs (1 hunks)
  • Maple2.Server.Game/Manager/QuestManager.cs (1 hunks)
  • Maple2.Server.Game/Manager/StatsManager.cs (1 hunks)
  • Maple2.Server.Game/Model/Field/Actor/Actor.cs (3 hunks)
  • Maple2.Server.Game/Model/Field/Actor/ActorStateComponent/MovementStateTasks/MovementState.SkillCastTask.cs (1 hunks)
  • Maple2.Server.Game/Model/Field/Actor/FieldNpc.cs (1 hunks)
  • Maple2.Server.Game/Model/Field/Actor/FieldPlayer.cs (4 hunks)
  • Maple2.Server.Game/Model/Field/Actor/IActor.cs (2 hunks)
  • Maple2.Server.Game/Model/Skill/SkillQueue.cs (2 hunks)
  • Maple2.Server.Game/Model/Skill/SkillRecord.cs (1 hunks)
  • Maple2.Server.Game/Model/Stats.cs (1 hunks)
  • Maple2.Server.Game/PacketHandlers/SkillHandler.cs (9 hunks)
  • Maple2.Server.Game/PacketHandlers/StateSkillHandler.cs (2 hunks)
  • Maple2.Server.Game/Packets/NpcTalkPacket.cs (1 hunks)
  • Maple2.Server.Game/Service/ChannelService.Heartbeat.cs (1 hunks)
  • Maple2.Server.Game/Util/DamageCalculator.cs (2 hunks)
💤 Files with no reviewable changes (1)
  • Maple2.Model/Enum/CompulsionEventType.cs
🧰 Additional context used
🧬 Code Graph Analysis (4)
Maple2.Server.Game/Model/Skill/SkillQueue.cs (2)
Maple2.Server.Game/Model/Skill/SkillRecord.cs (2)
  • SkillRecord (7-70)
  • SkillRecord (39-44)
Maple2.Model/ModelExtensions.cs (1)
  • ActorState (97-246)
Maple2.Server.Game/Model/Field/Actor/FieldPlayer.cs (8)
Maple2.Server.Game/Session/GameSession.cs (1)
  • GameEvent (547-547)
Maple2.Server.Game/Model/Field/Actor/Actor.cs (3)
  • Update (298-315)
  • SkillRecord (319-340)
  • SkillCastConsume (349-351)
Maple2.Server.Game/Model/Stats.cs (8)
  • Stat (153-211)
  • Stat (161-161)
  • Stat (163-167)
  • Stats (8-151)
  • Stats (17-33)
  • Stats (35-41)
  • Total (118-128)
  • Add (194-196)
Maple2.Server.Game/Model/Skill/SkillQueue.cs (2)
  • Add (19-27)
  • SkillRecord (29-37)
Maple2.Model/Metadata/Constants.cs (1)
  • Constant (10-957)
Maple2.Server.Game/Packets/StatsPacket.cs (1)
  • StatsPacket (10-101)
Maple2.Server.Game/Manager/Field/FieldManager/IField.cs (1)
  • Broadcast (67-67)
Maple2.Server.Game/Packets/SkillPacket.cs (1)
  • SkillPacket (13-113)
Maple2.Server.Game/Manager/StatsManager.cs (2)
Maple2.File.Ingest/Utils/AttributeExtensions.cs (1)
  • BasicAttribute (6-44)
Maple2.Server.Game/Model/Stats.cs (1)
  • AddRate (190-192)
Maple2.Server.Game/Manager/AchievementManager.cs (3)
Maple2.Database/Model/Achievement.cs (1)
  • Achievement (11-57)
Maple2.Database/Storage/Game/GameStorage.Achievement.cs (4)
  • Achievement (14-20)
  • Achievement (60-66)
  • GameStorage (12-68)
  • Request (13-67)
Maple2.Database/Extensions/DateTimeExtensions.cs (1)
  • ToEpochSeconds (6-12)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: build
🔇 Additional comments (40)
Maple2.Server.Game/Manager/NpcScriptManager.cs (1)

379-379: Good update to cutscene call signature.

The method call has been properly updated to include the scriptFunction.MoveMapId parameter, which aligns with the modified Cutscene method signature in NpcTalkPacket.cs.

Maple2.Server.Game/Packets/NpcTalkPacket.cs (2)

101-101: Method signature extended to include map ID parameter.

The Cutscene method signature has been updated to include the mapId parameter, which enables the cutscene functionality to specify which map to transition to.


105-105: Writing map ID to the cutscene packet.

The new mapId parameter is now being written to the packet, allowing the client to receive this information during cutscene transitions.

Maple2.Database/Storage/Metadata/QuestMetadataStorage.cs (1)

64-66: Method implementation looks good!

New method GetQuestsByChapter follows the same pattern as other filter methods in the class. This is a well-implemented addition that enables filtering quests by chapter ID.

Maple2.Server.Game/Model/Skill/SkillRecord.cs (1)

35-35: Good addition for state skill management

The new StateNextTick field with clear documentation will help track timing for state skills, which aligns with the PR objectives to fix sync skill casting and state skills.

Maple2.Server.Game/Manager/StatsManager.cs (1)

183-185: Variable name improvement and helpful comment

The variable name change from ratespecialAttribute to rateBasicAttribute better represents the data being processed. The added comment explains the purpose of ensuring minimum regen intervals, which aligns with the PR objectives to fix state skills.

Maple2.Model/Metadata/Constants.cs (1)

105-105: Good constant addition for minimum stat interval

This new constant MinStatIntervalTick with value 100 (0.1 seconds) provides a clear, centralized definition for the minimum regeneration interval, which supports the PR's objective to fix state skills and skill casting.

Maple2.Model/Enum/Buff.cs (2)

35-35: Removed ambiguity in BuffCategory enum

The question mark has been removed from the Slow = 8 enum value, indicating that its purpose has been confirmed and is no longer uncertain.


95-100: Added new enum to improve type safety

The new BuffCompulsionEventType enum replaces the previously deleted CompulsionEventType enum, maintaining the same values but with a more descriptive name that better indicates its relationship to the buff system.

Using a byte as the underlying type is appropriate for this small enum and helps with memory efficiency. The naming is consistent with C# conventions and the values match the expected usage in the compulsion event system.

Maple2.Server.Game/Util/DamageCalculator.cs (3)

13-13: Updated to use the new BuffCompulsionEventType enum

References to the previous CompulsionEventType enum have been replaced with the new BuffCompulsionEventType enum for better type safety and naming consistency.


18-18: Updated to use the new BuffCompulsionEventType enum

References to the previous CompulsionEventType enum have been replaced with the new BuffCompulsionEventType enum for better type safety and naming consistency.


83-83: Updated to use the new BuffCompulsionEventType enum

References to the previous CompulsionEventType enum have been replaced with the new BuffCompulsionEventType enum for better type safety and naming consistency.

Maple2.Model/Metadata/AdditionalEffectMetadata.cs (1)

88-88: Updated CompulsionEvent record to use new enum type

The CompulsionEvent record now uses the BuffCompulsionEventType enum instead of the previous CompulsionEventType enum, which is consistent with the type replacement across the codebase.

Maple2.Server.Game/Model/Skill/SkillQueue.cs (3)

1-3: Added necessary using directive for ActorState enum

Added the required using directive for the Maple2.Model.Enum namespace, which is needed for the ActorState enum used in the new conditions.


11-11: Added StateSkill tracking to improve state skill management

Added a new public nullable field to explicitly track the most recent skill with a non-None state, making it easier to access and manage state skills.

This change aligns with the PR objective of fixing issues with state skills and improves the handling of state-related skills like fast swimming.


22-24: Added logic to track state skills separately

Enhanced the Add method to update the StateSkill field whenever a skill with a non-None state is added to the queue. This provides an explicit way to track the active state skill without disrupting the existing circular buffer functionality.

This implementation ensures that state skills (like swimming or other movement-related skills) are properly tracked and can be easily accessed, which helps resolve the issues mentioned in the PR objectives.

Maple2.Server.Game/Model/Stats.cs (2)

169-173: Great defensive programming improvement!

Adding Math.Max(0, ...) ensures that stat values never go below zero, preventing potential issues with negative stats in game mechanics. This is a valuable safeguard that improves game state consistency.


175-178: Good consistency with non-negative enforcement

Similarly, this change ensures the Total and Current values remain non-negative when modified through the AddTotal method, maintaining the same protection pattern applied to AddBase.

Maple2.Model/Metadata/SkillMetadata.cs (2)

45-45: Improved type safety with enum replacement

Replacing the integer field with the strongly-typed SuperArmor enum improves code clarity and reduces the risk of bugs due to invalid values. This makes the codebase more maintainable and self-documenting.


142-142: Good use of strongly-typed enum

Similar to the previous change, using the BounceType enum instead of an integer improves type safety and makes the code more readable and maintainable. This change aligns with C# best practices.

Maple2.File.Ingest/Mapper/AdditionalEffectMapper.cs (2)

161-164: Consistent enum usage across codebase

This change replaces CompulsionEventType with BuffCompulsionEventType, maintaining consistent enum usage throughout the system. This standardization helps prevent bugs from mismatched enum types and improves code maintainability.


167-167: Maintaining logical consistency with new enum type

The condition check has been updated to use the new enum type while preserving the same logical behavior, ensuring seamless integration with the rest of the codebase.

Maple2.Server.Game/Service/ChannelService.Heartbeat.cs (3)

4-4: Good addition of structured logging

Adding Serilog for structured logging is a great improvement that will help with debugging and monitoring.


10-15: Excellent error handling improvement

Replacing thrown exceptions with logged warnings and graceful failure responses is a significant improvement in error handling. This approach is much more robust for a service that needs to handle potentially invalid requests without disrupting other operations.


16-21: Improved service reliability

Similar to the previous change, this replaces an exception with proper logging and a controlled failure response. This pattern makes the service more reliable and easier to debug when issues occur.

Maple2.Server.Game/Model/Field/Actor/ActorStateComponent/MovementStateTasks/MovementState.SkillCastTask.cs (1)

92-92: Method call updated to include field tick parameter.

The CastSkill method call now includes the current field tick (cast to an integer) and explicitly specifies the motionPoint parameter. This aligns with the broader changes to skill casting functionality that require precise timing information.

Maple2.Server.Game/Manager/QuestManager.cs (1)

586-630: New debugging utility for completing chapter quests added.

This new method provides a clean way to silently complete all quests in a specified chapter for debugging purposes. It correctly handles both existing and non-existing quests, properly manages quest conditions, and updates the database appropriately.

The implementation:

  1. Retrieves all quests for the specified chapter
  2. Updates existing quests or creates new completed ones
  3. Loads the quests to refresh the client state

This complements other debugging utilities in the PR like trophy completion.

Maple2.File.Ingest/Mapper/SkillMapper.cs (5)

20-21: Unused lists added for future implementation.

Two new empty lists (magicPaths and cubeMagicPaths) have been added but are not yet used in the code. These appear to be placeholders for future functionality related to magic path tracking.

Are these lists intended to be used in a future commit, or were they meant to be used already in this implementation?


73-73: Improved type safety with BounceType enum.

The cast to the newly added BounceType enum provides better type safety and readability compared to using raw integer values.


119-126: Enhanced state parsing using attribute-based lookup.

The parsing of the State property has been significantly improved by using attribute-based lookup for ActorState enum values. This is a more robust approach that relies on DescriptionAttribute metadata rather than simple string matching, and properly defaults to ActorState.None when the value is empty or unmatched.


138-138: Improved type safety with SuperArmor enum.

The cast to the newly added SuperArmor flags enum provides better type safety and readability compared to using integer values.


153-153: Added mapping for 'circle' region type.

Properly mapping the "circle" string to the SkillRegion.Cylinder enum value ensures that skills defining circular regions will be correctly interpreted.

Maple2.Model/Enum/Skill.cs (3)

204-211: New BounceType enum added for bounce behaviors.

A new BounceType enum has been introduced to define various bounce behaviors for skills. This supports the explicit typing in SkillMapper.cs and improves code readability by replacing raw integers with meaningful enum values.


213-218: New SuperArmor flags enum added for immunity types.

A new SuperArmor flags enum has been introduced to represent different types of immunity (stun and knockback). Using a flags enum is appropriate here as a skill can provide multiple types of immunity simultaneously.


186-190:

Details

✅ Verification successful

CompulsionType enum has been revised with new values.

The CompulsionType enum has been updated to replace its previous members with new members (Hit, Critical, Interrupt), with Interrupt marked as unconfirmed. This change affects how compulsion effects are interpreted in skills.

Have all references to the old CompulsionType values been updated throughout the codebase? Run this script to check for potential issues:


🏁 Script executed:

#!/bin/bash
# Check for any remaining references to old CompulsionType values
echo "Checking for references to old CompulsionType values..."
rg -l "CompulsionType\.Evasion|CompulsionType\.Block" --type cs

Length of output: 186


All old CompulsionType values removed and no lingering references found

A search for CompulsionType.Evasion and CompulsionType.Block returned no matches in the codebase, confirming that all references to the old enum members have been updated.

Maple2.Server.Game/PacketHandlers/StateSkillHandler.cs (1)

43-44: Verify tick-unit conversion & possible overflow

FieldTick appears to count server ticks, whereas TimeSpan.TotalMilliseconds returns real-time milliseconds.
If FieldTick is not millisecond-based this will skew StateNextTick.
Also, casting the double result to int can overflow for long animations.

Please double-check the units or switch to long:

-        cast.StateNextTick = session.Field.FieldTick + (int) TimeSpan.FromSeconds(cast.Motion.MotionProperty.SequenceSpeed).TotalMilliseconds;
+        long delayMs = (long) TimeSpan.FromSeconds(cast.Motion.MotionProperty.SequenceSpeed).TotalMilliseconds;
+        cast.StateNextTick = session.Field.FieldTick + delayMs;
Maple2.Server.Game/Model/Field/Actor/IActor.cs (1)

34-35: Interface update looks good

The enriched CastSkill signature propagates timing and spatial data and aligns
with the concrete implementations. No issues spotted.

Maple2.Server.Game/Model/Field/Actor/FieldPlayer.cs (1)

142-145: Early game-event update placement is sensible

Moving Session.GameEvent.Update(tickCount) to the top guarantees event logic
runs even if the player dies early in the frame. Nice catch.

Maple2.Server.Game/PacketHandlers/SkillHandler.cs (1)

349-353: Good: failure path now notifies the caller

The extra SkillUseFailedPacket.Fail(record) guarantees clients receive feedback when SkillCastConsume vetoes the cast.
Nice improvement.

Maple2.Server.Game/Commands/PlayerCommand.cs (1)

503-509: Good simplification of trophy unlock logic

DebugCompleteAllTrophies centralises the heavy work, and the command now provides clear user feedback – nice 👍

Comment thread Maple2.Server.Game/Manager/AchievementManager.cs Outdated
Comment thread Maple2.Server.Game/PacketHandlers/StateSkillHandler.cs
Comment thread Maple2.Server.Game/Model/Field/Actor/FieldNpc.cs Outdated
Comment thread Maple2.Server.Game/Model/Field/Actor/FieldNpc.cs
Comment thread Maple2.Server.Game/Model/Field/Actor/FieldPlayer.cs
Comment thread Maple2.Server.Game/PacketHandlers/SkillHandler.cs
Comment thread Maple2.Server.Game/PacketHandlers/SkillHandler.cs
Comment thread Maple2.Server.Game/Model/Field/Actor/Actor.cs
Comment thread Maple2.Server.Game/Commands/PlayerCommand.cs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
Maple2.Server.Game/Model/Field/Actor/Actor.cs (1)

326-329: ⚠️ Potential issue

Fix rotation assignment logic

There's an issue with the rotation assignment in the CastSkill method. The current implementation always assigns the property Rotation to itself when Rotation == default, which has no effect.

-            Rotation = Rotation == default ? Rotation : rotation,
+            Rotation = rotation == default ? Rotation : rotation,
             Rotate2Z = rotateZ,
             ServerTick = castTick,

This fix ensures that when a default rotation is provided, the actor's current rotation is used; otherwise, the provided rotation is applied.

🧹 Nitpick comments (2)
Maple2.Server.Game/Model/Field/Actor/Actor.cs (1)

209-211: Consider adding documentation for the empty virtual method

This new virtual method is meant to be overridden by derived classes, but it's currently lacking documentation to explain its purpose and how it should be used.

+    /// <summary>
+    /// Handles skill attack point processing. Override this method in derived classes to implement specific behavior.
+    /// </summary>
+    /// <param name="record">The skill record containing skill data</param>
+    /// <param name="attackPoint">The attack point to process</param>
     public virtual void SkillAttackPoint(SkillRecord record, byte attackPoint) {

     }
Maple2.Server.Game/Commands/PlayerCommand.cs (1)

178-222: Consider reducing code duplication in job mapping

The method correctly implements the awakening functionality, but contains duplicate job code mapping logic.

Consider refactoring the duplicate job mapping code into a helper method:

-        private void Awaken(InvocationContext ctx, JobCode jobCode) {
-            Job awakenedJob = jobCode switch {
-                JobCode.Newbie => Job.Newbie,
-                JobCode.Knight => Job.KnightII,
-                JobCode.Berserker => Job.BerserkerII,
-                JobCode.Wizard => Job.WizardII,
-                JobCode.Priest => Job.PriestII,
-                JobCode.Archer => Job.ArcherII,
-                JobCode.HeavyGunner => Job.HeavyGunnerII,
-                JobCode.Thief => Job.ThiefII,
-                JobCode.Assassin => Job.AssassinII,
-                JobCode.RuneBlader => Job.RuneBladerII,
-                JobCode.Striker => Job.StrikerII,
-                JobCode.SoulBinder => Job.SoulBinderII,
-                _ => throw new ArgumentException($"Invalid JobCode: {jobCode}"),
-            };
-            Job baseJob = jobCode switch {
-                JobCode.Newbie => Job.Newbie,
-                JobCode.Knight => Job.Knight,
-                JobCode.Berserker => Job.Berserker,
-                JobCode.Wizard => Job.Wizard,
-                JobCode.Priest => Job.Priest,
-                JobCode.Archer => Job.Archer,
-                JobCode.HeavyGunner => Job.HeavyGunner,
-                JobCode.Thief => Job.Thief,
-                JobCode.Assassin => Job.Assassin,
-                JobCode.RuneBlader => Job.RuneBlader,
-                JobCode.Striker => Job.Striker,
-                JobCode.SoulBinder => Job.SoulBinder,
-                _ => throw new ArgumentException($"Invalid JobCode: {jobCode}"),
-            };
+        private void Awaken(InvocationContext ctx, JobCode jobCode) {
+            Job awakenedJob = GetAwakenedJob(jobCode);
+            Job baseJob = GetBaseJob(jobCode);
+            
+            // Add these helper methods to the class:
+            // private Job GetAwakenedJob(JobCode jobCode) { ... }
+            // private Job GetBaseJob(JobCode jobCode) { ... }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c06789 and cbb8f6b.

📒 Files selected for processing (5)
  • Maple2.Server.Game/Commands/PlayerCommand.cs (3 hunks)
  • Maple2.Server.Game/Manager/AchievementManager.cs (1 hunks)
  • Maple2.Server.Game/Model/Field/Actor/Actor.cs (3 hunks)
  • Maple2.Server.Game/Model/Field/Actor/FieldNpc.cs (1 hunks)
  • Maple2.Server.Game/Model/Field/Actor/FieldPlayer.cs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • Maple2.Server.Game/Manager/AchievementManager.cs
  • Maple2.Server.Game/Model/Field/Actor/FieldNpc.cs
  • Maple2.Server.Game/Model/Field/Actor/FieldPlayer.cs
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: build
🔇 Additional comments (8)
Maple2.Server.Game/Model/Field/Actor/Actor.cs (3)

54-59: Good addition of thread-safe local ID counter

The introduction of a thread-safe local ID counter using Interlocked.Increment is a solid implementation choice for generating unique skill casting IDs. This will prevent conflicts when multiple skills are cast simultaneously in a multi-threaded environment.


201-207: Good implementation of splash skill effects

This enhancement properly handles splash effects by iterating over targets and applying effects at their positions. The implementation aligns with the PR objective of fixing sync skill casting issues.

Note: The code uses collection expression syntax [target.Position] which requires C# 12.


333-334: Good error logging for invalid motion point

Adding detailed error logging for invalid motion points will help with debugging issues in production. Consider including more context about why the motion point is invalid, such as expected range or requirements.

Maple2.Server.Game/Commands/PlayerCommand.cs (5)

86-86: Fix implemented for experience command

The code now correctly adds experience points using the ExpType.expDrop parameter, addressing the issue mentioned in the PR objectives.


157-170: Improved job command logic with proper exit code handling

The refactored logic properly handles both regular job changes and awakening cases, with appropriate exit code assignment in all paths (addressing the previous review feedback about missing exit codes).


224-249: Well-structured job advancement implementation

The method properly handles different job advancement scenarios, including:

  • Clearing skill tabs when changing job codes
  • Removing awakening skills when downgrading
  • Refreshing buffs and stats
  • Broadcasting the job change

This implementation helps fulfill the PR objective of fixing job command functionality.


251-262: Master skills unlocking logic implemented correctly

This method successfully implements the automatic completion of the master skill quest line, as mentioned in the PR objectives.


502-509: Trophy command simplified and fixed

The implementation now correctly uses DebugCompleteAllTrophies() followed by reloading achievements, which should fix the issue mentioned in the PR objectives about trophy unlocking not working properly.

@AngeloTadeucci
AngeloTadeucci merged commit 36cf4fc into master May 14, 2025
@AngeloTadeucci
AngeloTadeucci deleted the skills branch May 14, 2025 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants