ModernUO/Projects/UOContent/Mobiles/AI
Kamron Batman f8d2a2bacc
fix(ai): wild creatures no longer stand down when attacked (#2645)
## Symptom

Since #2614, on any shard with `taming.petsStandDownOnCommand` (default `Core.ML`), every wild creature hits `"I'm being attacked but my master told me not to fight."` when struck. Brigands still chase (acquisition is a separate path in the think loop) but the retaliation path is dead: no `OnAggressiveAction`, no `StopFlee`, no `ForceReacquire`, `Combatant` never set, and `Warmode` forced off on every hit.

## Root cause

#2614 correctly added `OrderType.None` to `BaseAI.IsStandDownOrder` — a stopped pet rests on `None` and Publish 51 says it must not fight back. But the gate in `BaseCreature.AggressiveAction` never asked whether anybody could have given the order. The old predicate (`ct != Follow && ct != Stop && ct != Stay`) had only excluded wild creatures by accident: `None` was not in its set, so nothing ever needed to spell the check out. A wild creature's `_controlOrder` is always `None`.

## Fix

Both halves of `AggressiveAction` now gate on `Controlled && ControlMaster != null && Commandable` — the same predicate every order entry point already uses (`OnSpeech`, context menu, `IsValidTarget`). Only a creature somebody can command has been told to stand down. That excludes, and lets fight back:

| Creature | Why it was standing down |
|---|---|
| Wild creature | rests on `None` |
| Energy vortex, blade spirits, animated weapon, animate dead | `Summoned` with a `SummonMaster` but never `Controlled`; rests on `None` |
| Familiar, talisman summon, escortee, mirror image | `Controlled` with a master but `Commandable => false`; sits on a system-issued `Follow` |

The last row is a deliberate behaviour change from #2614 for ML+ shards: a familiar or escortee on `Follow` no longer stands down when attacked. The publish speaks of commanded pets; a creature that cannot take an order was never told anything, and pre-ML it always fought back.

Commandable summons (Summon Creature, elementals, daemons) are `Controlled` with `ControlMaster == SummonMaster`, so they stand down exactly as pets do.

## Also: stop after stay

Found while testing: `all come` then `all stop` left the pet on `Stay`, ticking *"I have been ordered to stay"*. `come` rests into `Stay` on arrival (deliberate ModernUO divergence, kept), and #2614 had `IssueStop` keep a previous `Stay`. RunUO and ServUO never consult the previous order — `DoOrderStop` is "wander around here" (or `None` pre-ML) — and Publish 51 says a stopped pet *"may wander"*. `Stay` now joins `Follow`/`Guard` in `IssueStop`: stop cancels the standing order and the pet idles anchored where it stands. `Stop_WhileStaying_RemainsStayingAtOriginalPost` is replaced by `Stop_WhileStaying_CancelsToIdleNone` plus the `come, stop` repro.

## Tests

`PetRetaliationTests` gains one case per row above: `WildCreature_`, `UncontrolledSummon_`, `UncommandableCreature_Retaliates_UnderStandDown`. Each fails on main and passes here; full `UOContent.Tests` green (1058 passed).
2026-09-14 23:18:11 -07:00
..
BaseAI fix(ai): wild creatures no longer stand down when attacked (#2645) 2026-09-14 23:18:11 -07:00
AIControlMobileTarget.cs feat: Overhauls AI (Speech/Movement) (#2232) 2025-07-18 22:39:57 -07:00
AnimalAI.cs feat: derive the Running bit from the step pace and fix step-pacing bursts (#2599) 2026-08-30 16:48:52 -07:00
ArcherAI.cs feat: event-driven target acquisition with a reaction-time gradient (#2601) 2026-09-01 20:42:15 -07:00
BerserkAI.cs feat: event-driven target acquisition with a reaction-time gradient (#2601) 2026-09-01 20:42:15 -07:00
FamiliarAI.cs fix(ai): FamiliarAI owns familiar movement and combat; herding reaches its tile; ForcedAI read once (#2644) 2026-09-14 23:14:30 -07:00
HealerAI.cs feat: derive the Running bit from the step pace and fix step-pacing bursts (#2599) 2026-08-30 16:48:52 -07:00
MageAI.cs feat: derive the Running bit from the step pace and fix step-pacing bursts (#2599) 2026-08-30 16:48:52 -07:00
MeleeAI.cs feat: event-driven target acquisition with a reaction-time gradient (#2601) 2026-09-01 20:42:15 -07:00
OppositionGroup.cs feat: Overhauls AI (Speech/Movement) (#2232) 2025-07-18 22:39:57 -07:00
PredatorAI.cs feat: derive the Running bit from the step pace and fix step-pacing bursts (#2599) 2026-08-30 16:48:52 -07:00
ThiefAI.cs feat: derive the Running bit from the step pace and fix step-pacing bursts (#2599) 2026-08-30 16:48:52 -07:00
VendorAI.cs feat: Overhauls AI (Speech/Movement) (#2232) 2025-07-18 22:39:57 -07:00