diff --git a/Game/Dungeon/DungeonSimulation.cs b/Game/Dungeon/DungeonSimulation.cs index 8f0fa65..60680e0 100644 --- a/Game/Dungeon/DungeonSimulation.cs +++ b/Game/Dungeon/DungeonSimulation.cs @@ -252,13 +252,16 @@ public partial class DungeonSimulation mob.Abilities.Clear(); LoadMobAbilities(mob, mobDef); - // If no abilities loaded, give a basic attack - if (mob.Abilities.Count == 0) + bool hasBasicMelee = mob.Abilities.Any(a => a.Definition.AbilityType == MobAbilityType.MeleeAttack); + + // Always ensure there is at least one reliable melee fallback. + // This prevents ability setups (mana-gated/unimplemented types) from disabling all mob damage. + if (!hasBasicMelee) { if (mobDef.Id == 100 || mobDef.Name == "The Bone Lord") { Console.WriteLine( - $"[DungeonSimulation] Bone Lord has no loaded abilities; falling back to Basic Attack."); + $"[DungeonSimulation] Bone Lord has no melee fallback; adding Basic Attack."); } mob.Abilities.Add(new MobAbilityState @@ -430,23 +433,20 @@ public partial class DungeonSimulation /// private void ProcessMobAbility(MobInstance mob, PlayerInstance target) { - // Find the best available ability + // Find the best currently usable ability. var ability = mob.Abilities .Where(a => a.IsAvailable(mob.HpPercent)) .Where(a => a.Phase == 0 || a.Phase == mob.CurrentPhase) + .Where(a => IsImplementedAbilityType(a.Definition.AbilityType)) + .Where(a => CanUseAbilityNow(mob, target, a.Definition)) .OrderByDescending(a => a.Priority) .FirstOrDefault(); if (ability == null) return; - - float distance = Distance(mob.X, mob.Y, target.X, target.Y); - bool isSummonAbility = ability.Definition.AbilityType is MobAbilityType.SummonSingle or MobAbilityType.SummonBulk; - if (!isSummonAbility && ability.Definition.Range > 0 && distance > ability.Definition.Range) return; int manaCost = Math.Max(0, ability.Definition.ManaCost); if (manaCost > 0) { - if (mob.Mana < manaCost) return; mob.Mana -= manaCost; } @@ -517,6 +517,53 @@ public partial class DungeonSimulation } } + private static bool CanUseAbilityNow(MobInstance mob, PlayerInstance target, MobAbilityDefinition definition) + { + int manaCost = Math.Max(0, definition.ManaCost); + if (manaCost > 0 && mob.Mana < manaCost) + { + return false; + } + + bool isSummonAbility = definition.AbilityType is MobAbilityType.SummonSingle or MobAbilityType.SummonBulk; + if (!isSummonAbility && definition.Range > 0) + { + float distance = Distance(mob.X, mob.Y, target.X, target.Y); + if (distance > definition.Range) + { + return false; + } + } + + return true; + } + + private static bool IsImplementedAbilityType(MobAbilityType type) + { + return type switch + { + MobAbilityType.SummonSingle => true, + MobAbilityType.SummonBulk => true, + MobAbilityType.MeleeAttack => true, + MobAbilityType.Cleave => true, + MobAbilityType.ProjectileSingle => true, + MobAbilityType.ProjectileAoe => true, + MobAbilityType.GroundAoe => true, + MobAbilityType.ConeAttack => true, + MobAbilityType.Poison => true, + MobAbilityType.Bleed => true, + MobAbilityType.Burn => true, + MobAbilityType.Stun => true, + MobAbilityType.Slow => true, + MobAbilityType.Root => true, + MobAbilityType.Fear => true, + MobAbilityType.Knockback => true, + MobAbilityType.Pull => true, + MobAbilityType.HazardZone => true, + _ => false + }; + } + private void ProcessSummonAbility(MobInstance mob, MobAbilityDefinition ability) { if (!ability.SummonMobId.HasValue) diff --git a/abilityTemp.md b/abilityTemp.md index ca3440c..192cca1 100644 --- a/abilityTemp.md +++ b/abilityTemp.md @@ -86,4 +86,12 @@ COMMIT; ## Notes 1. `SummonMobId` is set to `1` for summon tests; adjust if you want another summon target. 2. These are seeded with `TEMP_TEST_*` keys so you can remove them quickly. -3. If you want, I can generate a matching cleanup script for `dungeon_mob_ability_assignments` by key lookup. +3. For broad behavior testing on low/zero-mana mobs, run this after insert: + +```sql +UPDATE `dungeon_mob_abilities` +SET `ManaCost` = 0 +WHERE `Key` LIKE 'TEMP_TEST_%'; +``` + +4. If you want, I can generate a matching cleanup script for `dungeon_mob_ability_assignments` by key lookup.