Enable HealSelf and widen AI engagement to ability range

- Implement HealSelf execution in DungeonSimulation and mark it as implemented

- Add healing log output for ability verification

- Use mob engagement range derived from offensive ability ranges in Aggressive/Defensive/Tank behaviors

- Allow ranged/projectile abilities to trigger before point-blank melee distance
This commit is contained in:
dingo
2026-02-10 21:31:24 -05:00
parent d9189be156
commit b6e3227f29
2 changed files with 55 additions and 5 deletions
+35 -5
View File
@@ -112,8 +112,10 @@ public static class MobAI
mob.UpdateFacingDirection(target.X, target.Y);
mob.CombatTime += deltaTime;
// In attack range?
if (distance <= mob.Stats.AttackRange)
float engageRange = GetEngagementRange(mob);
// In ability/attack range?
if (distance <= engageRange)
{
mob.State = MobState.Attacking;
mob.CurrentAnimation = mob.GetDirectionalAnimation("attack");
@@ -152,8 +154,9 @@ public static class MobAI
mob.TargetId = target.CharacterId;
mob.UpdateFacingDirection(target.X, target.Y);
if (distance <= mob.Stats.AttackRange)
float engageRange = GetEngagementRange(mob);
if (distance <= engageRange)
{
mob.State = MobState.Attacking;
mob.CurrentAnimation = mob.GetDirectionalAnimation("attack");
@@ -308,7 +311,8 @@ public static class MobAI
mob.TargetId = target.CharacterId;
mob.UpdateFacingDirection(target.X, target.Y);
if (distance <= mob.Stats.AttackRange)
float engageRange = GetEngagementRange(mob);
if (distance <= engageRange)
{
mob.State = MobState.Attacking;
mob.CurrentAnimation = mob.GetDirectionalAnimation("attack");
@@ -909,6 +913,32 @@ public static class MobAI
float dy = y2 - y1;
return MathF.Sqrt(dx * dx + dy * dy);
}
private static float GetEngagementRange(MobInstance mob)
{
float range = Math.Max(0f, mob.Stats.AttackRange);
if (mob.Abilities.Count == 0) return range;
foreach (var ability in mob.Abilities)
{
var def = ability.Definition;
if (def == null || def.Range <= 0) continue;
// Keep self/allied support skills from inflating engage distance.
if (def.AbilityType is MobAbilityType.HealSelf or MobAbilityType.HealAlly or MobAbilityType.HealAoe
or MobAbilityType.BuffSelf or MobAbilityType.BuffAllies or MobAbilityType.Shield
or MobAbilityType.Enrage or MobAbilityType.PhaseChange
or MobAbilityType.SummonSingle or MobAbilityType.SummonBulk)
{
continue;
}
range = Math.Max(range, def.Range);
}
return range;
}
#endregion
}