49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
namespace DataServer.Data.Entities;
|
|
|
|
/// <summary>
|
|
/// Runtime combat stats for a mob instance
|
|
/// </summary>
|
|
public class DungeonMobCombatStats
|
|
{
|
|
public int MaxHealth { get; set; }
|
|
public int PhysicalDamage { get; set; }
|
|
public int MagicDamage { get; set; }
|
|
public int Armor { get; set; }
|
|
public float MoveSpeed { get; set; }
|
|
public float AttackRange { get; set; }
|
|
public float AttackSpeed { get; set; }
|
|
public float AggroRange { get; set; }
|
|
public float LeashRange { get; set; }
|
|
public int XpReward { get; set; }
|
|
public Dictionary<string, float> Resistances { get; set; } = new();
|
|
|
|
/// <summary>
|
|
/// Primary damage type key (e.g., "physical", "fire", "poison")
|
|
/// </summary>
|
|
public string DamageTypeKey { get; set; } = "physical";
|
|
|
|
/// <summary>
|
|
/// Calculate damage after armor and resistances
|
|
/// </summary>
|
|
public int CalculateDamage(int rawDamage, string damageTypeKey)
|
|
{
|
|
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(damageTypeKey, out float resistance))
|
|
{
|
|
if (resistance >= 1.0f) return 0; // Immune
|
|
damage *= (1.0f - resistance);
|
|
}
|
|
|
|
return Math.Max(1, (int)damage);
|
|
}
|
|
}
|