ModernUO/Projects/UOContent/Mobiles/Abilities
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
..
Fire Breath feat: Adds ability groups, DOT abilities, and combat abilities (#1264) 2022-11-23 12:33:27 -08:00
Summon Undead refactor: master views over BaseCreature's one master reference (#2674) 2026-09-24 22:45:24 -07:00
AreaEffectMonsterAbility.cs fix: Adds guard for monster ability recursion (#2363) 2026-03-12 19:26:49 -07:00
BloodBathAttack.cs fix: Fixes Dot abilities. Adds blood bath attack (#1277) 2022-11-23 19:40:48 -08:00
ColossalBlow.cs fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
DeathExplosion.cs fix: Adds guard for monster ability recursion (#2363) 2026-03-12 19:26:49 -07:00
DestroyEquipment.cs fix: Streamlines insurance. Insurance only executes when enabled. (#2550) 2026-07-26 09:47:49 -07:00
DrainLifeAreaAttack.cs feat: Adds drain life ability (#1181) 2022-10-02 11:36:15 -07:00
DrainLifeAttack.cs fix: Fixes Dot abilities. Adds blood bath attack (#1277) 2022-11-23 19:40:48 -08:00
EnergyBoltCounter.cs fix: Fixes single target abilities. Adds drain life ability. (#1276) 2022-11-23 19:06:27 -08:00
FanningFire.cs feat: Adds SpecialAttack monster ability trigger. Fixes fanning fire. (#2186) 2025-05-15 22:14:52 -07:00
FanThrowCounter.cs fix: Fixes single target abilities. Adds drain life ability. (#1276) 2022-11-23 19:06:27 -08:00
GraspingClaw.cs fix: Fixes Dot abilities. Adds blood bath attack (#1277) 2022-11-23 19:40:48 -08:00
MagicalBarrier.cs fix: Fixes magical barrier NPE and an edge case (#2162) 2025-04-22 17:52:09 -07:00
MonsterAbilities.cs feat(throwing): add Ter Mur reptiles (Raptor + slith family) and their SA claws (#2515) 2026-07-02 23:58:29 -07:00
MonsterAbility.cs fix: monster ability queries no longer have side effects (#2716) 2026-10-18 17:41:27 -07:00
MonsterAbilityGroup.cs fix: Cleans up potential memory leak in monster abilities. (#2185) 2025-05-15 19:42:54 -07:00
MonsterAbilitySingleTarget.cs fix: Fixes single target abilities. Adds drain life ability. (#1276) 2022-11-23 19:06:27 -08:00
MonsterAbilitySingleTargetDoT.cs fix: Timer Remaining Count off by 1 fix (#2046) 2025-01-01 20:19:38 -08:00
MonsterAbilityTrigger.cs feat: Adds magical barrier and ebolt counter ability (#1182) 2022-10-02 20:48:53 -07:00
MonsterAbilityType.cs feat(throwing): add Ter Mur reptiles (Raptor + slith family) and their SA claws (#2515) 2026-07-02 23:58:29 -07:00
PoisonGasAreaAttack.cs feat: Adds magical barrier and ebolt counter ability (#1182) 2022-10-02 20:48:53 -07:00
PoisonGasCounter.cs fix: Fixes single target abilities. Adds drain life ability. (#1276) 2022-11-23 19:06:27 -08:00
ReflectPhysicalDamage.cs fix: Cleans up potential memory leak in monster abilities. (#2185) 2025-05-15 19:42:54 -07:00
RuneCorruption.cs fix: Fixes Dot abilities. Adds blood bath attack (#1277) 2022-11-23 19:40:48 -08:00
StunAttack.cs fix: Fixes NPE with stun attack (#1751) 2024-04-30 19:20:06 -07:00
SummonPixiesCounter.cs fix: Adds summon pixies. Fixes other abilities (#1274) 2022-11-23 17:39:23 -08:00
TailSwipe.cs feat(throwing): add Ter Mur reptiles (Raptor + slith family) and their SA claws (#2515) 2026-07-02 23:58:29 -07:00
ThrowHatchetCounter.cs fix: Fixes single target abilities. Adds drain life ability. (#1276) 2022-11-23 19:06:27 -08:00