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
@@ -13,7 +13,6 @@ public class DungeonCharacterCombatStats
public int BonusHealth { get; set; }
public int BonusMana { get; set; }
public int Armor { get; set; }
public int MagicResist { get; set; }
public float MoveSpeed { get; set; }
public float AttackSpeed { get; set; }
public float RegenRate { get; set; }
-1
View File
@@ -39,7 +39,6 @@ public static class DungeonCharacterStats
stats.BonusHealth += item.BonusHealth;
stats.BonusMana += item.BonusMana;
stats.Armor += item.Armor;
stats.MagicResist += item.MagicResist;
}
}
+8 -3
View File
@@ -45,11 +45,16 @@ public class DungeonItemDefinition
public int MinDamage { get; set; } = 0;
public int MaxDamage { get; set; } = 0;
public float AttackRange { get; set; } = 0; // 0 = melee
public DamageType DamageType { get; set; } = DamageType.Physical;
// Armor stats
/// <summary>
/// Damage type key (references DamageResistanceType.Key)
/// e.g., "physical", "fire", "poison"
/// </summary>
[MaxLength(32)]
public string DamageTypeKey { get; set; } = "physical";
// Armor stats (flat damage reduction for all damage types)
public int Armor { get; set; } = 0;
public int MagicResist { get; set; } = 0;
// Consumable effects
public int HealAmount { get; set; } = 0;
+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);
}
}
+2 -2
View File
@@ -167,14 +167,14 @@ public class DungeonMobDefinition
PhysicalDamage = (int)(BasePhysicalDamage * DamagePerTier * bracketMultiplier),
MagicDamage = (int)(BaseMagicDamage * DamagePerTier * bracketMultiplier),
Armor = (int)(BaseArmor * ArmorPerTier * bracketMultiplier),
MagicResist = (int)(BaseMagicResist * ArmorPerTier * bracketMultiplier),
MoveSpeed = MoveSpeed,
AttackRange = AttackRange,
AttackSpeed = AttackSpeed,
AggroRange = AggroRange,
LeashRange = LeashRange,
XpReward = (int)(BaseXp * XpPerTier * bracketMultiplier),
Resistances = Resistances
Resistances = Resistances,
DamageTypeKey = DamageTypeKey
};
}
}