You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cast the specialist's skill while transformed - #3603
Class skills and specialist skills reuse the same cast ids. For example, Ice Bolt (mage) and Volcano's Magma Plating are both cast id 3, and Magic Bullet and Holy Mage's Holy Weapon are both cast id 8.
SkillService.LoadSpecialistSkillsAsync adds the specialist's skills next to the class skills in character.Skills, and SkillResolver.FindLearned searched all of them by cast id without looking at UseSp. A transformed player's cast could therefore resolve to the class skill. That skill's target type no longer matched what the client sent (Magma Plating targets the caster, Ice Bolt an enemy), so the cast was cancelled (cancel 2 ...) and most specialist skills could not be used.
FindLearned is used both by the packet guard (UseSkillPacketHandler, UseAoeSkillPacketHandler, cooldown and mana) and by SkillResolver.Resolve, so both picked the wrong skill.
Fix
FindLearned now only searches the skills the character can cast right now: the specialist's skills (IsSpecialist()) while transformed, the class's otherwise.
Tests
In SkillResolverTests, with a character knowing both Ice Bolt (263) and Magma Plating (1081) on cast id 3:
ATransformedCharacterCastsTheSpecialistSkillOfACastIdItsClassAlsoUses: transformed, cast id 3 resolves to Magma Plating. This test fails without the fix.
AnUntransformedCharacterCastsTheClassSkillOfACastIdASpecialistAlsoUses: untransformed, it resolves to Ice Bolt.
The skill and battle tests (607 in NosCore.GameObject.Tests) and the skill, battle and mate packet handler tests (156) pass. Also checked in game: Volcano's skills, cancelled before the fix, now cast.
Summary by CodeRabbit
Bug Fixes
Skill selection now accounts for a character’s transformation state when choosing between learned skills that share a cast ID. Transformed characters select the specialist skill, while untransformed characters select the non-specialist skill.
Reviewing files that changed from the base of the PR and between 4216084 and 64fc2cd.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
FindLearned now filters skills by the character's transformation state. Tests verify that it selects the specialist skill when transformed and the class skill when untransformed.
Changes
Skill Lookup
Layer / File(s)
Summary
Filter and verify learned skills src/NosCore.GameObject/Services/BattleService/SkillResolver.cs, test/NosCore.GameObject.Tests/Services/BattleService/SkillResolverTests.cs
FindLearned now matches specialist status to character.UseSp. Tests use two skills with cast ID 3 and assert the expected selection for each transformation state.
NosCoreIO/NosCore#2652: Uses the skill returned by FindLearned for mana, cooldown, and reach checks.
NosCoreIO/NosCore#2878: Changes which learned skills FindLearned considers for a shared cast ID.
NosCoreIO/NosCore#2622: Unlocks specialist skills in cast order, which this lookup can search when a character is transformed.
Suggested reviewers: claude, erwan-joly
Merge Risk: Minimal · previous review 42160
This change makes a transformed character cast the specialist skill, not a class skill that shares its cast ID. Tests cover both states, and no actionable merge risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "Cast the specialist's skill while transformed" matches the main change. The PR changes SkillResolver.FindLearned to pick specialist skills while transformed and non-specialist skills otherw…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "Cast the specialist's skill while transformed" matches the main change. The PR changes SkillResolver.FindLearned to pick specialist skills while transformed and non-specialist skills otherwise, which fixes cast-ID collisions between class and specialist skills. The title is specific and describes the primary behavior change, and it does not include file lists or vague terms.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
Class and specialist skills reuse the same cast ids: Ice Bolt and
Volcano's Magma Plating are both 3, Magic Bullet and Holy Mage's Holy
Weapon are both 8. Loading a specialist adds its skills next to the class
ones, and FindLearned searched them all, so a transformed player's cast
could resolve to the class skill. Its target type did not match what the
client sent, and the cast was cancelled: most specialist skills could not
be used.
Only search the specialist's skills while transformed, and the class's
otherwise.
The reason will be displayed to describe this comment to others. Learn more.
Reviewed and tested on top of current master (9cc1908), since CI has not run on this fork's branch.
The change reads right. While transformed, the cast-id lookup only searches the specialist's skills, and otherwise only the class's. That matches the skill bar the client shows, so a specialist skill that shares its cast id with a class skill (Magma Plating and Ice Bolt, both 3) now resolves to the specialist's. Upgrade lookups still go through every skill, and passives are untouched.
Results after rebasing onto master:
dotnet build NosCore.sln: 0 errors.
GameObject.Tests 2822/2822 and PacketHandlers.Tests 1003/1003.
End-to-end Fight, Specialist and Skill scenarios: 29 of 31 on the first run, while the lab database went down mid-run. The two that failed (TheLivingCannotReviveThemselvesBackToFullHp and ASkillIsRefusedToSomeoneWithoutTheMpForIt) pass when re-run, so nothing in this change broke them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Class skills and specialist skills reuse the same cast ids. For example, Ice Bolt (mage) and Volcano's Magma Plating are both cast id 3, and Magic Bullet and Holy Mage's Holy Weapon are both cast id 8.
SkillService.LoadSpecialistSkillsAsyncadds the specialist's skills next to the class skills incharacter.Skills, andSkillResolver.FindLearnedsearched all of them by cast id without looking atUseSp. A transformed player's cast could therefore resolve to the class skill. That skill's target type no longer matched what the client sent (Magma Plating targets the caster, Ice Bolt an enemy), so the cast was cancelled (cancel 2 ...) and most specialist skills could not be used.FindLearnedis used both by the packet guard (UseSkillPacketHandler,UseAoeSkillPacketHandler, cooldown and mana) and bySkillResolver.Resolve, so both picked the wrong skill.Fix
FindLearnednow only searches the skills the character can cast right now: the specialist's skills (IsSpecialist()) while transformed, the class's otherwise.Tests
In
SkillResolverTests, with a character knowing both Ice Bolt (263) and Magma Plating (1081) on cast id 3:ATransformedCharacterCastsTheSpecialistSkillOfACastIdItsClassAlsoUses: transformed, cast id 3 resolves to Magma Plating. This test fails without the fix.AnUntransformedCharacterCastsTheClassSkillOfACastIdASpecialistAlsoUses: untransformed, it resolves to Ice Bolt.The skill and battle tests (607 in
NosCore.GameObject.Tests) and the skill, battle and mate packet handler tests (156) pass. Also checked in game: Volcano's skills, cancelled before the fix, now cast.Summary by CodeRabbit