ModernUO/Projects/UOContent/Items/Weapons
Kamron Batman a7bb8a8222
refactor(archery): centralize SE ammo auto-recovery off PlayerMobile (#2496)
## Summary

Streamlines the SE-era archery ammo auto-recovery (recovering spent arrows/bolts after a miss). The mechanic was previously spread across four unrelated trigger points and a weapon-scoped timer that was divorced from the recovery state living on `PlayerMobile`. It also contained dead code.

### Problems fixed
- **Dead `!Warmode` gate** — `OnMiss` only runs from `OnSwing`, which requires warmode to fire, so the `if (!pm.Warmode)` branch that started the recovery timer could never trigger.
- **Scattered, divorced state** — banked ammo lived on `PlayerMobile.RecoverableAmmo` while the timer lived on the weapon (`_recoveryTimerToken`), and recovery was kicked off from four different places (`OnWarmodeChanged`, `PlayerMobile.OnDamage` kill, `BaseCreature.OnDamage` kill, `OnBeforeDeath`).
- **Per-player footprint** — every `PlayerMobile` carried a `RecoverableAmmo` field even though ~99% never miss with a bow (and most are offline).

### New design — `AmmoRecovery` side table
- All state (banked ammo + one repeating timer) is keyed by player in a static dictionary, so only players who actually miss carry any state. Transient by design — this was never serialized.
- **One feed point:** `OnMiss` banks the spent ammo type and starts the player's timer.
- **One drain point:** the timer self-gates and gathers ammo into the backpack only once the archer has disengaged — **alive, out of warmode, and not running** — otherwise it retries next tick, so banked ammo is never lost while online.
- **"Not running" allows standing still _or_ walking.** The `Direction.Running` bit is stale after a player stops, so it's paired with movement recency (`LastMoveTime`); only an *actively* running archer is blocked.
- Removed the redundant scattered triggers, the dead `!Warmode` branch, `RecoverableAmmo`, `RecoverAmmo()`, and the now-empty `OnWarmodeChanged` override. `PlayerMobile.OnDelete` calls `AmmoRecovery.Forget`.

### Behavior notes
- On death, banked ammo is **no longer flushed to the corpse** — it stays banked and is recovered after resurrection once the archer settles (player keeps it rather than dropping it to looters).
- `OnHit` immediate recovery (the ~40% arrow-to-defender behavior) is **unchanged**.

## Test plan
- [x] `dotnet build Projects/UOContent/UOContent.csproj -c Release` — succeeds, 0 warnings, 0 errors.
- [ ] In-game (SE era): miss bow shots, then disengage (drop warmode + stop) and confirm the "You recover N arrows/bolts" message and backpack contents; confirm recovery does **not** fire while running and **does** while walking/standing.
2026-06-21 23:22:55 -07:00
..
Abilities feat: Refactor Poison system, implement Darkglow & Parasitic effects (#2385) 2026-03-21 21:27:22 -07:00
Artifacts fix: Adds back razor/assistuo negotiations (#1089) 2022-06-25 01:47:45 -07:00
Axes fix: Special moves and various UOR+ bonuses (#2384) 2026-03-22 10:55:01 -07:00
Knives fix: Optimizes items to use default weights. (Part 4) (#2243) 2025-07-24 23:29:29 -07:00
Maces fix: Special moves and various UOR+ bonuses (#2384) 2026-03-22 10:55:01 -07:00
ML Weapons fix: Optimizes items to use default weights. (Part 4) (#2243) 2025-07-24 23:29:29 -07:00
PoleArms fix: Optimizes items to use default weights. (Part 2) (#2241) 2025-07-24 15:41:44 -07:00
Ranged refactor(archery): centralize SE ammo auto-recovery off PlayerMobile (#2496) 2026-06-21 23:22:55 -07:00
SE Weapons fix: Optimizes items to use default weights. (Part 4) (#2243) 2025-07-24 23:29:29 -07:00
SpearsAndForks fix: Special moves and various UOR+ bonuses (#2384) 2026-03-22 10:55:01 -07:00
Staves fix: Optimizes items to use default weights. (Part 4) (#2243) 2025-07-24 23:29:29 -07:00
Swords fix: Optimizes items to use default weights. (Part 2) (#2241) 2025-07-24 15:41:44 -07:00
Throwing chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Wooden fix: Updates serialization to use v2.0 (#998) 2022-04-17 08:02:15 -07:00
BaseMeleeWeapon.cs feat: T2A defensive spells (#2378) 2026-03-22 11:18:34 -07:00
BaseWeapon.cs feat: Add zero-alloc interpolation handler to ValueStringBuilder, replace all StringBuilder usage (#2387) 2026-03-22 14:23:44 -07:00
Fists.cs fix: Special moves and various UOR+ bonuses (#2384) 2026-03-22 10:55:01 -07:00
HitLower.cs fix(core): Adds Hashed & Hierarchical Timer Wheel (#655) 2021-07-11 22:42:06 -07:00
SlayerEntry.cs feat: Adds Pre-UOTD single click support for weapons, armor, wands, and clothing (#2053) 2025-01-13 17:04:24 -08:00
SlayerGroup.cs fix: Fixes ignoring mobs, champions, party crash, slayer rarity, boat speedhack, etc (#1222) 2022-10-31 22:16:50 -07:00
SlayerName.cs Formats UO Content (#201) 2020-08-27 18:30:38 -07:00
WeaponEnums.cs fix: Adds throwing weapons (#1107) 2022-07-01 17:03:27 -07:00