ModernUO/Projects/UOContent/Mobiles
Kamron Batman 4e57ec2373
fix: monster ability queries no longer have side effects (#2716)
## Problem
`GetMonsterAbilities()` answers three questions through one virtual: which abilities a creature has (`GetAbility`, `AOS.cs` reflect/barrier, bard fire-breath difficulty), which abilities are enabled right now, and where cooldown state must be cleaned up (`InvalidateNextAbilityTriggers` on death and delete). Every caller assumes it is a pure, stable list. About 70 creatures return a static array; only LordOaks computed it:

```
Mobile.Delete()
 → BaseCreature.OnDelete() → CreatureDeletedEvent
 → MonsterAbility.InvalidateNextAbilityTriggers()
 → LordOaks.GetMonsterAbilities() → CheckQueen() → new Silvani().MoveToWorld(...)
```

- Deleting a Lord Oaks nobody had fought (champion reset, `DeleteCreatures`, GM delete) spawned an orphaned Silvani where he stood.
- The spell damage scalar (`AlterDamageScalarFrom`) spawned her too.
- With the queen dead his list was empty, so cleanup skipped his cooldown entries. The static `Dictionary<BaseCreature, long>` on the ability singleton kept a reference to the deleted creature. `MonsterAbilityGroup` children's entries were never cleaned either.
- Neira threw unholy bones from `AlterDamageScalarFrom`, so any caller asking for a damage scalar (a preview gump, for example) could fire the effect.

## Changes
- **Per-creature cooldowns:** a lazy `Dictionary<MonsterAbility, long>` on `BaseCreature` (`IsAbilityOnCooldown`, `SetAbilityCooldown`, `ClearAbilityCooldowns`). The static dictionaries and the query-driven cleanup are gone, and death still resets cooldowns. Tick comparisons are wraparound-safe.
- **Pure contract:** `GetMonsterAbilities()` is documented as pure. The new `virtual bool CanUseAbility(MonsterAbility)` gates abilities that only work some of the time. Every `TriggerAbility*` loop and `GetAbility` check it.
- **LordOaks:** always lists his abilities; `CanUseAbility` and the 10% spell shield read "queen alive". The queen spawns when he is first aggressed or first given a combatant, never on the internal map. Aggression lands before the damage it causes, so the first spell is still shielded, as before.
- **Neira:** the unholy bone throw moves to `OnDamagedBySpell`.

A follow-up PR makes minions such as the queen, pixies and Barracoon's rats belong to their champion spawn, so a spawn reset cleans them up.

## Testing
- `LordOaksTests` covers three cases:
  - querying or deleting an unengaged Lord Oaks spawns nothing;
  - aggression spawns the queen exactly once, and the shield and abilities follow her life;
  - an Oaks on the internal map never spawns her.
- UOContent.Tests: 1234 passed, 2 skipped.
- A local constructor sweep (every Mobile built and deleted repeatedly) no longer reports LordOaks.
2026-10-18 17:41:27 -07:00
..
Abilities fix: monster ability queries no longer have side effects (#2716) 2026-10-18 17:41:27 -07:00
AI fix(ai): swap GetDelay bounds so min is the lower one (#2711) 2026-10-17 13:58:04 -07:00
Animals refactor: master views over BaseCreature's one master reference (#2674) 2026-09-24 22:45:24 -07:00
Familiars refactor: master views over BaseCreature's one master reference (#2674) 2026-09-24 22:45:24 -07:00
Guards feat: Adjusts fame and karma system with era gates for OSI accuracy (#2389) 2026-04-25 11:19:57 -07:00
Healers feat: Adds Mobile.Murderer virtual property, consolidates kill-threshold checks (#2355) 2026-03-06 08:36:41 -08:00
Hireables fix: male rangers no longer leak StuddedLegs (#2712) 2026-10-17 15:17:46 -07:00
Monsters fix: fishing by era: deep water, serpents, SOS, big fish and magic fish (#2718) 2026-10-18 17:34:10 -07:00
Special fix: monster ability queries no longer have side effects (#2716) 2026-10-18 17:41:27 -07:00
Townfolk fix: NPC outfits no longer stack two items on one layer (#2715) 2026-10-17 16:17:11 -07:00
Vendors fix: NPC outfits no longer stack two items on one layer (#2715) 2026-10-17 16:17:11 -07:00
BaseCreature.cs fix: monster ability queries no longer have side effects (#2716) 2026-10-18 17:41:27 -07:00
CreatureEvents.cs refactor: Changes BaseCreature to the SerializationGenerator (delta save requirement) (#2611) 2026-09-06 14:11:51 -07:00
NPCSpeeds.cs refactor: Changes BaseCreature to the SerializationGenerator (delta save requirement) (#2611) 2026-09-06 14:11:51 -07:00
PlayerMobile.cs fix: a deleted character's followers, and familiars that never unregistered (#2675) 2026-09-24 23:01:40 -07:00
VirtualMountItem.cs fix: Fixes mount stamina, adds Pub46+ Ethereal stamina (#1716) 2024-04-05 21:05:16 -07:00