Files
systemrevivalserver/data/entities/DungeonMobCombatStats.cs
T
2025-12-06 18:06:03 -05:00

54 lines
1.7 KiB
C#

using Server.Data.Enums;
namespace Server.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 int MagicResist { 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>
/// Calculate damage after resistances
/// </summary>
public int CalculateDamage(int rawDamage, DamageType damageType)
{
string typeKey = damageType.ToString().ToLower();
// Check for resistance/weakness
if (Resistances.TryGetValue(typeKey, out float resistance))
{
if (resistance >= 1.0f) return 0; // Immune
return (int)(rawDamage * (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;
}
}