Monster Attribute Scaler Plugin#772
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new feature plugin designed to enhance game difficulty by scaling monster attributes. It leverages the existing plugin architecture to apply multiplicative modifiers to monster stats at spawn time, while providing a configurable interface for server administrators to adjust these values. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new MonsterAttributeScaler plugin and its associated configuration to scale monster attributes like health, damage, and defense by a configurable percentage. The code review identified a critical issue where attribute modifiers were not being removed when monsters were removed from the map, which could lead to stat stacking on respawn. Additionally, feedback was provided to refine the health-scaling logic to prevent unintended healing or resurrection, and a suggestion was made to replace Console.WriteLine with a structured logging framework.
sven-n
left a comment
There was a problem hiding this comment.
Configuration changes in the Admin Panel require a server restart to take effect.
Do you know why? Because the plugin creates one element per monster and never updates it again.
How about this solution:
- The plugin just holds one SimpleElement and shares it between all monsters by adding the same instance to all monsters. No tracking of monsters required.
- When configuration changed, simply apply the change to the one shared SimpleElement instance.
Can you try that?
It could also be interesting to add percentages for different kind of attributes. At the moment, it scales every attribute by the same percentage.
|
Good idea I will try this your solution. I tried to make a plugin as simple as it possible and try to not change anything in source code only plugin files. |
|
Plugin now allows setting % to each stat + option change to all. Also I've implemented your soulution. |
|
Long tests ingame with debug and logging. But finally plugin works as it should - tested in game. (1st PR message updated). Here is an detailed explanation from AI. Bug found and fixed: Live configuration updates from Admin Panel silently did nothing. Root cause: In Fix: Replaced every usage of the |
|
Thank you :) |
Monster Attribute Scaler Plugin
What it does:
A feature plugin that scales monster base stats by a configurable percentage.
Each stat group (Damage, AttackRate, DefenseRate, Defense, Health) has its own
percentage setting. Default: +25% to MinimumPhysBaseDmg, MaximumPhysBaseDmg,
AttackRatePvm, DefenseRatePvm, DefenseBase, and MaximumHealth. Supports a
"Scale All" option that sets all stat groups at once. Starts disabled by default.
How it works:
The plugin uses shared multiplicative IElement instances, one per stat group,
added to all monsters at spawn time via IObjectAddedToMapPlugIn and removed
on despawn via IObjectRemovedFromMapPlugIn. Configuration changes in the
Admin Panel take effect immediately by mutating the shared element values,
which propagate to all active monsters through the attribute system's
ValueChanged event. The configuration class handles ScaleAll cascading and
individual field isolation at the property level.
Bug fix — ConfigurationChangeHandler (not plugin-specific, but required for live updates):
The OnPlugInConfigurationChanged method passed the entity primary key (Id)
instead of plugInConfiguration.TypeId to all PlugInManager calls. This caused
ActivatePlugIn, DeactivatePlugIn, and ConfigurePlugIn to silently no-op because
PlugInManager looks up plugins by their [Guid] TypeId, not by the database entity
PK. Fix: replaced 'id' with 'plugInConfiguration.TypeId' in all four calls.
Files modified for this plugin:
OpenMU/src/GameLogic/Properties/PlugInResources.resx
OpenMU/src/GameLogic/Properties/PlugInResources.Designer.cs
Files modified (bug fix, required for live updates):
OpenMU/src/Startup/ConfigurationChangeHandler.cs
Files added for this plugin:
OpenMU/src/GameLogic/PlugIns/MonsterAttributeScaler.cs
OpenMU/src/GameLogic/PlugIns/MonsterAttributeScalerConfiguration.cs