ModernUO/Projects/UOContent/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
..
BaseAI fix(ai): guard zero-int detection cooldown and duplicate pet friends (#2667) 2026-09-23 10:42:38 -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): BaseAI.OnAggressiveAction owns the retaliation policy; familiars refuse cleanly (#2662) 2026-09-22 18:48:13 -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