DamageTypeChanges

This commit is contained in:
dingo
2025-12-26 16:24:12 -05:00
parent 84d49520a0
commit 1d3e4e5f90
17 changed files with 3941 additions and 770 deletions
+18 -23
View File
@@ -1,5 +1,3 @@
using DataServer.Data.Enums;
namespace DataServer.Data.Entities;
/// <summary>
@@ -11,7 +9,6 @@ public class DungeonMobCombatStats
public int PhysicalDamage { get; set; }
public int MagicDamage { get; set; }
public int Armor { get; set; }
public int MagicResist { get; set; }
public float MoveSpeed { get; set; }
public float AttackRange { get; set; }
public float AttackSpeed { get; set; }
@@ -21,33 +18,31 @@ public class DungeonMobCombatStats
public Dictionary<string, float> Resistances { get; set; } = new();
/// <summary>
/// Calculate damage after resistances
/// Primary damage type key (e.g., "physical", "fire", "poison")
/// </summary>
public int CalculateDamage(int rawDamage, DamageType damageType)
public string DamageTypeKey { get; set; } = "physical";
/// <summary>
/// Calculate damage after armor and resistances
/// </summary>
public int CalculateDamage(int rawDamage, string damageTypeKey)
{
string typeKey = damageType.ToString().ToLower();
float damage = rawDamage;
// Apply armor reduction (flat mitigation for all damage types)
if (Armor > 0)
{
float armorReduction = Armor / (float)(Armor + 100);
damage *= (1.0f - armorReduction);
}
// Check for resistance/weakness
if (Resistances.TryGetValue(typeKey, out float resistance))
if (Resistances.TryGetValue(damageTypeKey, out float resistance))
{
if (resistance >= 1.0f) return 0; // Immune
return (int)(rawDamage * (1.0f - resistance));
damage *= (1.0f - resistance);
}
// Physical/Magic armor reduction
if (damageType == DamageType.Physical && Armor > 0)
{
// Armor formula: damage reduction = armor / (armor + 100)
float reduction = Armor / (float)(Armor + 100);
return (int)(rawDamage * (1.0f - reduction));
}
if (damageType != DamageType.Physical && MagicResist > 0)
{
float reduction = MagicResist / (float)(MagicResist + 100);
return (int)(rawDamage * (1.0f - reduction));
}
return rawDamage;
return Math.Max(1, (int)damage);
}
}