Skip to content

Changed maximum attack speed is not considered #663

@sven-n

Description

@sven-n

Describe the bug
A changed maximum value of an attribute (e.g. at attack speed) is not considered when requesting it from the AttributeSystem.

To Reproduce
Steps to reproduce the behavior:

  1. Add 5000 agility to the testgmDk character on the admin panel
  2. Change the maximum value of the AttackSpeed attribute on the admin panel to 300
  3. Log into the game (MuMain, extended protocol) with the testgm account and select the testgmDk character
  4. See that the attack speed reports as 200 (the default).

Expected behavior
The attack speed should be reported as 300.

Additional context
The fix is probably to use the actual attribute defintion at AttributeSystem.GetValueOfAttribute. Currently, the AttributeDefinition which is passed as argument is used. However, this is not the same instance as the one which is configured.
This should probably work (see AttributeSystem.cs):

    /// <inheritdoc/>
    public float GetValueOfAttribute(AttributeDefinition? attributeDefinition)
    {
        var element = this.GetAttribute(attributeDefinition);
        if (element != null)
        {
            var actualDefinition = (element as BaseAttribute)?.Definition ?? attributeDefinition;
            if (actualDefinition?.MaximumValue is { } maximumValue && element.Value > maximumValue)
            {
                return maximumValue;
            }

            return element.Value;
        }

        return 0;
    }

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions