using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json; using Server.Data.Enums; namespace Server.Data.Entities; /// /// Monster/NPC template definition stored in database /// [Table("dungeon_mob_definitions")] public class DungeonMobDefinition { [Key] public int Id { get; set; } [Required] [MaxLength(64)] public string Name { get; set; } = ""; [MaxLength(256)] public string Description { get; set; } = ""; public MobType Type { get; set; } = MobType.Normal; public MobCategory Category { get; set; } = MobCategory.Undead; public int MinTier { get; set; } = 1; // Minimum dungeon tier to spawn public int MaxTier { get; set; } = 99; // Maximum tier (for progression gating) // Base Combat Stats public int BaseHealth { get; set; } = 50; public int BaseMana { get; set; } = 0; public int BasePhysicalDamage { get; set; } = 5; public int BaseMagicDamage { get; set; } = 0; public int BaseArmor { get; set; } = 0; public int BaseMagicResist { get; set; } = 0; // Movement & Combat public float MoveSpeed { get; set; } = 60f; public float AttackRange { get; set; } = 40f; // Melee range ~40, ranged 150+ public float AttackSpeed { get; set; } = 1.0f; // Attacks per second public float AggroRange { get; set; } = 150f; // Detection radius public float LeashRange { get; set; } = 400f; // Max chase distance before reset // Scaling per dungeon tier (multipliers) public float HealthPerTier { get; set; } = 1.2f; public float DamagePerTier { get; set; } = 1.15f; public float ArmorPerTier { get; set; } = 1.1f; // Experience & Loot public int BaseXp { get; set; } = 10; public float XpPerTier { get; set; } = 1.25f; public int LootTableId { get; set; } = 0; // Reference to loot_tables public float DropChanceMultiplier { get; set; } = 1.0f; /// /// JSON block for resistances/weaknesses /// Example: {"fire": -0.25, "ice": 0.5, "poison": 1.0} /// Negative = weakness (takes more damage), Positive = resistance (takes less), 1.0 = immune /// [MaxLength(1024)] public string ResistancesJson { get; set; } = "{}"; /// /// JSON block for special abilities/behaviors /// Example: {"canFlee": true, "fleeHealthPercent": 0.2, "callsForHelp": true} /// [MaxLength(1024)] public string AbilitiesJson { get; set; } = "{}"; // Visuals /// /// Path to the mob's .tscn scene file on CDN (e.g., "scenes/mobs/skeleton.tscn") /// If null/empty, client uses fallback placeholder shape /// [MaxLength(256)] public string? ScenePath { get; set; } /// /// Color tint applied to the mob (hex, e.g., "#ff0000" for red variant) /// [MaxLength(16)] public string TintColor { get; set; } = "#ffffff"; /// /// Scale multiplier for the mob (1.0 = normal size) /// public float Scale { get; set; } = 1.0f; // Legacy fields - kept for backwards compatibility, ScenePath takes priority [MaxLength(128)] public string SpriteSheet { get; set; } = ""; public int SpriteWidth { get; set; } = 32; public int SpriteHeight { get; set; } = 32; public float AnimationSpeed { get; set; } = 8f; // Frames per second public bool IsEnabled { get; set; } = true; // Helper methods for JSON parsing [NotMapped] public Dictionary Resistances { get { try { return JsonSerializer.Deserialize>(ResistancesJson) ?? new(); } catch { return new(); } } set { ResistancesJson = JsonSerializer.Serialize(value); } } [NotMapped] public Dictionary Abilities { get { try { return JsonSerializer.Deserialize>(AbilitiesJson) ?? new(); } catch { return new(); } } set { AbilitiesJson = JsonSerializer.Serialize(value); } } /// /// Calculate scaled stats for a specific level bracket /// Level bracket scaling: each bracket adds 15% to base stats /// public DungeonMobCombatStats GetStatsForBracket(int bracketMin) { // Calculate bracket number (1-10 = bracket 1, 11-20 = bracket 2, etc.) int bracketNumber = Math.Max(1, (bracketMin - 1) / 10 + 1); // Bracket scaling: each bracket adds 15% to base stats (compound) double bracketMultiplier = Math.Pow(1.15, bracketNumber - 1); return new DungeonMobCombatStats { MaxHealth = (int)(BaseHealth * HealthPerTier * bracketMultiplier), 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 }; } }