RynthAi: monster rule Priority 0 means never attacked
A monster whose applicable rule (its own row, else Default) has Priority <= 0 is dropped in ScanNearbyTargets before the LOS check, so it is never a target (acquire, re-lock, kill-shot alternate, next pick) and is not counted by any consumer of the scan list or the no-LOS count: HasTargets, HasNearbyMonsters, HasEngageableTarget, HasCloseThreat, IsUnderCloseAttack (nav hold, combat entry, stance, buff/rest, loot starvation, corpse gates, pets). An active target that becomes ignored is dropped at once. There is no exception for a Priority 0 monster that attacks the player; the HP failsafe still protects the player. Combat hook: ctx.monsters (RynthAi.Combat GetScanned) reads the same scan list, so an ignored monster is left out of it, even while it hits us, and ScriptAttackProblem rejects a script answer at a Priority 0 target before the fight-target match (a fight target whose rule changed to 0 is still the active target until Think drops it), so RynthAi casts its own choice. ScriptHealProblem rejects a script heal (a drain) at one the same way (CombatManager.IsIgnored). MonsterEditor: the P column shows "ign" for 0 and carries a tooltip on the header, cell and editor. README documents monster rules. Tests: IgnoreMonsterTests, a loot-starvation case in LootCorpseTests, and two CombatHookTests (ctx.monsters leaves out an ignored monster; a script answer at one is rejected, both even while it hits us; a script heal at a fight target turned to Priority 0 is rejected). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
10e2c2eb0a
commit
7cbc6fdca9
10 changed files with 387 additions and 6 deletions
|
|
@ -76,6 +76,9 @@ public partial class BuffManager
|
|||
if (LevelLacksComponents((int)spell)) return $"spell {spell} has no components (refused by the server; RynthAi uses a lower level)";
|
||||
if (target == player) return null;
|
||||
var cm = _combatManager;
|
||||
// Monster rule Priority 0 = never attacked: a drain at one is refused too, even when it is
|
||||
// still the fight target (its rule changed before Think dropped it) or still scanned.
|
||||
if (cm != null && cm.IsIgnored(unchecked((int)target))) return "the target is ignored (monster rule Priority 0)";
|
||||
bool listed = cm != null && unchecked((uint)cm.activeTargetId) == target;
|
||||
if (!listed && cm != null)
|
||||
foreach (var t in cm.ScannedTargets)
|
||||
|
|
|
|||
|
|
@ -87,6 +87,10 @@ public partial class CombatManager
|
|||
return $"spell {spell} was refused by the server, parked for {(parked - DateTime.Now).TotalSeconds:0} s more";
|
||||
uint player = _playerId != 0 ? _playerId : _host.GetPlayerId();
|
||||
if (castTarget == player) return null;
|
||||
// Monster rule Priority 0 = IGNORE: not a target for a script either, even one attacking us.
|
||||
// Checked before the fight-target match: a fight target whose rule changed to 0 is still
|
||||
// the active target until Think drops it.
|
||||
if (IsIgnored((int)castTarget)) return "the target is ignored (monster rule Priority 0)";
|
||||
bool listed = castTarget == unchecked((uint)activeTargetId);
|
||||
for (int i = 0; !listed && i < _scannedTargets.Count; i++)
|
||||
if (unchecked((uint)_scannedTargets[i].Id) == castTarget) listed = true;
|
||||
|
|
|
|||
|
|
@ -963,6 +963,13 @@ public partial class CombatManager : IDisposable
|
|||
// Dead but not yet reclassified as corpse — skip
|
||||
if (_worldFilter.GetHealthRatio(wo.Id) == 0f) continue;
|
||||
|
||||
// Monster rule Priority 0 = IGNORE, with no exception: even one attacking us is never
|
||||
// attacked (a monster worth fighting back needs a rule above 0). Left out of the
|
||||
// scan entirely, so it is neither a target nor a reason to hold nav,
|
||||
// combat, looting or buffs: every consumer reads this list or _nearbyNoLos, and an
|
||||
// ignored monster is not counted in either (it is dropped before the LOS check).
|
||||
if (PriorityOf(wo.Id) <= 0) continue;
|
||||
|
||||
bool losBlocked = false;
|
||||
if (_settings.EnableRaycasting && RaycastInitialized && _raycastSystem?.TargetingFSM != null)
|
||||
{
|
||||
|
|
@ -2791,6 +2798,12 @@ public partial class CombatManager : IDisposable
|
|||
|
||||
if (blacklisted)
|
||||
DropTarget("blacklisted");
|
||||
else if (target != null && PriorityOf(activeTargetId) <= 0)
|
||||
{
|
||||
// The rule says ignore (it changed, or the rule cache caught up).
|
||||
ForgetScanned(activeTargetId);
|
||||
DropTarget("ignored (monster rule Priority 0)");
|
||||
}
|
||||
else if (target != null && IsSpellProjectileName(target.Name))
|
||||
DropTarget("spell projectile (not a monster)");
|
||||
else if (target != null && (int)target.ObjectClass != (int)AcObjectClass.Monster)
|
||||
|
|
@ -3885,6 +3898,9 @@ public partial class CombatManager : IDisposable
|
|||
return progress != DateTime.MinValue && (now - progress).TotalMilliseconds <= UndamagedCommitmentMaxMs;
|
||||
}
|
||||
|
||||
/// <summary>True when the monster rule for <paramref name="id"/> says Priority 0 (never attacked).</summary>
|
||||
internal bool IsIgnored(int id) => PriorityOf(id) <= 0;
|
||||
|
||||
/// <summary>The Priority of the monster rule that applies to <paramref name="id"/> (its own
|
||||
/// row by name or match expression, else the DEFAULT row; 1 when neither exists). Cached per
|
||||
/// monster for <see cref="PriorityCacheMs"/>; the cache empties when the rule list changes.</summary>
|
||||
|
|
|
|||
Loading…
Reference in a new issue