ModernUO/Projects/UOContent.Tests/Tests/Mobiles/AI
Kamron Batman 00688a04cf
fix(ai): guard zero-int detection cooldown and duplicate pet friends (#2667)
Supersedes #2658 (rebased onto main; edits by maintainers were not enabled on the original branch). Credit to @MithrilHammer for both fixes and the regression tests; their three commits are kept as authored.

Addresses two items from #2627:

- The detect-hidden cooldown clamps its divisor to at least one. A creature whose effective intelligence reaches zero now uses the existing capped cooldown instead of throwing.
- Pet friends are unique. `AddPetFriend` ignores an existing friend, so one removal revokes the membership.

On top of that, `AddPetFriend` and `RemovePetFriend` now go through the generated `AddToFriends` / `RemoveFromFriends`, which mark the creature dirty. `Friends` goes back to null when the last friend is removed, and removing a non-friend no longer touches the list.

Duplicates already stored in saves are not migrated.

## Tests

`DetectHiddenTimerTests` (7 cases) drives the real AI timer and checks cooldown bounds and retry timing. `PetFriendMembershipTests` (3 cases) covers duplicate adds, removal, and re-adding without disturbing other friends. `UOContent.Tests`: 1158 passed, 2 skipped, 0 failed on Windows.
2026-09-23 10:42:38 -07:00
..
AcquisitionTests.cs feat: event-driven target acquisition with a reaction-time gradient (#2601) 2026-09-01 20:42:15 -07:00
AIDeactivationTests.cs fix: handle null maps when deactivating creature AI (#2629) 2026-09-11 17:26:47 -07:00
ApproachOutcomeTests.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
ApproachTargetTests.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
DebugMessageTimingTests.cs fix(ai): make debug-message cooldown comparisons wraparound-safe (#2659) 2026-09-19 09:59:00 -07:00
DetectHiddenTimerTests.cs fix(ai): guard zero-int detection cooldown and duplicate pet friends (#2667) 2026-09-23 10:42:38 -07:00
FamiliarAITests.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
ForcedAITests.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
GuardFollowTests.cs fix: pets freeze, forget their orders, obey the wrong players, and fight when told not to (#2614) 2026-09-10 19:28:13 -07:00
GuardFriendlyFireTests.cs fix(ai): guarding pets never target their owner or the owner's pets (#2665) 2026-09-23 10:13:34 -07:00
GuardOrderTests.cs fix: pet obedience pacing, stale AI wake rescheduling, and Guard order persistence through combat (#2594) 2026-08-30 16:39:29 -07:00
HerdingTests.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
MoveSpeedTests.cs refactor: Changes BaseCreature to the SerializationGenerator (delta save requirement) (#2611) 2026-09-06 14:11:51 -07:00
PetFriendMembershipTests.cs fix(ai): guard zero-int detection cooldown and duplicate pet friends (#2667) 2026-09-23 10:42:38 -07:00
PetOrderTests.cs fix(ai): wild creatures no longer stand down when attacked (#2645) 2026-09-14 23:18:11 -07:00
PetPacingTests.cs fix: pets freeze, forget their orders, obey the wrong players, and fight when told not to (#2614) 2026-09-10 19:28:13 -07:00
PetRetaliationTests.cs fix(ai): wild creatures no longer stand down when attacked (#2645) 2026-09-14 23:18:11 -07:00
PetTestStub.cs fix: pets freeze, forget their orders, obey the wrong players, and fight when told not to (#2614) 2026-09-10 19:28:13 -07:00
RunFlagTests.cs feat: derive the Running bit from the step pace and fix step-pacing bursts (#2599) 2026-08-30 16:48:52 -07:00
SummonAcquireRulesTests.cs fix(ai): restore pre-AOS berserk energy vortexes and blade spirits (#2666) 2026-09-23 10:29:20 -07:00