ModernUO/Projects/UOContent/Mobiles/Special
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
..
Barracoon.cs fix: Changes Map.Sector.Mobiles to link list & Fixes various related crash bugs (#1553) 2023-10-29 22:42:46 -07:00
BaseChampion.cs feat: Adds Mobile.Murderer virtual property, consolidates kill-threshold checks (#2355) 2026-03-06 08:36:41 -08:00
BaseShieldGuard.cs fix: Fixes memory leak in virtual mounts and codegens specials (#1476) 2023-08-25 22:42:23 -07:00
CapturedHordeMinion.cs fix: Fixes memory leak in virtual mounts and codegens specials (#1476) 2023-08-25 22:42:23 -07:00
ChaosGuard.cs feat: Adds Stamina System to overhaul overweight. (#1465) 2023-09-16 17:52:54 -07:00
DarkGuardian.cs fix: Fixes memory leak in virtual mounts and codegens specials (#1476) 2023-08-25 22:42:23 -07:00
Harrower.cs perf: keep damage entries in an inline intrusive list (#2605) 2026-09-01 23:25:14 -07:00
HarrowerTentacles.cs fix: Fixes tentacles not getting removed from harrower's list (#2239) 2025-07-24 14:18:16 -07:00
LordOaks.cs fix: monster ability queries no longer have side effects (#2716) 2026-10-18 17:41:27 -07:00
Mephitis.cs fix: Fixes memory leak in virtual mounts and codegens specials (#1476) 2023-08-25 22:42:23 -07:00
Neira.cs fix: monster ability queries no longer have side effects (#2716) 2026-10-18 17:41:27 -07:00
OrderGuard.cs fix: Fixes memory leak in virtual mounts and codegens specials (#1476) 2023-08-25 22:42:23 -07:00
Paragon.cs feat: Adds independent think/move clocks for creature AI to fix speed (#2591) 2026-08-23 10:19:59 -07:00
Rikktor.cs fix: Changes Map.Sector.Mobiles to link list & Fixes various related crash bugs (#1553) 2023-10-29 22:42:46 -07:00
Semidar.cs fix: Fixes memory leak in virtual mounts and codegens specials (#1476) 2023-08-25 22:42:23 -07:00
Serado.cs fix: Changes Map.Sector.Mobiles to link list & Fixes various related crash bugs (#1553) 2023-10-29 22:42:46 -07:00
ServantOfSemidar.cs fix: Fixes memory leak in virtual mounts and codegens specials (#1476) 2023-08-25 22:42:23 -07:00
Silvani.cs fix: Fixes memory leak in virtual mounts and codegens specials (#1476) 2023-08-25 22:42:23 -07:00