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).
This commit is contained in:
parent
1e891094fe
commit
f8d2a2bacc
4 changed files with 95 additions and 21 deletions
|
|
@ -218,19 +218,16 @@ public abstract partial class BaseAI
|
|||
return OrderType.Attack;
|
||||
}
|
||||
|
||||
// Stop: Follow/Guard -> idle here; Stay -> keep the post; anything transient -> the standing order.
|
||||
// Stop: Follow/Guard/Stay -> idle here; anything transient -> the standing order.
|
||||
private OrderType IssueStop(OrderType previous)
|
||||
{
|
||||
Mobile.ControlTarget = null;
|
||||
|
||||
switch (previous)
|
||||
{
|
||||
case OrderType.Stay:
|
||||
{
|
||||
return OrderType.Stay; // resumed: anchor untouched
|
||||
}
|
||||
case OrderType.Follow:
|
||||
case OrderType.Guard:
|
||||
case OrderType.Stay:
|
||||
{
|
||||
SetPersistentOrder(OrderType.None); // cancel the standing order; idle anchor = here
|
||||
return OrderType.None;
|
||||
|
|
|
|||
|
|
@ -2736,22 +2736,18 @@ namespace Server.Mobiles
|
|||
aggressor.Aggressors.Add(AggressorInfo.Create(this, aggressor, true));
|
||||
}
|
||||
|
||||
var ct = _controlOrder;
|
||||
var toldToStandDown = _controlled && _controlMaster != null && Commandable &&
|
||||
BaseAI.IsStandDownOrder(_controlOrder);
|
||||
|
||||
if (AIObject != null)
|
||||
if (StandsDownOnCommand && toldToStandDown)
|
||||
{
|
||||
if (!StandsDownOnCommand || !BaseAI.IsStandDownOrder(ct))
|
||||
{
|
||||
AIObject.OnAggressiveAction(aggressor);
|
||||
}
|
||||
else
|
||||
{
|
||||
AIObject.DebugSay("I'm being attacked but my master told me not to fight.");
|
||||
Warmode = false;
|
||||
return;
|
||||
}
|
||||
AIObject?.DebugSay("I'm being attacked but my master told me not to fight.");
|
||||
Warmode = false;
|
||||
return;
|
||||
}
|
||||
|
||||
AIObject?.OnAggressiveAction(aggressor);
|
||||
|
||||
StopFlee();
|
||||
|
||||
ForceReacquire();
|
||||
|
|
@ -2767,7 +2763,7 @@ namespace Server.Mobiles
|
|||
}
|
||||
|
||||
// Only reachable when the pet does not stand down: the orders above returned early.
|
||||
if (aggressor.ChangingCombatant && (_controlled || _summoned) && BaseAI.IsStandDownOrder(ct))
|
||||
if (aggressor.ChangingCombatant && toldToStandDown)
|
||||
{
|
||||
IssueOrder(OrderType.Attack, null, aggressor);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue