Skip to content

Commit

Permalink
Fixed attack speed when equipping two weapons
Browse files Browse the repository at this point in the history
  • Loading branch information
sven-n committed Oct 18, 2024
1 parent 0bd52d5 commit 1ad5937
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
23 changes: 22 additions & 1 deletion src/GameLogic/Attributes/Stats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,28 @@ public class Stats
/// <summary>
/// Gets the attack speed attribute definition.
/// </summary>
public static AttributeDefinition AttackSpeed { get; } = new (new Guid("BACC1115-1E8B-4E62-B952-8F8DDB58A949"), "Attack Speed", string.Empty);
public static AttributeDefinition AttackSpeed { get; } = new(new Guid("BACC1115-1E8B-4E62-B952-8F8DDB58A949"), "Attack Speed", string.Empty)
{
MaximumValue = 200,
};

/// <summary>
/// Gets the attack speed by weapon attribute definition.
/// </summary>
public static AttributeDefinition AttackSpeedByWeapon { get; } = new(new Guid("45EEEDEE-C76B-40E6-A0BC-2B493E10B140"), "Attack Speed by Weapons", string.Empty);

/// <summary>
/// Gets the attribute which says, if two weapons are equipped.
/// </summary>
public static AttributeDefinition AreTwoWeaponsEquipped { get; } = new(new Guid("56DA895D-BAFD-4A5C-9864-B17AB8369998"), "Are two weapons equipped", string.Empty)
{
MaximumValue = 1,
};

/// <summary>
/// Gets the attribute which counts the equipped weapons.
/// </summary>
public static AttributeDefinition EquippedWeaponCount { get; } = new(new Guid("15D6493F-549D-455F-9FFF-A0D589FD7DA2"), "Equipped Weapon Count", string.Empty);

/// <summary>
/// Gets the magic speed attribute definition which is used for some skills.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ private void AddCommonAttributeRelationships(ICollection<AttributeRelationship>
attributeRelationships.Add(this.CreateAttributeRelationship(Stats.DefensePvm, 1, Stats.DefenseBase));
attributeRelationships.Add(this.CreateAttributeRelationship(Stats.DefensePvp, 1, Stats.DefenseBase));

attributeRelationships.Add(this.CreateAttributeRelationship(Stats.AttackSpeed, 1, Stats.AttackSpeedByWeapon));
attributeRelationships.Add(this.CreateAttributeRelationship(Stats.MagicSpeed, 1, Stats.AttackSpeedByWeapon));

// If two weapons are equipped we subtract the half of the sum of the speeds again from the attack speed
attributeRelationships.Add(this.CreateAttributeRelationship(Stats.AreTwoWeaponsEquipped, 1, Stats.EquippedWeaponCount));
var tempSpeed = this.Context.CreateNew<AttributeDefinition>(Guid.NewGuid(), "Temp Half weapon attack speed", string.Empty);
this.GameConfiguration.Attributes.Add(tempSpeed);
attributeRelationships.Add(this.CreateAttributeRelationship(tempSpeed, -0.5f, Stats.AttackSpeedByWeapon));
attributeRelationships.Add(this.CreateConditionalRelationship(Stats.AttackSpeed, Stats.AreTwoWeaponsEquipped, tempSpeed));
attributeRelationships.Add(this.CreateConditionalRelationship(Stats.MagicSpeed, Stats.AreTwoWeaponsEquipped, tempSpeed));

attributeRelationships.Add(this.CreateConditionalRelationship(Stats.DefenseBase, Stats.IsShieldEquipped, Stats.BonusDefenseWithShield));

var tempDefense = this.Context.CreateNew<AttributeDefinition>(Guid.NewGuid(), "Temp Defense Bonus multiplier with Shield", string.Empty);
Expand Down Expand Up @@ -140,6 +151,7 @@ private void AddCommonBaseAttributeValues(ICollection<ConstValueAttribute> baseA
baseAttributeValues.Add(this.CreateConstValueAttribute(0.03f, Stats.PoisonDamageMultiplier));
baseAttributeValues.Add(this.CreateConstValueAttribute(1, Stats.ItemDurationIncrease));
baseAttributeValues.Add(this.CreateConstValueAttribute(2, Stats.AbilityRecoveryAbsolute));
baseAttributeValues.Add(this.CreateConstValueAttribute(-1, Stats.AreTwoWeaponsEquipped));

if (isMaster)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ protected void CreateWeapon(byte @group, byte number, byte slot, int skillNumber
maxDamagePowerUp.BonusPerLevelTable = this._weaponDamageIncreaseTable;
item.BasePowerUpAttributes.Add(maxDamagePowerUp);

var speedPowerUp = this.CreateItemBasePowerUpDefinition(Stats.AttackSpeed, attackSpeed, AggregateType.AddRaw);
var speedPowerUp = this.CreateItemBasePowerUpDefinition(Stats.AttackSpeedByWeapon, attackSpeed, AggregateType.AddRaw);
item.BasePowerUpAttributes.Add(speedPowerUp);

this.CreateItemRequirementIfNeeded(item, Stats.Level, levelRequirement);
Expand Down Expand Up @@ -368,6 +368,11 @@ protected void CreateWeapon(byte @group, byte number, byte slot, int skillNumber
}
}

if (height > 1) // exclude bolts and arrows
{
item.BasePowerUpAttributes.Add(this.CreateItemBasePowerUpDefinition(Stats.EquippedWeaponCount, 1, AggregateType.AddRaw));
}

if (group == (int)ItemGroups.Bows && height > 1)
{
item.BasePowerUpAttributes.Add(this.CreateItemBasePowerUpDefinition(Stats.AmmunitionConsumptionRate, 1, AggregateType.AddRaw));
Expand Down

0 comments on commit 1ad5937

Please sign in to comment.