Fix crit calculation and bonus attack/def/luck
This commit is contained in:
@@ -158,7 +158,7 @@ public class EffectService
|
||||
return;
|
||||
|
||||
var currentWeapon = (Weapon)_player.EquipmentComponent.EquippedWeapon.Value;
|
||||
currentWeapon.IncreaseWeaponAttack(1);
|
||||
currentWeapon.IncreaseAttack(1);
|
||||
SfxDatabase.Instance.Play(SoundEffect.IncreaseStat);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,18 @@ public partial class Accessory : EquipableItem
|
||||
[Save("accessory_bonus_luck")]
|
||||
private int _bonusLuck { get; set; } = 0;
|
||||
|
||||
public void IncreaseAttack(int bonus) => _bonusDamage += bonus;
|
||||
|
||||
public void SetAttack(int newBonus) => _bonusDamage = newBonus;
|
||||
|
||||
public void IncreaseDefense(int bonus) => _bonusDefense += bonus;
|
||||
|
||||
public void SetDefense(int newBonus) => _bonusDefense = newBonus;
|
||||
|
||||
public void IncreaseLuck(int bonus) => _bonusLuck += bonus;
|
||||
|
||||
public void SetLuck(int newBonus) => _bonusLuck = newBonus;
|
||||
|
||||
[Export]
|
||||
[Save("accessory_stats")]
|
||||
public AccessoryStats Stats { get; set; } = new AccessoryStats();
|
||||
|
||||
@@ -38,6 +38,18 @@ public partial class Armor : EquipableItem
|
||||
|
||||
public override int BonusLuck { get => _bonusLuck; }
|
||||
|
||||
public void IncreaseAttack(int bonus) => _bonusDamage += bonus;
|
||||
|
||||
public void SetAttack(int newBonus) => _bonusDamage = newBonus;
|
||||
|
||||
public void IncreaseDefense(int bonus) => _bonusDefense += bonus;
|
||||
|
||||
public void SetDefense(int newBonus) => _bonusDefense = newBonus;
|
||||
|
||||
public void IncreaseLuck(int bonus) => _bonusLuck += bonus;
|
||||
|
||||
public void SetLuck(int newBonus) => _bonusLuck = newBonus;
|
||||
|
||||
|
||||
[Save("armor_bonus_damage")]
|
||||
private int _bonusDamage { get; set; } = 0;
|
||||
|
||||
@@ -46,13 +46,17 @@ public partial class Weapon : EquipableItem
|
||||
|
||||
public override ElementalResistanceSet ElementalResistance => new ElementalResistanceSet(Stats.AeolicResistance, Stats.HydricResistance, Stats.IgneousResistance, Stats.FerrumResistance, Stats.TelluricResistance, Stats.HolyResistance, Stats.CurseResistance);
|
||||
|
||||
public void IncreaseWeaponAttack(int bonus) => _bonusDamage += bonus;
|
||||
public void IncreaseAttack(int bonus) => _bonusDamage += bonus;
|
||||
|
||||
public void SetWeaponAttack(int newBonus) => _bonusDamage = newBonus;
|
||||
public void SetAttack(int newBonus) => _bonusDamage = newBonus;
|
||||
|
||||
public void IncreaseWeaponDefense(int bonus) => _bonusDefense += bonus;
|
||||
public void IncreaseDefense(int bonus) => _bonusDefense += bonus;
|
||||
|
||||
public void SetWeaponDefense(int newBonus) => _bonusDefense = newBonus;
|
||||
public void SetDefense(int newBonus) => _bonusDefense = newBonus;
|
||||
|
||||
public void IncreaseLuck(int bonus) => _bonusLuck += bonus;
|
||||
|
||||
public void SetLuck(int newBonus) => _bonusLuck = newBonus;
|
||||
|
||||
public override int BonusAttack { get => _bonusDamage; }
|
||||
|
||||
|
||||
@@ -388,13 +388,13 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
weapon.Augment = new Augment(JewelTags.AutoIdentifyAllItems, new IdentifyAllItemsAugment(this));
|
||||
break;
|
||||
case JewelTags.IncreaseAtkDefLuck:
|
||||
weapon.Stats.BonusAttack += 2;
|
||||
weapon.Stats.BonusDefense += 2;
|
||||
weapon.Stats.BonusLuck += 10;
|
||||
weapon.IncreaseAttack(2);
|
||||
weapon.IncreaseDefense(2);
|
||||
weapon.IncreaseLuck(10);
|
||||
weapon.Augment = new Augment(JewelTags.IncreaseAtkDefLuck, new BasicAugment());
|
||||
break;
|
||||
case JewelTags.IncreaseLuck:
|
||||
weapon.Stats.BonusLuck += 25;
|
||||
weapon.IncreaseLuck(25);
|
||||
weapon.Augment = new Augment(JewelTags.IncreaseLuck, new BasicAugment());
|
||||
break;
|
||||
}
|
||||
@@ -442,13 +442,13 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
armor.Augment = new Augment(JewelTags.AutoIdentifyAllItems, new IdentifyAllItemsAugment(this));
|
||||
break;
|
||||
case JewelTags.IncreaseAtkDefLuck:
|
||||
armor.Stats.BonusAttack += 2;
|
||||
armor.Stats.BonusDefense += 2;
|
||||
armor.Stats.BonusLuck += 10;
|
||||
armor.IncreaseAttack(2);
|
||||
armor.IncreaseDefense(2);
|
||||
armor.IncreaseLuck(10);
|
||||
armor.Augment = new Augment(JewelTags.IncreaseAtkDefLuck, new BasicAugment());
|
||||
break;
|
||||
case JewelTags.IncreaseLuck:
|
||||
armor.Stats.BonusLuck += 25;
|
||||
armor.IncreaseLuck(25);
|
||||
armor.Augment = new Augment(JewelTags.IncreaseLuck, new BasicAugment());
|
||||
break;
|
||||
}
|
||||
@@ -496,13 +496,13 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
accessory.Augment = new Augment(JewelTags.AutoIdentifyAllItems, new IdentifyAllItemsAugment(this));
|
||||
break;
|
||||
case JewelTags.IncreaseAtkDefLuck:
|
||||
accessory.Stats.BonusAttack += 2;
|
||||
accessory.Stats.BonusDefense += 2;
|
||||
accessory.Stats.BonusLuck += 10;
|
||||
accessory.IncreaseAttack(2);
|
||||
accessory.IncreaseDefense(2);
|
||||
accessory.IncreaseLuck(10);
|
||||
accessory.Augment = new Augment(JewelTags.IncreaseAtkDefLuck, new BasicAugment());
|
||||
break;
|
||||
case JewelTags.IncreaseLuck:
|
||||
accessory.Stats.BonusLuck += 25;
|
||||
accessory.IncreaseLuck(25);
|
||||
accessory.Augment = new Augment(JewelTags.IncreaseLuck, new BasicAugment());
|
||||
break;
|
||||
}
|
||||
@@ -672,7 +672,7 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
if (weapon.WeaponTag == WeaponTag.InverseHPAttackPower)
|
||||
{
|
||||
var healthPercentage = (HealthComponent.CurrentHP.Value * 10) / HealthComponent.MaximumHP.Value;
|
||||
weapon.SetWeaponAttack(10 - healthPercentage);
|
||||
weapon.SetAttack(10 - healthPercentage);
|
||||
EquipmentComponent.Equip(weapon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ internal class PlayerEffectService
|
||||
{
|
||||
var weapon = _player.EquipmentComponent.EquippedWeapon.Value as Weapon;
|
||||
var newAttack = Mathf.Max(weapon.BonusAttack - 1, 0);
|
||||
weapon.SetWeaponAttack(newAttack);
|
||||
weapon.SetAttack(newAttack);
|
||||
_player.EquipmentComponent.UpdateEquipment(weapon);
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,8 @@ public static class BattleExtensions
|
||||
{
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
var roll = rng.Randf();
|
||||
var isCriticalHit = roll <= (luckStat / 100);
|
||||
var roll = rng.Randf() * 100;
|
||||
var isCriticalHit = roll <= luckStat;
|
||||
return isCriticalHit;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user