-
Notifications
You must be signed in to change notification settings - Fork 34
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
[Tweak] Melee / Ближнее Оружие #62
Conversation
WalkthroughThe pull request implements substantial modifications to the melee combat system in the codebase. Key changes include the reorganization of namespaces for the Changes
Possibly related PRs
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (2)
Files skipped from review as they are similar to previous changes (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
Content.Server/_White/Melee/Crit/CritComponent.cs (1)
12-12
: Clarify the purpose and usage of theRealChance
property.The
RealChance
property is a nullable float, but its intended purpose and usage are unclear from the code alone. Consider adding comments or documentation to explain how this property is meant to be utilized within the critical hit system.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (10)
- Content.Server/_White/Melee/BackStab/BackStabComponent.cs (1 hunks)
- Content.Server/_White/Melee/BackStab/BackStabSystem.cs (2 hunks)
- Content.Server/_White/Melee/Crit/CritComponent.cs (1 hunks)
- Content.Server/_White/Melee/Crit/CritSystem.cs (1 hunks)
- Resources/Locale/en-US/_white/backstab/backstab.ftl (0 hunks)
- Resources/Locale/en-US/_white/melee/backstab.ftl (1 hunks)
- Resources/Locale/en-US/_white/melee/crit.ftl (1 hunks)
- Resources/Locale/ru-RU/_white/backstab/backstab.ftl (0 hunks)
- Resources/Locale/ru-RU/_white/melee/backstab.ftl (1 hunks)
- Resources/Locale/ru-RU/_white/melee/crit.ftl (1 hunks)
Files not reviewed due to no reviewable changes (2)
- Resources/Locale/en-US/_white/backstab/backstab.ftl
- Resources/Locale/ru-RU/_white/backstab/backstab.ftl
Files skipped from review due to trivial changes (4)
- Content.Server/_White/Melee/BackStab/BackStabComponent.cs
- Resources/Locale/en-US/_white/melee/backstab.ftl
- Resources/Locale/ru-RU/_white/melee/backstab.ftl
- Resources/Locale/ru-RU/_white/melee/crit.ftl
Additional comments not posted (10)
Resources/Locale/en-US/_white/melee/crit.ftl (1)
1-1
: LGTM!The localization string for critical hit damage is well-defined and follows the FTL (Fluent) format. The placeholder
{$damage}
is correctly used to dynamically insert the actual damage value. This addition enhances the user experience by providing clear feedback on critical hits.Content.Server/_White/Melee/Crit/CritComponent.cs (1)
1-13
: TheCritComponent
class implementation looks good!The
CritComponent
class provides a solid foundation for managing critical hit mechanics within the melee combat system. The default values forCritChance
andCritMultiplier
seem balanced, but their impact on gameplay should be monitored and adjusted as needed.Content.Server/_White/Melee/BackStab/BackStabSystem.cs (5)
1-8
: LGTM!The added using directives are consistent with the changes made to the
BackStabSystem
class.
9-9
: Namespace change looks good!Moving the
BackStabSystem
class to theContent.Server._White.Melee.BackStab
namespace improves the organization of the codebase and reflects the server-specific nature of the class.
15-15
: Dependency change is appropriate!Changing the
SharedPopupSystem
dependency toPopupSystem
aligns with the server-specific nature of theBackStabSystem
class.
51-52
: Localization key update is an improvement!The new localization key,
"melee-backstab-damage"
, is more descriptive and consistent with the context of the backstab damage message. This change improves the clarity and maintainability of the localization system.
Line range hint
1-54
: Removing theINetManager
dependency is a good decision!The removal of the
INetManager
dependency aligns with the server-specific nature of theBackStabSystem
class and improves the maintainability and performance of the codebase by eliminating unused dependencies.Content.Server/_White/Melee/Crit/CritSystem.cs (3)
12-53
: LGTM!The
CritSystem
class is well-implemented and follows good coding practices. It has a clear single responsibility, well-defined dependencies, and a logical flow for handling critical hits in melee attacks.The core logic for processing critical hits is properly encapsulated within the
HandleHit
method, which checks for hit entities, determines if the hit is critical, calculates the bonus damage, updates the event data, and displays a popup message to the user.The
IsCriticalHit
method uses theIRobustRandom
to generate random values and compare them with the critical hit chance defined in theCritComponent
. It also manages the dynamic adjustment of the critical hit chance based on the outcome of the current hit.The code is well-structured, readable, and follows consistent naming conventions. The use of dependency injection and event subscription aligns with best practices.
Overall, the implementation of the
CritSystem
class is solid and enhances the melee combat mechanics by introducing critical hits.
23-38
: LGTM!The
HandleHit
method is well-structured and handles the critical hit logic effectively. It follows a clear flow of checking the necessary conditions, calculating the bonus damage, updating the event data, and providing user feedback.The method starts by checking if there are any hit entities and if the hit is critical using the
IsCriticalHit
method. This early return avoids unnecessary processing if the conditions are not met.If the hit is critical, the method calculates the bonus damage by multiplying the base damage by the critical multiplier defined in the
CritComponent
. It then updates theBonusDamage
property of theMeleeHitEvent
with a newDamageSpecifier
that represents the additional damage dealt by the critical hit. The usage of the "Slash" damage type prototype and the calculated bonus damage ensures consistent damage application.Finally, the method displays a localized popup message to the user indicating the critical hit damage using the
PopupSystem
. The message is constructed using theLoc.GetString
method with the appropriate localization key and the formatted damage value.Overall, the
HandleHit
method is well-implemented and effectively handles the critical hit logic for melee attacks.
40-52
: LGTM!The
IsCriticalHit
method is well-implemented and provides a clean and concise way to determine if a hit is critical based on the chance defined in theCritComponent
.The method starts by checking if the
RealChance
property of the component is null and initializes it with the baseCritChance
value if necessary. This ensures that theRealChance
property is always properly initialized before being used.The method then generates a random float value using the
IRobustRandom
and compares it with theRealChance
value. If the random value is less than or equal to theRealChance
, the hit is considered critical. This logic effectively simulates the probability of a critical hit occurring based on the defined chance.If the hit is critical, the method resets the
RealChance
to the baseCritChance
value defined in the component. This ensures that the critical hit chance is reset to its original value after a successful critical hit, maintaining consistency with the intended mechanics.If the hit is not critical, the method increments the
RealChance
value. This dynamic adjustment of the critical hit chance for future hits adds an interesting gameplay element, increasing the likelihood of a critical hit occurring if the current hit is not critical. It provides a sense of escalating tension and rewards players for persistent attacks.The method returns a boolean value indicating whether the hit is critical or not, making it easy to use and integrate with other parts of the codebase.
Overall, the
IsCriticalHit
method is well-structured, readable, and effectively determines the criticality of a hit based on the defined chance and dynamic adjustments.
Описание PR
Переместил систему удара в спину на сервер. Добавил систему критического попадания для кровавого кинжала