From 9c67dd3935974a8d0bfa182f7b553ac75a060c13 Mon Sep 17 00:00:00 2001 From: dingo Date: Sat, 27 Dec 2025 11:09:09 -0500 Subject: [PATCH] Mob AIv2 and player speed cap --- Game/Dungeon/MobAI.cs | 462 +++++ Game/Dungeon/MobInstance.cs | 150 +- Migrations/20251227160629_Mob AI.Designer.cs | 1941 ++++++++++++++++++ Migrations/20251227160629_Mob AI.cs | 223 ++ Migrations/GameDbContextModelSnapshot.cs | 228 +- Services/Admin/Pages/Mobs/Edit.cshtml.cs | 5 +- data/GameDbContext.cs | 5 + data/entities/DungeonCharacterStats.cs | 8 +- data/entities/DungeonMobDefinition.cs | 94 +- data/entities/MobAbilityAssignment.cs | 63 + data/entities/MobAbilityDefinition.cs | 143 ++ data/enums/MobAbilityTargeting.cs | 46 + data/enums/MobAbilityType.cs | 108 + data/enums/MobBehavior.cs | 37 + 14 files changed, 3479 insertions(+), 34 deletions(-) create mode 100644 Game/Dungeon/MobAI.cs create mode 100644 Migrations/20251227160629_Mob AI.Designer.cs create mode 100644 Migrations/20251227160629_Mob AI.cs create mode 100644 data/entities/MobAbilityAssignment.cs create mode 100644 data/entities/MobAbilityDefinition.cs create mode 100644 data/enums/MobAbilityTargeting.cs create mode 100644 data/enums/MobAbilityType.cs create mode 100644 data/enums/MobBehavior.cs diff --git a/Game/Dungeon/MobAI.cs b/Game/Dungeon/MobAI.cs new file mode 100644 index 0000000..0bd3d93 --- /dev/null +++ b/Game/Dungeon/MobAI.cs @@ -0,0 +1,462 @@ +using DataServer.Data.Entities; +using DataServer.Data.Enums; + +namespace Server.Game.Dungeon; + +/// +/// Handles mob AI behavior and decision making +/// +public static class MobAI +{ + /// + /// Main AI update - called each tick for each mob + /// + public static void UpdateMob(MobInstance mob, DungeonSimulation sim, float deltaTime) + { + if (!mob.IsAlive || mob.IsStunned) return; + + // Update cooldowns + UpdateCooldowns(mob, deltaTime); + + // Update status effects + UpdateStatusEffects(mob, sim, deltaTime); + + // Check for phase transitions (for bosses) + CheckPhaseTransition(mob); + + // Update state time + mob.StateTime += deltaTime; + + // Handle casting + if (mob.CastingAbility != null) + { + mob.CastTimeRemaining -= deltaTime; + if (mob.CastTimeRemaining <= 0) + { + ExecuteAbility(mob, mob.CastingAbility, sim); + mob.CastingAbility = null; + mob.State = MobState.Idle; + } + return; + } + + // Main behavior switch + switch (mob.Behavior) + { + case MobBehavior.Aggressive: + UpdateAggressive(mob, sim, deltaTime); + break; + case MobBehavior.Defensive: + UpdateDefensive(mob, sim, deltaTime); + break; + case MobBehavior.Ranged: + UpdateRanged(mob, sim, deltaTime); + break; + case MobBehavior.Skirmisher: + UpdateSkirmisher(mob, sim, deltaTime); + break; + case MobBehavior.Summoner: + case MobBehavior.Tank: + case MobBehavior.Assassin: + case MobBehavior.Healer: + case MobBehavior.Patrol: + case MobBehavior.Pack: + // For now, fall back to aggressive behavior + // TODO: Implement specialized behaviors + UpdateAggressive(mob, sim, deltaTime); + break; + } + } + + #region Core Behaviors + + private static void UpdateAggressive(MobInstance mob, DungeonSimulation sim, float deltaTime) + { + var target = FindNearestPlayer(mob, sim); + + if (target == null) + { + ReturnToSpawn(mob, sim, deltaTime); + return; + } + + float distance = GetDistance(mob.X, mob.Y, target.X, target.Y); + mob.TargetId = target.CharacterId; + mob.UpdateFacingDirection(target.X, target.Y); + mob.CombatTime += deltaTime; + + // Try to use abilities + var ability = SelectAbility(mob, distance); + if (ability != null && TryUseAbility(mob, ability, target, sim)) + { + return; + } + + // Chase and melee + if (distance <= mob.Stats.AttackRange) + { + mob.State = MobState.Attacking; + mob.CurrentAnimation = mob.GetDirectionalAnimation("attack"); + } + else if (distance <= mob.Stats.LeashRange) + { + mob.State = MobState.Chasing; + mob.CurrentAnimation = mob.GetDirectionalAnimation("walk"); + MoveToward(mob, target.X, target.Y, mob.Stats.MoveSpeed * mob.GetSpeedModifier() * deltaTime); + } + else + { + ReturnToSpawn(mob, sim, deltaTime); + } + } + + private static void UpdateDefensive(MobInstance mob, DungeonSimulation sim, float deltaTime) + { + float distFromSpawn = GetDistance(mob.X, mob.Y, mob.SpawnX, mob.SpawnY); + var target = FindNearestPlayer(mob, sim); + + if (target != null) + { + float targetDistFromSpawn = GetDistance(target.X, target.Y, mob.SpawnX, mob.SpawnY); + float distance = GetDistance(mob.X, mob.Y, target.X, target.Y); + + if (targetDistFromSpawn <= mob.Stats.AggroRange) + { + mob.TargetId = target.CharacterId; + mob.UpdateFacingDirection(target.X, target.Y); + + if (distFromSpawn > mob.Stats.LeashRange * 0.5f) + { + ReturnToSpawn(mob, sim, deltaTime); + return; + } + + var ability = SelectAbility(mob, distance); + if (ability != null && TryUseAbility(mob, ability, target, sim)) + { + return; + } + + if (distance <= mob.Stats.AttackRange) + { + mob.State = MobState.Attacking; + } + else + { + mob.State = MobState.Chasing; + MoveToward(mob, target.X, target.Y, mob.Stats.MoveSpeed * 0.7f * deltaTime); + } + } + else + { + mob.TargetId = null; + ReturnToSpawn(mob, sim, deltaTime); + } + } + else + { + ReturnToSpawn(mob, sim, deltaTime); + } + } + + private static void UpdateRanged(MobInstance mob, DungeonSimulation sim, float deltaTime) + { + var target = FindNearestPlayer(mob, sim); + + if (target == null) + { + ReturnToSpawn(mob, sim, deltaTime); + return; + } + + float distance = GetDistance(mob.X, mob.Y, target.X, target.Y); + mob.TargetId = target.CharacterId; + mob.UpdateFacingDirection(target.X, target.Y); + mob.CombatTime += deltaTime; + + var ability = SelectAbility(mob, distance, preferRanged: true); + if (ability != null && TryUseAbility(mob, ability, target, sim)) + { + return; + } + + // Maintain preferred range + if (distance < mob.PreferredRange * 0.6f) + { + mob.State = MobState.Kiting; + MoveAwayFrom(mob, target.X, target.Y, mob.Stats.MoveSpeed * deltaTime); + } + else if (distance > mob.PreferredRange * 1.2f && distance <= mob.Stats.LeashRange) + { + mob.State = MobState.Chasing; + MoveToward(mob, target.X, target.Y, mob.Stats.MoveSpeed * deltaTime); + } + else if (distance > mob.Stats.LeashRange) + { + ReturnToSpawn(mob, sim, deltaTime); + } + else + { + mob.State = MobState.Attacking; + } + } + + private static void UpdateSkirmisher(MobInstance mob, DungeonSimulation sim, float deltaTime) + { + var target = FindNearestPlayer(mob, sim); + + if (target == null) + { + ReturnToSpawn(mob, sim, deltaTime); + return; + } + + float distance = GetDistance(mob.X, mob.Y, target.X, target.Y); + mob.TargetId = target.CharacterId; + mob.UpdateFacingDirection(target.X, target.Y); + + if (mob.HpPercent <= mob.FleeThreshold && mob.FleeThreshold > 0) + { + mob.State = MobState.Fleeing; + MoveAwayFrom(mob, target.X, target.Y, mob.Stats.MoveSpeed * 1.2f * deltaTime); + return; + } + + // Attack then retreat pattern + if (mob.State == MobState.Attacking && mob.StateTime < 2.0f) + { + var ability = SelectAbility(mob, distance); + if (ability != null && TryUseAbility(mob, ability, target, sim)) + { + return; + } + + if (distance <= mob.Stats.AttackRange) + { + mob.CurrentAnimation = mob.GetDirectionalAnimation("attack"); + } + else + { + MoveToward(mob, target.X, target.Y, mob.Stats.MoveSpeed * deltaTime); + } + } + else if (mob.StateTime < 4.0f) + { + mob.State = MobState.Kiting; + MoveAwayFrom(mob, target.X, target.Y, mob.Stats.MoveSpeed * deltaTime); + } + else + { + mob.StateTime = 0; + mob.State = MobState.Attacking; + } + } + + #endregion + + #region Ability System + + private static MobAbilityState? SelectAbility(MobInstance mob, float distance, bool preferRanged = false) + { + var available = mob.Abilities + .Where(a => a.IsAvailable(mob.HpPercent)) + .Where(a => a.Phase == 0 || a.Phase == mob.CurrentPhase) + .Where(a => a.Definition.Range >= distance || a.Definition.Range == 0) + .ToList(); + + if (preferRanged) + { + available = available + .Where(a => a.Definition.AbilityType == MobAbilityType.ProjectileSingle || + a.Definition.AbilityType == MobAbilityType.ProjectileAoe) + .ToList(); + } + + if (available.Count == 0) return null; + + // Weight by priority + var weighted = available.OrderByDescending(a => a.Priority).ToList(); + + // Add some randomness + if (weighted.Count > 1 && Random.Shared.NextDouble() < 0.3) + { + return weighted[Random.Shared.Next(weighted.Count)]; + } + + return weighted.FirstOrDefault(); + } + + private static bool TryUseAbility(MobInstance mob, MobAbilityState ability, PlayerInstance target, DungeonSimulation sim) + { + if (!ability.IsAvailable(mob.HpPercent)) return false; + if (mob.IsSilenced && ability.Definition.CastTime > 0) return false; + + float distance = GetDistance(mob.X, mob.Y, target.X, target.Y); + if (ability.Definition.Range > 0 && distance > ability.Definition.Range) return false; + + // Check mana cost + if (ability.Definition.ManaCost > mob.Mana) return false; + + // Start casting + if (ability.Definition.CastTime > 0) + { + mob.CastingAbility = ability; + mob.CastTimeRemaining = ability.Definition.CastTime; + mob.State = MobState.Casting; + mob.CurrentAnimation = mob.GetDirectionalAnimation(ability.Definition.AnimationKey); + return true; + } + + // Instant ability + ExecuteAbility(mob, ability, sim); + return true; + } + + private static void ExecuteAbility(MobInstance mob, MobAbilityState ability, DungeonSimulation sim) + { + ability.CooldownRemaining = ability.Definition.Cooldown; + mob.Mana -= ability.Definition.ManaCost; + mob.CurrentAnimation = mob.GetDirectionalAnimation(ability.Definition.AnimationKey); + + // TODO: Queue the ability effect for the simulation to process + // For now, abilities are tracked but effects need to be wired up in DungeonSimulation + // The simulation will need to check mob.CastingAbility and process effects there + } + + #endregion + + #region Helpers + + private static void UpdateCooldowns(MobInstance mob, float deltaTime) + { + foreach (var ability in mob.Abilities) + { + if (ability.CooldownRemaining > 0) + ability.CooldownRemaining -= deltaTime; + } + } + + private static void UpdateStatusEffects(MobInstance mob, DungeonSimulation sim, float deltaTime) + { + var expired = new List(); + + foreach (var effect in mob.StatusEffects) + { + effect.Duration -= deltaTime; + + // Handle DOT + if (effect.DamagePerTick > 0) + { + effect.NextTickIn -= deltaTime; + if (effect.NextTickIn <= 0) + { + mob.Health -= effect.DamagePerTick; + effect.NextTickIn = effect.TickInterval; + + if (mob.Health <= 0) + { + mob.Health = 0; + mob.IsAlive = false; + mob.State = MobState.Dead; + } + } + } + + if (effect.Duration <= 0) + expired.Add(effect); + } + + foreach (var e in expired) + mob.StatusEffects.Remove(e); + } + + private static void CheckPhaseTransition(MobInstance mob) + { + if (mob.Phases == null || mob.Phases.Count == 0) return; + + for (int i = mob.Phases.Count - 1; i >= 0; i--) + { + var phase = mob.Phases[i]; + if (mob.HpPercent <= phase.HpThreshold && mob.CurrentPhase < i + 1) + { + mob.CurrentPhase = i + 1; + mob.Behavior = phase.Behavior; + mob.StateTime = 0; + break; + } + } + } + + private static PlayerInstance? FindNearestPlayer(MobInstance mob, DungeonSimulation sim) + { + return sim.Players.Values + .Where(p => p.IsAlive) + .Where(p => GetDistance(mob.X, mob.Y, p.X, p.Y) <= mob.Stats.AggroRange) + .OrderBy(p => GetDistance(mob.X, mob.Y, p.X, p.Y)) + .FirstOrDefault(); + } + + private static void ReturnToSpawn(MobInstance mob, DungeonSimulation sim, float deltaTime) + { + float dist = GetDistance(mob.X, mob.Y, mob.SpawnX, mob.SpawnY); + if (dist < 10f) + { + mob.State = MobState.Idle; + mob.TargetId = null; + mob.CombatTime = 0; + mob.CurrentAnimation = mob.GetDirectionalAnimation("idle"); + + // Heal when returning + if (mob.Health < mob.MaxHealth) + { + mob.Health = Math.Min(mob.MaxHealth, mob.Health + (int)(mob.MaxHealth * 0.1f * deltaTime)); + } + } + else + { + mob.State = MobState.Returning; + mob.UpdateFacingDirection(mob.SpawnX, mob.SpawnY); + mob.CurrentAnimation = mob.GetDirectionalAnimation("walk"); + MoveToward(mob, mob.SpawnX, mob.SpawnY, mob.Stats.MoveSpeed * deltaTime); + } + } + + private static void MoveToward(MobInstance mob, float targetX, float targetY, float speed) + { + if (mob.IsRooted) return; + + float dx = targetX - mob.X; + float dy = targetY - mob.Y; + float dist = MathF.Sqrt(dx * dx + dy * dy); + + if (dist > 0) + { + mob.X += (dx / dist) * speed; + mob.Y += (dy / dist) * speed; + } + } + + private static void MoveAwayFrom(MobInstance mob, float targetX, float targetY, float speed) + { + if (mob.IsRooted) return; + + float dx = mob.X - targetX; + float dy = mob.Y - targetY; + float dist = MathF.Sqrt(dx * dx + dy * dy); + + if (dist > 0) + { + mob.X += (dx / dist) * speed; + mob.Y += (dy / dist) * speed; + } + } + + private static float GetDistance(float x1, float y1, float x2, float y2) + { + float dx = x2 - x1; + float dy = y2 - y1; + return MathF.Sqrt(dx * dx + dy * dy); + } + + #endregion +} diff --git a/Game/Dungeon/MobInstance.cs b/Game/Dungeon/MobInstance.cs index 6b5e3d7..4b4dab8 100644 --- a/Game/Dungeon/MobInstance.cs +++ b/Game/Dungeon/MobInstance.cs @@ -20,6 +20,45 @@ public class CarriedLootItem public int Quantity { get; set; } } +/// +/// Runtime state for a mob ability +/// +public class MobAbilityState +{ + public int AbilityId { get; set; } + public MobAbilityDefinition Definition { get; set; } = null!; + public float CooldownRemaining { get; set; } + public int Priority { get; set; } + public int Phase { get; set; } + public float? MinHpPercent { get; set; } + public float? MaxHpPercent { get; set; } + + /// + /// Check if this ability is available (off cooldown and HP in range) + /// + public bool IsAvailable(float currentHpPercent) + { + if (CooldownRemaining > 0) return false; + if (MinHpPercent.HasValue && currentHpPercent < MinHpPercent.Value) return false; + if (MaxHpPercent.HasValue && currentHpPercent > MaxHpPercent.Value) return false; + return true; + } +} + +/// +/// Active status effect on a mob +/// +public class MobStatusEffect +{ + public string EffectType { get; set; } = ""; // poison, bleed, burn, slow, stun, etc. + public float Duration { get; set; } + public float TickInterval { get; set; } + public float NextTickIn { get; set; } + public int DamagePerTick { get; set; } + public float Modifier { get; set; } = 1.0f; // For slow, etc. + public ulong SourcePlayerId { get; set; } +} + /// /// Runtime instance of a mob in a dungeon /// @@ -37,15 +76,73 @@ public class MobInstance public int Health { get; set; } public int MaxHealth { get; set; } + public int Mana { get; set; } + public int MaxMana { get; set; } public bool IsAlive { get; set; } = true; public DungeonMobCombatStats Stats { get; set; } = new(); public MobState State { get; set; } = MobState.Idle; public MobType Type { get; set; } + public MobBehavior Behavior { get; set; } = MobBehavior.Aggressive; + + /// Current phase for multi-phase mobs (0 = first phase) + public int CurrentPhase { get; set; } = 0; + + /// Phase configurations loaded from definition + public List? Phases { get; set; } public ulong? TargetId { get; set; } public long LastAttackTick { get; set; } + /// Time spent in current state (for behavior decisions) + public float StateTime { get; set; } + + /// Last position for stuck detection + public float LastX { get; set; } + public float LastY { get; set; } + public float StuckTime { get; set; } + + // === Abilities === + /// Abilities this mob can use + public List Abilities { get; set; } = new(); + + /// Currently casting ability (null if not casting) + public MobAbilityState? CastingAbility { get; set; } + + /// Remaining cast time + public float CastTimeRemaining { get; set; } + + /// Active status effects on this mob + public List StatusEffects { get; set; } = new(); + + /// Current animation being played + public string CurrentAnimation { get; set; } = "idle"; + + /// Direction mob is facing (down, up, left, right) + public string FacingDirection { get; set; } = "down"; + + // === Behavior-specific === + /// Preferred combat distance (for ranged/skirmisher) + public float PreferredRange { get; set; } = 40f; + + /// Flee threshold HP percentage + public float FleeThreshold { get; set; } = 0f; + + /// Has already called for help this combat + public bool HasCalledForHelp { get; set; } + + /// Patrol waypoints (for Patrol behavior) + public List<(float X, float Y)>? PatrolPath { get; set; } + + /// Current patrol waypoint index + public int PatrolIndex { get; set; } + + /// Enrage stacks (for Enrage behavior) + public int EnrageStacks { get; set; } + + /// Time since combat started (for time-based mechanics) + public float CombatTime { get; set; } + // Visual - sprite configuration JSON public string? SpriteConfigJson { get; set; } public string TintColor { get; set; } = "#ffffff"; @@ -54,10 +151,53 @@ public class MobInstance // Carried loot from player kills public List CarriedPlayerLoot { get; set; } = new(); - /// - /// Check if this mob is carrying loot from player kills - /// + /// Check if this mob is carrying loot from player kills public bool HasCarriedLoot => CarriedPlayerLoot.Count > 0; + + /// Current HP as percentage (0-1) + public float HpPercent => MaxHealth > 0 ? (float)Health / MaxHealth : 0f; + + /// Check if mob is stunned + public bool IsStunned => StatusEffects.Any(e => e.EffectType == "stun" && e.Duration > 0); + + /// Check if mob is rooted + public bool IsRooted => StatusEffects.Any(e => e.EffectType == "root" && e.Duration > 0); + + /// Check if mob is silenced + public bool IsSilenced => StatusEffects.Any(e => e.EffectType == "silence" && e.Duration > 0); + + /// Get current speed modifier from status effects + public float GetSpeedModifier() + { + float modifier = 1.0f; + foreach (var effect in StatusEffects.Where(e => e.EffectType == "slow")) + { + modifier *= effect.Modifier; + } + return modifier; + } + + /// Update facing direction based on movement + public void UpdateFacingDirection(float targetX, float targetY) + { + float dx = targetX - X; + float dy = targetY - Y; + + if (Math.Abs(dx) > Math.Abs(dy)) + { + FacingDirection = dx > 0 ? "right" : "left"; + } + else + { + FacingDirection = dy > 0 ? "down" : "up"; + } + } + + /// Get the animation key with direction + public string GetDirectionalAnimation(string baseAnim) + { + return $"{baseAnim}_{FacingDirection}"; + } } public enum MobState @@ -65,7 +205,11 @@ public enum MobState Idle, Chasing, Attacking, + Casting, Returning, Fleeing, + Kiting, // Moving away while attacking (skirmisher) + Summoning, // In summoning animation + Healing, // Healing self or ally Dead } diff --git a/Migrations/20251227160629_Mob AI.Designer.cs b/Migrations/20251227160629_Mob AI.Designer.cs new file mode 100644 index 0000000..99536b1 --- /dev/null +++ b/Migrations/20251227160629_Mob AI.Designer.cs @@ -0,0 +1,1941 @@ +// +using System; +using DataServer.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace SystemRevivalServer.Migrations +{ + [DbContext(typeof(GameDbContext))] + [Migration("20251227160629_Mob AI")] + partial class MobAI + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + + modelBuilder.Entity("DataServer.Data.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("BannedUntil") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime(6)") + .HasDefaultValueSql("CURRENT_TIMESTAMP(6)"); + + b.Property("Email") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("IsBanned") + .HasColumnType("tinyint(1)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("varbinary(64)"); + + b.Property("PasswordSalt") + .IsRequired() + .HasColumnType("varbinary(32)"); + + b.Property("Role") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("UpdatedAt") + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("datetime(6)") + .HasDefaultValueSql("CURRENT_TIMESTAMP(6)"); + + MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property("UpdatedAt")); + + b.Property("Username") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("Email") + .IsUnique(); + + b.HasIndex("Username") + .IsUnique(); + + b.ToTable("accounts", (string)null); + }); + + modelBuilder.Entity("DataServer.Data.Entities.ClientAsset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AssetType") + .HasColumnType("int"); + + b.Property("CdnPath") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("FileHash") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("FilePath") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("FileSize") + .HasColumnType("bigint"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("IsRequired") + .HasColumnType("tinyint(1)"); + + b.Property("MinClientVersion") + .HasMaxLength(16) + .HasColumnType("varchar(16)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("client_assets"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DamageResistanceType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Color") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("varchar(16)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("IconPath") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("damage_resistance_types"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DeathChest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DungeonInstanceId") + .HasColumnType("char(36)"); + + b.Property("EmptiedAt") + .HasColumnType("datetime(6)"); + + b.Property("GoldAmount") + .HasColumnType("bigint"); + + b.Property("IsEmpty") + .HasColumnType("tinyint(1)"); + + b.Property("OwnerCharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("VictimCharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("VictimMobDefinitionId") + .HasColumnType("int"); + + b.Property("X") + .HasColumnType("float"); + + b.Property("Y") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("OwnerCharacterId"); + + b.HasIndex("VictimCharacterId"); + + b.ToTable("dungeon_death_chests"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DeathChestItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("DeathChestId") + .HasColumnType("bigint unsigned"); + + b.Property("IsTaken") + .HasColumnType("tinyint(1)"); + + b.Property("ItemDefinitionId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("SlotIndex") + .HasColumnType("int"); + + b.Property("TakenAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("DeathChestId"); + + b.HasIndex("ItemDefinitionId"); + + b.ToTable("dungeon_death_chest_items"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonBeltItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("InventorySlotIndex") + .HasColumnType("int"); + + b.Property("SlotIndex") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CharacterId"); + + b.ToTable("dungeon_belt_items"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("bigint unsigned"); + + b.Property("BossesKilled") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CurrentHealth") + .HasColumnType("int"); + + b.Property("CurrentMana") + .HasColumnType("int"); + + b.Property("Dexterity") + .HasColumnType("int"); + + b.Property("DungeonsCompleted") + .HasColumnType("int"); + + b.Property("Endurance") + .HasColumnType("int"); + + b.Property("EquippedAccessory") + .HasColumnType("bigint unsigned"); + + b.Property("EquippedBoots") + .HasColumnType("bigint unsigned"); + + b.Property("EquippedChest") + .HasColumnType("bigint unsigned"); + + b.Property("EquippedGloves") + .HasColumnType("bigint unsigned"); + + b.Property("EquippedHead") + .HasColumnType("bigint unsigned"); + + b.Property("EquippedLegs") + .HasColumnType("bigint unsigned"); + + b.Property("EquippedOffhand") + .HasColumnType("bigint unsigned"); + + b.Property("EquippedWeapon") + .HasColumnType("bigint unsigned"); + + b.Property("Experience") + .HasColumnType("bigint"); + + b.Property("Gold") + .HasColumnType("bigint"); + + b.Property("Intelligence") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.Property("LastPlayedAt") + .HasColumnType("datetime(6)"); + + b.Property("Level") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("PlayersKilled") + .HasColumnType("int"); + + b.Property("ResistancesJson") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("Strength") + .HasColumnType("int"); + + b.Property("TotalDeaths") + .HasColumnType("int"); + + b.Property("TotalKills") + .HasColumnType("int"); + + b.Property("UnspentStatPoints") + .HasColumnType("int"); + + b.Property("Wisdom") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.ToTable("dungeon_characters"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacterCraftingSkill", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("Experience") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("int"); + + b.Property("SkillType") + .HasColumnType("int"); + + b.Property("TotalItemsCrafted") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CharacterId"); + + b.ToTable("dungeon_character_crafting_skills"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacterItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AcquiredAt") + .HasColumnType("datetime(6)"); + + b.Property("CharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("EquipSlot") + .HasColumnType("int"); + + b.Property("IsEquipped") + .HasColumnType("tinyint(1)"); + + b.Property("ItemDefinitionId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("SlotIndex") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CharacterId"); + + b.HasIndex("ItemDefinitionId"); + + b.ToTable("dungeon_character_items"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacterItemCraftedLink", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CharacterItemId") + .HasColumnType("bigint unsigned"); + + b.Property("CraftedItemId") + .HasColumnType("bigint unsigned"); + + b.HasKey("Id"); + + b.HasIndex("CharacterItemId"); + + b.HasIndex("CraftedItemId"); + + b.ToTable("dungeon_character_item_crafted_link"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacterKnownRecipe", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("DiscoveredAt") + .HasColumnType("datetime(6)"); + + b.Property("RecipeId") + .HasColumnType("int"); + + b.Property("TimesCrafted") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CharacterId"); + + b.HasIndex("RecipeId"); + + b.ToTable("dungeon_character_known_recipes"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCraftedItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("BaseItemDefinitionId") + .HasColumnType("int"); + + b.Property("CraftedAt") + .HasColumnType("datetime(6)"); + + b.Property("CrafterId") + .HasColumnType("bigint unsigned"); + + b.Property("CrafterName") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("CraftingLevelAtCreation") + .HasColumnType("int"); + + b.Property("CustomName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("QualityRating") + .HasColumnType("int"); + + b.Property("RecipeId") + .HasColumnType("int"); + + b.Property("RollHistoryJson") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("RolledBonusArmor") + .HasColumnType("int"); + + b.Property("RolledBonusDexterity") + .HasColumnType("int"); + + b.Property("RolledBonusEndurance") + .HasColumnType("int"); + + b.Property("RolledBonusHealAmount") + .HasColumnType("int"); + + b.Property("RolledBonusHealth") + .HasColumnType("int"); + + b.Property("RolledBonusIntelligence") + .HasColumnType("int"); + + b.Property("RolledBonusMagicResist") + .HasColumnType("int"); + + b.Property("RolledBonusMana") + .HasColumnType("int"); + + b.Property("RolledBonusManaRestore") + .HasColumnType("int"); + + b.Property("RolledBonusMaxDamage") + .HasColumnType("int"); + + b.Property("RolledBonusMinDamage") + .HasColumnType("int"); + + b.Property("RolledBonusStrength") + .HasColumnType("int"); + + b.Property("RolledBonusWisdom") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("BaseItemDefinitionId"); + + b.HasIndex("CrafterId"); + + b.HasIndex("RecipeId"); + + b.ToTable("dungeon_crafted_items"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCraftingRecipe", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("BaseXp") + .HasColumnType("int"); + + b.Property("BonusOutputChanceAtMinLevel") + .HasColumnType("float"); + + b.Property("BonusOutputItemDefinitionId") + .HasColumnType("int"); + + b.Property("BonusOutputMaxLevel") + .HasColumnType("int"); + + b.Property("BonusOutputMinLevel") + .HasColumnType("int"); + + b.Property("BonusOutputQuantity") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("HasStatRolls") + .HasColumnType("tinyint(1)"); + + b.Property("IsBaseRecipe") + .HasColumnType("tinyint(1)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("OutputItemDefinitionId") + .HasColumnType("int"); + + b.Property("OutputQuantity") + .HasColumnType("int"); + + b.Property("PossibleStatsJson") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("RequiredLevel") + .HasColumnType("int"); + + b.Property("SkillType") + .HasColumnType("int"); + + b.Property("Tier") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("OutputItemDefinitionId"); + + b.ToTable("dungeon_crafting_recipes"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCraftingRecipeIngredient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ItemDefinitionId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("RecipeId") + .HasColumnType("int"); + + b.Property("SlotOrder") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ItemDefinitionId"); + + b.HasIndex("RecipeId"); + + b.ToTable("dungeon_crafting_recipe_ingredients"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonItemDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Armor") + .HasColumnType("int"); + + b.Property("AttackRange") + .HasColumnType("float"); + + b.Property("BonusDexterity") + .HasColumnType("int"); + + b.Property("BonusEndurance") + .HasColumnType("int"); + + b.Property("BonusHealth") + .HasColumnType("int"); + + b.Property("BonusIntelligence") + .HasColumnType("int"); + + b.Property("BonusMana") + .HasColumnType("int"); + + b.Property("BonusStrength") + .HasColumnType("int"); + + b.Property("BonusWisdom") + .HasColumnType("int"); + + b.Property("BuffDuration") + .HasColumnType("int"); + + b.Property("BuffResistancesJson") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("DamageTypeKey") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("EquipSlot") + .HasColumnType("int"); + + b.Property("HealAmount") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("IsTeleportScroll") + .HasColumnType("tinyint(1)"); + + b.Property("ManaRestore") + .HasColumnType("int"); + + b.Property("MaxDamage") + .HasColumnType("int"); + + b.Property("MaxStack") + .HasColumnType("int"); + + b.Property("MinDamage") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Rarity") + .HasColumnType("int"); + + b.Property("RequiredDexterity") + .HasColumnType("int"); + + b.Property("RequiredIntelligence") + .HasColumnType("int"); + + b.Property("RequiredLevel") + .HasColumnType("int"); + + b.Property("RequiredStrength") + .HasColumnType("int"); + + b.Property("RequiredWisdom") + .HasColumnType("int"); + + b.Property("ResistancesJson") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("SpriteId") + .HasColumnType("int"); + + b.Property("SpritePath") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Stackable") + .HasColumnType("tinyint(1)"); + + b.Property("StaminaRestore") + .HasColumnType("int"); + + b.Property("TeachesSpellId") + .HasColumnType("int"); + + b.Property("TintColor") + .HasMaxLength(16) + .HasColumnType("varchar(16)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("dungeon_item_definitions"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonLearnedSpell", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("DefinitionId") + .HasColumnType("int"); + + b.Property("LearnedAt") + .HasColumnType("datetime(6)"); + + b.Property("SpellDefinitionId") + .HasColumnType("int"); + + b.Property("SpellLevel") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CharacterId"); + + b.HasIndex("DefinitionId"); + + b.ToTable("dungeon_learned_spells"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonLootTable", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Description") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DropChanceMultiplier") + .HasColumnType("float"); + + b.Property("GuaranteedDrop") + .HasColumnType("tinyint(1)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("MaxDrops") + .HasColumnType("int"); + + b.Property("MaxTier") + .HasColumnType("int"); + + b.Property("MinDrops") + .HasColumnType("int"); + + b.Property("MinTier") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.ToTable("dungeon_loot_tables"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonLootTableEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("DropChance") + .HasColumnType("float"); + + b.Property("DropChancePerTier") + .HasColumnType("float"); + + b.Property("Guaranteed") + .HasColumnType("tinyint(1)"); + + b.Property("ItemDefinitionId") + .HasColumnType("int"); + + b.Property("LootTableId") + .HasColumnType("int"); + + b.Property("MaxDropChance") + .HasColumnType("float"); + + b.Property("MaxQuantity") + .HasColumnType("int"); + + b.Property("MinQuantity") + .HasColumnType("int"); + + b.Property("Weight") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ItemDefinitionId"); + + b.HasIndex("LootTableId"); + + b.ToTable("dungeon_loot_table_entries"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonMobDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AggroRange") + .HasColumnType("float"); + + b.Property("AnimationSpeed") + .HasColumnType("float"); + + b.Property("ArmorPerTier") + .HasColumnType("float"); + + b.Property("AttackRange") + .HasColumnType("float"); + + b.Property("AttackSpeed") + .HasColumnType("float"); + + b.Property("BaseArmor") + .HasColumnType("int"); + + b.Property("BaseHealth") + .HasColumnType("int"); + + b.Property("BaseMagicDamage") + .HasColumnType("int"); + + b.Property("BaseMagicResist") + .HasColumnType("int"); + + b.Property("BaseMana") + .HasColumnType("int"); + + b.Property("BasePhysicalDamage") + .HasColumnType("int"); + + b.Property("BaseXp") + .HasColumnType("int"); + + b.Property("Behavior") + .HasColumnType("int"); + + b.Property("CallForHelpRadius") + .HasColumnType("float"); + + b.Property("Category") + .HasColumnType("int"); + + b.Property("DamagePerTier") + .HasColumnType("float"); + + b.Property("DamageTypeKey") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DropChanceMultiplier") + .HasColumnType("float"); + + b.Property("FleeThreshold") + .HasColumnType("float"); + + b.Property("HealthPerTier") + .HasColumnType("float"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LeashRange") + .HasColumnType("float"); + + b.Property("LootTableId") + .HasColumnType("int"); + + b.Property("MaxTier") + .HasColumnType("int"); + + b.Property("MinTier") + .HasColumnType("int"); + + b.Property("MoveSpeed") + .HasColumnType("float"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("PhasesJson") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("PreferredRange") + .HasColumnType("float"); + + b.Property("ResistancesJson") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("Scale") + .HasColumnType("float"); + + b.Property("SpriteConfigJson") + .HasMaxLength(8192) + .HasColumnType("varchar(8192)"); + + b.Property("TintColor") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("varchar(16)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("XpPerTier") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("dungeon_mob_definitions"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonMobLootTable", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("LootTableId") + .HasColumnType("int"); + + b.Property("MobDefinitionId") + .HasColumnType("int"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("RollChance") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("LootTableId"); + + b.HasIndex("MobDefinitionId"); + + b.ToTable("dungeon_mob_loot_tables"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonPersistence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("BossKilled") + .HasColumnType("tinyint(1)"); + + b.Property("ChestStateJson") + .HasColumnType("json"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatorCharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("CreatorId") + .HasColumnType("bigint unsigned"); + + b.Property("CreatorLevel") + .HasColumnType("int"); + + b.Property("CreatorName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCleared") + .HasColumnType("tinyint(1)"); + + b.Property("LastActivity") + .HasColumnType("datetime(6)"); + + b.Property("LevelBracketMax") + .HasColumnType("int"); + + b.Property("LevelBracketMin") + .HasColumnType("int"); + + b.Property("LootChestStateJson") + .HasColumnType("json"); + + b.Property("MobStateJson") + .HasColumnType("json"); + + b.Property("PersistedAt") + .HasColumnType("datetime(6)"); + + b.Property("Seed") + .HasColumnType("int"); + + b.Property("Tier") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatorId"); + + b.ToTable("dungeon_instances"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonRecipeScroll", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("ItemDefinitionId") + .HasColumnType("int"); + + b.Property("RecipeId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ItemDefinitionId"); + + b.HasIndex("RecipeId"); + + b.ToTable("dungeon_recipe_scrolls"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonSpellDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AreaOfEffect") + .HasColumnType("float"); + + b.Property("BaseDamage") + .HasColumnType("int"); + + b.Property("BaseHealing") + .HasColumnType("int"); + + b.Property("Cooldown") + .HasColumnType("float"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("EffectColor") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("IsShield") + .HasColumnType("tinyint(1)"); + + b.Property("IsTeleport") + .HasColumnType("tinyint(1)"); + + b.Property("ManaCost") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Range") + .HasColumnType("float"); + + b.Property("RequiredIntelligence") + .HasColumnType("int"); + + b.Property("RequiredLevel") + .HasColumnType("int"); + + b.Property("RequiredWisdom") + .HasColumnType("int"); + + b.Property("ShieldAmount") + .HasColumnType("int"); + + b.Property("SpriteId") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("dungeon_spell_definitions"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonStashItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CharacterId") + .HasColumnType("bigint unsigned"); + + b.Property("DefinitionId") + .HasColumnType("int"); + + b.Property("ItemDefinitionId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("SlotIndex") + .HasColumnType("int"); + + b.Property("StoredAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("CharacterId"); + + b.HasIndex("DefinitionId"); + + b.ToTable("dungeon_stash_items"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobAbilityAssignment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AbilityDefinitionId") + .HasColumnType("int"); + + b.Property("CooldownOverride") + .HasColumnType("float"); + + b.Property("DamageOverride") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("MaxHpPercent") + .HasColumnType("float"); + + b.Property("MinHpPercent") + .HasColumnType("float"); + + b.Property("MobDefinitionId") + .HasColumnType("int"); + + b.Property("Phase") + .HasColumnType("int"); + + b.Property("PriorityOverride") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AbilityDefinitionId"); + + b.HasIndex("MobDefinitionId"); + + b.ToTable("dungeon_mob_ability_assignments"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobAbilityDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AbilityType") + .HasColumnType("int"); + + b.Property("AffectedStat") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("AnimationDuration") + .HasColumnType("float"); + + b.Property("AnimationKey") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("AoeRadius") + .HasColumnType("float"); + + b.Property("BaseDamage") + .HasColumnType("int"); + + b.Property("CastTime") + .HasColumnType("float"); + + b.Property("ConeAngle") + .HasColumnType("float"); + + b.Property("Cooldown") + .HasColumnType("float"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DamagePerTier") + .HasColumnType("float"); + + b.Property("DamageTypeKey") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DisplacementDistance") + .HasColumnType("float"); + + b.Property("DotDamagePerTick") + .HasColumnType("int"); + + b.Property("DotTickInterval") + .HasColumnType("float"); + + b.Property("EffectDuration") + .HasColumnType("float"); + + b.Property("HpThresholdAbove") + .HasColumnType("float"); + + b.Property("HpThresholdBelow") + .HasColumnType("float"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ManaCost") + .HasColumnType("int"); + + b.Property("MinTargetsInRange") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("ProjectileSpeed") + .HasColumnType("float"); + + b.Property("ProjectileSprite") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Range") + .HasColumnType("float"); + + b.Property("SoundEffectKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("SpeedModifier") + .HasColumnType("float"); + + b.Property("StatModifier") + .HasColumnType("float"); + + b.Property("SummonCount") + .HasColumnType("int"); + + b.Property("SummonMobId") + .HasColumnType("int"); + + b.Property("Targeting") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("VisualEffectKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.ToTable("dungeon_mob_abilities"); + }); + + modelBuilder.Entity("DataServer.Data.Session", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("bigint unsigned"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime(6)") + .HasDefaultValueSql("CURRENT_TIMESTAMP(6)"); + + b.Property("CreatedIp") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ExpiresAt") + .HasColumnType("datetime(6)"); + + b.Property("RevokedAt") + .HasColumnType("datetime(6)"); + + b.Property("TokenHash") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("UserAgent") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("TokenHash") + .IsUnique(); + + b.ToTable("sessions", (string)null); + }); + + modelBuilder.Entity("DataServer.Data.Zone", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint unsigned"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime(6)") + .HasDefaultValueSql("CURRENT_TIMESTAMP(6)"); + + b.Property("MaxX") + .HasColumnType("double"); + + b.Property("MaxY") + .HasColumnType("double"); + + b.Property("MaxZ") + .HasColumnType("double"); + + b.Property("MinX") + .HasColumnType("double"); + + b.Property("MinY") + .HasColumnType("double"); + + b.Property("MinZ") + .HasColumnType("double"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("UpdatedAt") + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("datetime(6)") + .HasDefaultValueSql("CURRENT_TIMESTAMP(6)"); + + MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property("UpdatedAt")); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("zones", (string)null); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DeathChest", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "OwnerCharacter") + .WithMany() + .HasForeignKey("OwnerCharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "VictimCharacter") + .WithMany() + .HasForeignKey("VictimCharacterId"); + + b.Navigation("OwnerCharacter"); + + b.Navigation("VictimCharacter"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DeathChestItem", b => + { + b.HasOne("DataServer.Data.Entities.DeathChest", "DeathChest") + .WithMany("Items") + .HasForeignKey("DeathChestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "ItemDefinition") + .WithMany() + .HasForeignKey("ItemDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DeathChest"); + + b.Navigation("ItemDefinition"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonBeltItem", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "Character") + .WithMany() + .HasForeignKey("CharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Character"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacter", b => + { + b.HasOne("DataServer.Data.Account", "Account") + .WithMany("Characters") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacterCraftingSkill", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "Character") + .WithMany("CraftingSkills") + .HasForeignKey("CharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Character"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacterItem", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "Character") + .WithMany("Inventory") + .HasForeignKey("CharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "ItemDefinition") + .WithMany() + .HasForeignKey("ItemDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Character"); + + b.Navigation("ItemDefinition"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacterItemCraftedLink", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacterItem", "CharacterItem") + .WithMany() + .HasForeignKey("CharacterItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonCraftedItem", "CraftedItem") + .WithMany() + .HasForeignKey("CraftedItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CharacterItem"); + + b.Navigation("CraftedItem"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacterKnownRecipe", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "Character") + .WithMany("KnownRecipes") + .HasForeignKey("CharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonCraftingRecipe", "Recipe") + .WithMany() + .HasForeignKey("RecipeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Character"); + + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCraftedItem", b => + { + b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "BaseItemDefinition") + .WithMany() + .HasForeignKey("BaseItemDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "Crafter") + .WithMany() + .HasForeignKey("CrafterId"); + + b.HasOne("DataServer.Data.Entities.DungeonCraftingRecipe", "Recipe") + .WithMany() + .HasForeignKey("RecipeId"); + + b.Navigation("BaseItemDefinition"); + + b.Navigation("Crafter"); + + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCraftingRecipe", b => + { + b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "OutputItem") + .WithMany() + .HasForeignKey("OutputItemDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OutputItem"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCraftingRecipeIngredient", b => + { + b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "ItemDefinition") + .WithMany() + .HasForeignKey("ItemDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonCraftingRecipe", "Recipe") + .WithMany("Ingredients") + .HasForeignKey("RecipeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ItemDefinition"); + + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonLearnedSpell", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "Character") + .WithMany("LearnedSpells") + .HasForeignKey("CharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonSpellDefinition", "Definition") + .WithMany() + .HasForeignKey("DefinitionId"); + + b.Navigation("Character"); + + b.Navigation("Definition"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonLootTableEntry", b => + { + b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "ItemDefinition") + .WithMany() + .HasForeignKey("ItemDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonLootTable", "LootTable") + .WithMany("Entries") + .HasForeignKey("LootTableId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ItemDefinition"); + + b.Navigation("LootTable"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonMobLootTable", b => + { + b.HasOne("DataServer.Data.Entities.DungeonLootTable", "LootTable") + .WithMany() + .HasForeignKey("LootTableId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonMobDefinition", "MobDefinition") + .WithMany() + .HasForeignKey("MobDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LootTable"); + + b.Navigation("MobDefinition"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonPersistence", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "Creator") + .WithMany() + .HasForeignKey("CreatorId"); + + b.Navigation("Creator"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonRecipeScroll", b => + { + b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "ItemDefinition") + .WithMany() + .HasForeignKey("ItemDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonCraftingRecipe", "Recipe") + .WithMany() + .HasForeignKey("RecipeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ItemDefinition"); + + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonStashItem", b => + { + b.HasOne("DataServer.Data.Entities.DungeonCharacter", "Character") + .WithMany("Stash") + .HasForeignKey("CharacterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonItemDefinition", "Definition") + .WithMany() + .HasForeignKey("DefinitionId"); + + b.Navigation("Character"); + + b.Navigation("Definition"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobAbilityAssignment", b => + { + b.HasOne("DataServer.Data.Entities.MobAbilityDefinition", "AbilityDefinition") + .WithMany() + .HasForeignKey("AbilityDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonMobDefinition", "MobDefinition") + .WithMany("AbilityAssignments") + .HasForeignKey("MobDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AbilityDefinition"); + + b.Navigation("MobDefinition"); + }); + + modelBuilder.Entity("DataServer.Data.Session", b => + { + b.HasOne("DataServer.Data.Account", "Account") + .WithMany("Sessions") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("DataServer.Data.Account", b => + { + b.Navigation("Characters"); + + b.Navigation("Sessions"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DeathChest", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCharacter", b => + { + b.Navigation("CraftingSkills"); + + b.Navigation("Inventory"); + + b.Navigation("KnownRecipes"); + + b.Navigation("LearnedSpells"); + + b.Navigation("Stash"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonCraftingRecipe", b => + { + b.Navigation("Ingredients"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonLootTable", b => + { + b.Navigation("Entries"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonMobDefinition", b => + { + b.Navigation("AbilityAssignments"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20251227160629_Mob AI.cs b/Migrations/20251227160629_Mob AI.cs new file mode 100644 index 0000000..b42a0b7 --- /dev/null +++ b/Migrations/20251227160629_Mob AI.cs @@ -0,0 +1,223 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace SystemRevivalServer.Migrations +{ + /// + public partial class MobAI : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "AbilitiesJson", + table: "dungeon_mob_definitions"); + + migrationBuilder.AlterColumn( + name: "SpriteConfigJson", + table: "dungeon_mob_definitions", + type: "varchar(8192)", + maxLength: 8192, + nullable: true, + oldClrType: typeof(string), + oldType: "varchar(4096)", + oldMaxLength: 4096, + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddColumn( + name: "Behavior", + table: "dungeon_mob_definitions", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "CallForHelpRadius", + table: "dungeon_mob_definitions", + type: "float", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "FleeThreshold", + table: "dungeon_mob_definitions", + type: "float", + nullable: false, + defaultValue: 0f); + + migrationBuilder.AddColumn( + name: "PhasesJson", + table: "dungeon_mob_definitions", + type: "varchar(2048)", + maxLength: 2048, + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddColumn( + name: "PreferredRange", + table: "dungeon_mob_definitions", + type: "float", + nullable: false, + defaultValue: 0f); + + migrationBuilder.CreateTable( + name: "dungeon_mob_abilities", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Name = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(256)", maxLength: 256, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Key = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + AbilityType = table.Column(type: "int", nullable: false), + Targeting = table.Column(type: "int", nullable: false), + BaseDamage = table.Column(type: "int", nullable: false), + DamagePerTier = table.Column(type: "float", nullable: false), + DamageTypeKey = table.Column(type: "varchar(32)", maxLength: 32, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Range = table.Column(type: "float", nullable: false), + AoeRadius = table.Column(type: "float", nullable: false), + ConeAngle = table.Column(type: "float", nullable: false), + Cooldown = table.Column(type: "float", nullable: false), + CastTime = table.Column(type: "float", nullable: false), + AnimationDuration = table.Column(type: "float", nullable: false), + ProjectileSpeed = table.Column(type: "float", nullable: false), + ProjectileSprite = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + EffectDuration = table.Column(type: "float", nullable: false), + DotDamagePerTick = table.Column(type: "int", nullable: false), + DotTickInterval = table.Column(type: "float", nullable: false), + SpeedModifier = table.Column(type: "float", nullable: false), + DisplacementDistance = table.Column(type: "float", nullable: false), + SummonMobId = table.Column(type: "int", nullable: true), + SummonCount = table.Column(type: "int", nullable: false), + StatModifier = table.Column(type: "float", nullable: false), + AffectedStat = table.Column(type: "varchar(32)", maxLength: 32, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + HpThresholdBelow = table.Column(type: "float", nullable: true), + HpThresholdAbove = table.Column(type: "float", nullable: true), + MinTargetsInRange = table.Column(type: "int", nullable: true), + Priority = table.Column(type: "int", nullable: false), + ManaCost = table.Column(type: "int", nullable: false), + AnimationKey = table.Column(type: "varchar(32)", maxLength: 32, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + SoundEffectKey = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + VisualEffectKey = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + IsEnabled = table.Column(type: "tinyint(1)", nullable: false), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + UpdatedAt = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_dungeon_mob_abilities", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "dungeon_mob_ability_assignments", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + MobDefinitionId = table.Column(type: "int", nullable: false), + AbilityDefinitionId = table.Column(type: "int", nullable: false), + CooldownOverride = table.Column(type: "float", nullable: true), + DamageOverride = table.Column(type: "int", nullable: true), + PriorityOverride = table.Column(type: "int", nullable: true), + Phase = table.Column(type: "int", nullable: false), + MinHpPercent = table.Column(type: "float", nullable: true), + MaxHpPercent = table.Column(type: "float", nullable: true), + IsEnabled = table.Column(type: "tinyint(1)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_dungeon_mob_ability_assignments", x => x.Id); + table.ForeignKey( + name: "FK_dungeon_mob_ability_assignments_dungeon_mob_abilities_Abilit~", + column: x => x.AbilityDefinitionId, + principalTable: "dungeon_mob_abilities", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_dungeon_mob_ability_assignments_dungeon_mob_definitions_MobD~", + column: x => x.MobDefinitionId, + principalTable: "dungeon_mob_definitions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_dungeon_mob_ability_assignments_AbilityDefinitionId", + table: "dungeon_mob_ability_assignments", + column: "AbilityDefinitionId"); + + migrationBuilder.CreateIndex( + name: "IX_dungeon_mob_ability_assignments_MobDefinitionId", + table: "dungeon_mob_ability_assignments", + column: "MobDefinitionId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "dungeon_mob_ability_assignments"); + + migrationBuilder.DropTable( + name: "dungeon_mob_abilities"); + + migrationBuilder.DropColumn( + name: "Behavior", + table: "dungeon_mob_definitions"); + + migrationBuilder.DropColumn( + name: "CallForHelpRadius", + table: "dungeon_mob_definitions"); + + migrationBuilder.DropColumn( + name: "FleeThreshold", + table: "dungeon_mob_definitions"); + + migrationBuilder.DropColumn( + name: "PhasesJson", + table: "dungeon_mob_definitions"); + + migrationBuilder.DropColumn( + name: "PreferredRange", + table: "dungeon_mob_definitions"); + + migrationBuilder.AlterColumn( + name: "SpriteConfigJson", + table: "dungeon_mob_definitions", + type: "varchar(4096)", + maxLength: 4096, + nullable: true, + oldClrType: typeof(string), + oldType: "varchar(8192)", + oldMaxLength: 8192, + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddColumn( + name: "AbilitiesJson", + table: "dungeon_mob_definitions", + type: "varchar(1024)", + maxLength: 1024, + nullable: false, + defaultValue: "") + .Annotation("MySql:CharSet", "utf8mb4"); + } + } +} diff --git a/Migrations/GameDbContextModelSnapshot.cs b/Migrations/GameDbContextModelSnapshot.cs index c8fa246..5c97a36 100644 --- a/Migrations/GameDbContextModelSnapshot.cs +++ b/Migrations/GameDbContextModelSnapshot.cs @@ -963,11 +963,6 @@ namespace SystemRevivalServer.Migrations MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); - b.Property("AbilitiesJson") - .IsRequired() - .HasMaxLength(1024) - .HasColumnType("varchar(1024)"); - b.Property("AggroRange") .HasColumnType("float"); @@ -1004,6 +999,12 @@ namespace SystemRevivalServer.Migrations b.Property("BaseXp") .HasColumnType("int"); + b.Property("Behavior") + .HasColumnType("int"); + + b.Property("CallForHelpRadius") + .HasColumnType("float"); + b.Property("Category") .HasColumnType("int"); @@ -1023,6 +1024,9 @@ namespace SystemRevivalServer.Migrations b.Property("DropChanceMultiplier") .HasColumnType("float"); + b.Property("FleeThreshold") + .HasColumnType("float"); + b.Property("HealthPerTier") .HasColumnType("float"); @@ -1049,6 +1053,13 @@ namespace SystemRevivalServer.Migrations .HasMaxLength(64) .HasColumnType("varchar(64)"); + b.Property("PhasesJson") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("PreferredRange") + .HasColumnType("float"); + b.Property("ResistancesJson") .IsRequired() .HasMaxLength(1024) @@ -1058,8 +1069,8 @@ namespace SystemRevivalServer.Migrations .HasColumnType("float"); b.Property("SpriteConfigJson") - .HasMaxLength(4096) - .HasColumnType("varchar(4096)"); + .HasMaxLength(8192) + .HasColumnType("varchar(8192)"); b.Property("TintColor") .IsRequired() @@ -1298,6 +1309,185 @@ namespace SystemRevivalServer.Migrations b.ToTable("dungeon_stash_items"); }); + modelBuilder.Entity("DataServer.Data.Entities.MobAbilityAssignment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AbilityDefinitionId") + .HasColumnType("int"); + + b.Property("CooldownOverride") + .HasColumnType("float"); + + b.Property("DamageOverride") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("MaxHpPercent") + .HasColumnType("float"); + + b.Property("MinHpPercent") + .HasColumnType("float"); + + b.Property("MobDefinitionId") + .HasColumnType("int"); + + b.Property("Phase") + .HasColumnType("int"); + + b.Property("PriorityOverride") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AbilityDefinitionId"); + + b.HasIndex("MobDefinitionId"); + + b.ToTable("dungeon_mob_ability_assignments"); + }); + + modelBuilder.Entity("DataServer.Data.Entities.MobAbilityDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("AbilityType") + .HasColumnType("int"); + + b.Property("AffectedStat") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("AnimationDuration") + .HasColumnType("float"); + + b.Property("AnimationKey") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("AoeRadius") + .HasColumnType("float"); + + b.Property("BaseDamage") + .HasColumnType("int"); + + b.Property("CastTime") + .HasColumnType("float"); + + b.Property("ConeAngle") + .HasColumnType("float"); + + b.Property("Cooldown") + .HasColumnType("float"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DamagePerTier") + .HasColumnType("float"); + + b.Property("DamageTypeKey") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DisplacementDistance") + .HasColumnType("float"); + + b.Property("DotDamagePerTick") + .HasColumnType("int"); + + b.Property("DotTickInterval") + .HasColumnType("float"); + + b.Property("EffectDuration") + .HasColumnType("float"); + + b.Property("HpThresholdAbove") + .HasColumnType("float"); + + b.Property("HpThresholdBelow") + .HasColumnType("float"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ManaCost") + .HasColumnType("int"); + + b.Property("MinTargetsInRange") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("ProjectileSpeed") + .HasColumnType("float"); + + b.Property("ProjectileSprite") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Range") + .HasColumnType("float"); + + b.Property("SoundEffectKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("SpeedModifier") + .HasColumnType("float"); + + b.Property("StatModifier") + .HasColumnType("float"); + + b.Property("SummonCount") + .HasColumnType("int"); + + b.Property("SummonMobId") + .HasColumnType("int"); + + b.Property("Targeting") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("VisualEffectKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.ToTable("dungeon_mob_abilities"); + }); + modelBuilder.Entity("DataServer.Data.Session", b => { b.Property("Id") @@ -1673,6 +1863,25 @@ namespace SystemRevivalServer.Migrations b.Navigation("Definition"); }); + modelBuilder.Entity("DataServer.Data.Entities.MobAbilityAssignment", b => + { + b.HasOne("DataServer.Data.Entities.MobAbilityDefinition", "AbilityDefinition") + .WithMany() + .HasForeignKey("AbilityDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DataServer.Data.Entities.DungeonMobDefinition", "MobDefinition") + .WithMany("AbilityAssignments") + .HasForeignKey("MobDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AbilityDefinition"); + + b.Navigation("MobDefinition"); + }); + modelBuilder.Entity("DataServer.Data.Session", b => { b.HasOne("DataServer.Data.Account", "Account") @@ -1718,6 +1927,11 @@ namespace SystemRevivalServer.Migrations { b.Navigation("Entries"); }); + + modelBuilder.Entity("DataServer.Data.Entities.DungeonMobDefinition", b => + { + b.Navigation("AbilityAssignments"); + }); #pragma warning restore 612, 618 } } diff --git a/Services/Admin/Pages/Mobs/Edit.cshtml.cs b/Services/Admin/Pages/Mobs/Edit.cshtml.cs index 731dc5e..52f0f0a 100644 --- a/Services/Admin/Pages/Mobs/Edit.cshtml.cs +++ b/Services/Admin/Pages/Mobs/Edit.cshtml.cs @@ -230,7 +230,10 @@ public class EditModel : AdminPageModel AnimationSpeed = Mob.AnimationSpeed, SpriteConfigJson = Mob.SpriteConfigJson, ResistancesJson = Mob.ResistancesJson, - AbilitiesJson = Mob.AbilitiesJson, + Behavior = Mob.Behavior, + PreferredRange = Mob.PreferredRange, + FleeThreshold = Mob.FleeThreshold, + CallForHelpRadius = Mob.CallForHelpRadius, IsEnabled = Mob.IsEnabled }; _db.DungeonMobDefinitions.Add(newMob); diff --git a/data/GameDbContext.cs b/data/GameDbContext.cs index 500388a..570cec4 100644 --- a/data/GameDbContext.cs +++ b/data/GameDbContext.cs @@ -22,6 +22,11 @@ public sealed class GameDbContext : DbContext public DbSet DungeonLootTables => Set(); public DbSet DungeonLootTableEntries => Set(); public DbSet DungeonMobLootTables => Set(); + + // Mob abilities + public DbSet MobAbilityDefinitions => Set(); + public DbSet MobAbilityAssignments => Set(); + public DbSet DungeonBeltItems => Set(); public DbSet DeathChests => Set(); public DbSet DeathChestItems => Set(); diff --git a/data/entities/DungeonCharacterStats.cs b/data/entities/DungeonCharacterStats.cs index f6a75f3..4306b30 100644 --- a/data/entities/DungeonCharacterStats.cs +++ b/data/entities/DungeonCharacterStats.cs @@ -5,11 +5,15 @@ namespace DataServer.Data.Entities; /// public static class DungeonCharacterStats { + private const float BaseSpeed = 100f; + private const float DexSpeedModifier = 0.5f; // Reduced from 2f + private const float MaxSpeed = 500f; + public static int GetMaxHealth(DungeonCharacter c) => 50 + (c.Endurance * 10); public static int GetMaxMana(DungeonCharacter c) => 20 + (c.Wisdom * 8); public static int GetMaxStamina(DungeonCharacter c) => 50 + (c.Endurance * 5); public static float GetXpBonus(DungeonCharacter c) => 1.0f + (c.Wisdom * 0.02f); - public static float GetMoveSpeed(DungeonCharacter c) => 100f + (c.Dexterity * 2f); + public static float GetMoveSpeed(DungeonCharacter c) => Math.Min(MaxSpeed, BaseSpeed + (c.Dexterity * DexSpeedModifier)); public static float GetAttackSpeed(DungeonCharacter c) => 1.0f + (c.Dexterity * 0.02f); public static float GetRegenRate(DungeonCharacter c) => 1.0f + (c.Endurance * 0.1f); @@ -45,7 +49,7 @@ public static class DungeonCharacterStats stats.MaxHealth = 50 + (stats.Endurance * 10) + stats.BonusHealth; stats.MaxMana = 20 + (stats.Wisdom * 8) + stats.BonusMana; stats.MaxStamina = 50 + (stats.Endurance * 5); - stats.MoveSpeed = 100f + (stats.Dexterity * 2f); + stats.MoveSpeed = Math.Min(MaxSpeed, BaseSpeed + (stats.Dexterity * DexSpeedModifier)); stats.AttackSpeed = 1.0f + (stats.Dexterity * 0.02f); stats.RegenRate = 1.0f + (stats.Endurance * 0.1f); stats.PhysicalDamageMultiplier = 1.0f + (stats.Strength * 0.05f); diff --git a/data/entities/DungeonMobDefinition.cs b/data/entities/DungeonMobDefinition.cs index 73e54a2..b231e5f 100644 --- a/data/entities/DungeonMobDefinition.cs +++ b/data/entities/DungeonMobDefinition.cs @@ -24,6 +24,11 @@ public class DungeonMobDefinition public MobType Type { get; set; } = MobType.Normal; public MobCategory Category { get; set; } = MobCategory.Undead; + /// + /// AI behavior pattern for this mob + /// + public MobBehavior Behavior { get; set; } = MobBehavior.Aggressive; + public int MinTier { get; set; } = 1; // Minimum dungeon tier to spawn public int MaxTier { get; set; } = 99; // Maximum tier (for progression gating) @@ -49,6 +54,21 @@ public class DungeonMobDefinition public float AggroRange { get; set; } = 150f; // Detection radius public float LeashRange { get; set; } = 400f; // Max chase distance before reset + /// + /// Preferred combat distance (for ranged/skirmisher behaviors) + /// + public float PreferredRange { get; set; } = 40f; + + /// + /// Flee threshold - if HP drops below this %, mob may flee (for skirmisher/defensive) + /// + public float FleeThreshold { get; set; } = 0f; + + /// + /// Call for help radius - alerts nearby mobs when engaged + /// + public float CallForHelpRadius { get; set; } = 0f; + // Scaling per dungeon tier (multipliers) public float HealthPerTier { get; set; } = 1.2f; public float DamagePerTier { get; set; } = 1.15f; @@ -69,32 +89,38 @@ public class DungeonMobDefinition public string ResistancesJson { get; set; } = "{}"; /// - /// JSON block for special abilities/behaviors - /// Example: {"canFlee": true, "fleeHealthPercent": 0.2, "callsForHelp": true} + /// JSON block for boss phases (for multi-phase bosses) + /// Example: [{"hpThreshold": 0.75, "behavior": "Enrage"}, {"hpThreshold": 0.25, "behavior": "Summoner"}] /// - [MaxLength(1024)] - public string AbilitiesJson { get; set; } = "{}"; + [MaxLength(2048)] + public string? PhasesJson { get; set; } // Visuals /// /// JSON configuration for mob sprites and animations - /// Example: { - /// "sprites": { - /// "idle_front": "assets/sprites/skeleton_idle_front.png", - /// "idle_back": "assets/sprites/skeleton_idle_back.png", - /// "run_front": "assets/sprites/skeleton_run_front.png" - /// }, + /// Structure: { + /// "spriteSheet": "textures/mobs/skeleton.png", /// "frameWidth": 64, /// "frameHeight": 64, - /// "fps": 8, /// "animations": { - /// "idle_front": {"frames": 8, "loop": true}, - /// "run_front": {"frames": 8, "loop": true} + /// "idle_down": {"row": 0, "frames": 4, "fps": 4, "loop": true}, + /// "idle_up": {"row": 1, "frames": 4, "fps": 4, "loop": true}, + /// "idle_left": {"row": 2, "frames": 4, "fps": 4, "loop": true}, + /// "idle_right": {"row": 3, "frames": 4, "fps": 4, "loop": true}, + /// "walk_down": {"row": 4, "frames": 8, "fps": 8, "loop": true}, + /// "walk_up": {"row": 5, "frames": 8, "fps": 8, "loop": true}, + /// "walk_left": {"row": 6, "frames": 8, "fps": 8, "loop": true}, + /// "walk_right": {"row": 7, "frames": 8, "fps": 8, "loop": true}, + /// "attack_down": {"row": 8, "frames": 6, "fps": 12, "loop": false}, + /// "attack_up": {"row": 9, "frames": 6, "fps": 12, "loop": false}, + /// "attack_left": {"row": 10, "frames": 6, "fps": 12, "loop": false}, + /// "attack_right": {"row": 11, "frames": 6, "fps": 12, "loop": false}, + /// "cast_down": {"row": 12, "frames": 8, "fps": 10, "loop": false}, + /// "death": {"row": 16, "frames": 6, "fps": 8, "loop": false} /// } /// } - /// If null/empty, client uses fallback placeholder shape /// - [MaxLength(4096)] + [MaxLength(8192)] public string? SpriteConfigJson { get; set; } /// @@ -112,6 +138,12 @@ public class DungeonMobDefinition public bool IsEnabled { get; set; } = true; + // === Navigation Properties === + /// + /// Abilities assigned to this mob + /// + public ICollection AbilityAssignments { get; set; } = new List(); + // Helper to get parsed sprite config [NotMapped] public Dictionary? SpriteConfig @@ -137,18 +169,17 @@ public class DungeonMobDefinition } [NotMapped] - public Dictionary Abilities + public List? Phases { get { - try { return JsonSerializer.Deserialize>(AbilitiesJson) ?? new(); } - catch { return new(); } + if (string.IsNullOrEmpty(PhasesJson)) return null; + try { return JsonSerializer.Deserialize>(PhasesJson); } + catch { return null; } } - set { AbilitiesJson = JsonSerializer.Serialize(value); } + set { PhasesJson = value != null ? JsonSerializer.Serialize(value) : null; } } - - /// /// Calculate scaled stats for a specific level bracket /// Level bracket scaling: each bracket adds 15% to base stats @@ -178,3 +209,24 @@ public class DungeonMobDefinition }; } } + +/// +/// Configuration for a boss phase +/// +public class MobPhaseConfig +{ + /// HP threshold to trigger this phase (0-1) + public float HpThreshold { get; set; } + + /// New behavior for this phase + public MobBehavior Behavior { get; set; } + + /// Speed multiplier for this phase + public float SpeedMultiplier { get; set; } = 1.0f; + + /// Damage multiplier for this phase + public float DamageMultiplier { get; set; } = 1.0f; + + /// Optional message to display when entering phase + public string? PhaseMessage { get; set; } +} diff --git a/data/entities/MobAbilityAssignment.cs b/data/entities/MobAbilityAssignment.cs new file mode 100644 index 0000000..71debd6 --- /dev/null +++ b/data/entities/MobAbilityAssignment.cs @@ -0,0 +1,63 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace DataServer.Data.Entities; + +/// +/// Junction table linking mobs to their abilities +/// A mob can have multiple abilities, and abilities can be shared +/// +[Table("dungeon_mob_ability_assignments")] +public class MobAbilityAssignment +{ + [Key] + public int Id { get; set; } + + /// The mob definition this ability is assigned to + public int MobDefinitionId { get; set; } + + [ForeignKey(nameof(MobDefinitionId))] + public DungeonMobDefinition? MobDefinition { get; set; } + + /// The ability definition + public int AbilityDefinitionId { get; set; } + + [ForeignKey(nameof(AbilityDefinitionId))] + public MobAbilityDefinition? AbilityDefinition { get; set; } + + /// + /// Override cooldown for this mob (null = use ability default) + /// + public float? CooldownOverride { get; set; } + + /// + /// Override damage for this mob (null = use ability default) + /// + public int? DamageOverride { get; set; } + + /// + /// Priority override for AI selection (null = use ability default) + /// + public int? PriorityOverride { get; set; } + + /// + /// Phase this ability is available in (for multi-phase bosses) + /// 0 = all phases, 1 = phase 1 only, etc. + /// + public int Phase { get; set; } = 0; + + /// + /// Minimum HP percentage for this ability to be available (0-1) + /// + public float? MinHpPercent { get; set; } + + /// + /// Maximum HP percentage for this ability to be available (0-1) + /// + public float? MaxHpPercent { get; set; } + + /// + /// Is this ability enabled for this mob + /// + public bool IsEnabled { get; set; } = true; +} diff --git a/data/entities/MobAbilityDefinition.cs b/data/entities/MobAbilityDefinition.cs new file mode 100644 index 0000000..d114974 --- /dev/null +++ b/data/entities/MobAbilityDefinition.cs @@ -0,0 +1,143 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using DataServer.Data.Enums; + +namespace DataServer.Data.Entities; + +/// +/// Definition for a mob ability that can be assigned to mobs +/// +[Table("dungeon_mob_abilities")] +public class MobAbilityDefinition +{ + [Key] + public int Id { get; set; } + + [Required] + [MaxLength(64)] + public string Name { get; set; } = ""; + + [MaxLength(256)] + public string Description { get; set; } = ""; + + /// + /// Internal key for referencing (e.g., "skeleton_arrow", "boss_slam") + /// + [Required] + [MaxLength(64)] + public string Key { get; set; } = ""; + + public MobAbilityType AbilityType { get; set; } = MobAbilityType.MeleeAttack; + public MobAbilityTargeting Targeting { get; set; } = MobAbilityTargeting.CurrentTarget; + + // === Damage/Healing === + /// Base damage or healing amount + public int BaseDamage { get; set; } = 10; + + /// Damage scaling per dungeon tier + public float DamagePerTier { get; set; } = 1.15f; + + /// Damage type key (references DamageResistanceType) + [MaxLength(32)] + public string DamageTypeKey { get; set; } = "physical"; + + // === Range & Area === + /// Maximum range to use ability + public float Range { get; set; } = 40f; + + /// AOE radius (0 for single target) + public float AoeRadius { get; set; } = 0f; + + /// Cone angle in degrees (for cone attacks) + public float ConeAngle { get; set; } = 0f; + + // === Timing === + /// Cooldown in seconds between uses + public float Cooldown { get; set; } = 5f; + + /// Cast time in seconds (0 for instant) + public float CastTime { get; set; } = 0f; + + /// Animation duration in seconds + public float AnimationDuration { get; set; } = 0.5f; + + // === Projectile (if applicable) === + /// Projectile speed (if projectile type) + public float ProjectileSpeed { get; set; } = 300f; + + /// Projectile sprite path + [MaxLength(256)] + public string? ProjectileSprite { get; set; } + + // === Status Effects === + /// Duration of any applied status effect + public float EffectDuration { get; set; } = 3f; + + /// Damage per tick for DOT effects + public int DotDamagePerTick { get; set; } = 5; + + /// Tick interval for DOT effects + public float DotTickInterval { get; set; } = 1f; + + /// Slow/speed modifier (0.5 = 50% slow) + public float SpeedModifier { get; set; } = 0.5f; + + /// Knockback/pull distance + public float DisplacementDistance { get; set; } = 100f; + + // === Summoning === + /// Mob definition ID to summon + public int? SummonMobId { get; set; } + + /// Number of mobs to summon + public int SummonCount { get; set; } = 1; + + // === Buff/Debuff === + /// Stat modifier percentage (1.5 = +50%, 0.5 = -50%) + public float StatModifier { get; set; } = 1.0f; + + /// Which stat to modify (damage, defense, speed, etc.) + [MaxLength(32)] + public string? AffectedStat { get; set; } + + // === Conditions === + /// Only usable below this HP percentage (0-1) + public float? HpThresholdBelow { get; set; } + + /// Only usable above this HP percentage (0-1) + public float? HpThresholdAbove { get; set; } + + /// Minimum number of targets in range to use + public int? MinTargetsInRange { get; set; } + + /// Priority for AI ability selection (higher = more likely) + public int Priority { get; set; } = 1; + + // === Mana/Resource Cost === + public int ManaCost { get; set; } = 0; + + // === Animation === + /// + /// Animation key to play (e.g., "attack", "cast", "special1") + /// Client will look for [animation]_[direction] sprites + /// + [MaxLength(32)] + public string AnimationKey { get; set; } = "attack"; + + /// + /// Sound effect key to play + /// + [MaxLength(64)] + public string? SoundEffectKey { get; set; } + + /// + /// Visual effect to spawn (particle effect key) + /// + [MaxLength(64)] + public string? VisualEffectKey { get; set; } + + public bool IsEnabled { get; set; } = true; + + public DateTime CreatedAt { get; set; } = DateTime.UtcNow; + public DateTime UpdatedAt { get; set; } = DateTime.UtcNow; +} diff --git a/data/enums/MobAbilityTargeting.cs b/data/enums/MobAbilityTargeting.cs new file mode 100644 index 0000000..bf1b6df --- /dev/null +++ b/data/enums/MobAbilityTargeting.cs @@ -0,0 +1,46 @@ +namespace DataServer.Data.Enums; + +/// +/// How an ability selects its target +/// +public enum MobAbilityTargeting +{ + /// Targets self + Self, + + /// Targets current aggro target + CurrentTarget, + + /// Targets nearest enemy + NearestEnemy, + + /// Targets lowest HP enemy + LowestHpEnemy, + + /// Targets highest HP enemy + HighestHpEnemy, + + /// Targets nearest ally + NearestAlly, + + /// Targets lowest HP ally + LowestHpAlly, + + /// Targets random enemy in range + RandomEnemy, + + /// Targets ground location + GroundLocation, + + /// AOE around self + AroundSelf, + + /// AOE around target + AroundTarget, + + /// All enemies in range + AllEnemiesInRange, + + /// All allies in range + AllAlliesInRange +} diff --git a/data/enums/MobAbilityType.cs b/data/enums/MobAbilityType.cs new file mode 100644 index 0000000..4e1b769 --- /dev/null +++ b/data/enums/MobAbilityType.cs @@ -0,0 +1,108 @@ +namespace DataServer.Data.Enums; + +/// +/// Types of abilities mobs can use +/// +public enum MobAbilityType +{ + // === Damage Abilities === + /// Basic melee attack + MeleeAttack, + + /// Single target projectile + ProjectileSingle, + + /// Projectile that explodes on impact for AOE damage + ProjectileAoe, + + /// Ground-targeted AOE damage zone + GroundAoe, + + /// Cone-shaped attack in front of mob + ConeAttack, + + /// Attack all targets in range + Cleave, + + // === Healing Abilities === + /// Heal self + HealSelf, + + /// Heal single ally + HealAlly, + + /// AOE heal for nearby allies + HealAoe, + + // === Summoning === + /// Summon a single mob + SummonSingle, + + /// Summon multiple mobs at once + SummonBulk, + + // === Crowd Control === + /// Stun target, preventing movement and actions + Stun, + + /// Knock target back from mob + Knockback, + + /// Fear target, causing them to flee + Fear, + + /// Pull target toward mob + Pull, + + /// Root target in place (can still attack) + Root, + + /// Slow target movement speed + Slow, + + /// Silence target (prevent ability use) + Silence, + + // === Damage Over Time === + /// Apply poison damage over time + Poison, + + /// Apply bleed damage over time + Bleed, + + /// Apply burn damage over time + Burn, + + // === Buffs/Debuffs === + /// Buff self with increased stats + BuffSelf, + + /// Buff nearby allies + BuffAllies, + + /// Debuff target with reduced stats + Debuff, + + /// Enrage - increased damage, possibly reduced defense + Enrage, + + /// Shield self from damage + Shield, + + // === Movement === + /// Dash/charge toward target + Charge, + + /// Teleport to location + Teleport, + + /// Dash away from target + Retreat, + + // === Special === + /// Create a dangerous zone on ground + HazardZone, + + /// Phase change - switch behavior/abilities at HP threshold + PhaseChange +} diff --git a/data/enums/MobBehavior.cs b/data/enums/MobBehavior.cs new file mode 100644 index 0000000..1249898 --- /dev/null +++ b/data/enums/MobBehavior.cs @@ -0,0 +1,37 @@ +namespace DataServer.Data.Enums; + +/// +/// AI behavior patterns for mobs +/// +public enum MobBehavior +{ + /// Charges player on sight, melee attacks + Aggressive, + + /// Stays near spawn, only attacks if approached + Defensive, + + /// Keeps distance, fires projectiles + Ranged, + + /// Hit-and-run tactics, kites players + Skirmisher, + + /// Spawns additional mobs, stays back + Summoner, + + /// High HP, slow movement, blocks paths + Tank, + + /// Targets low-HP players, high burst damage + Assassin, + + /// Heals nearby allied mobs + Healer, + + /// Walks a route, alerts others on player sight + Patrol, + + /// Calls nearby mobs when engaged + Pack +}