fix: champion minions belong to their spawn (#2717)

Stacked on #2716. Retarget to `main` after it merges.

## Problem
Mobiles a champion summons mid-fight aren't tracked by anything:

| Summoner | Minions |
|---|---|
| LordOaks | Silvani queen |
| `SummonPixiesCounter` (LordOaks, Silvani, Twaulo) | 3-6 pixies per trigger |
| Barracoon | 3-6 ratmen per trigger |

`ChampionSpawn.DeleteCreatures` (called on expiry and when the spawn is deleted) clears only `Creatures` and the champion. These minions survive every reset and stay in the save. I surveyed every content creature that creates other mobiles; the others already clean up after themselves: Meraktus deletes its followers, Harrower kills its tentacles, PlagueSpawn and the Enraged animals delete themselves when their owner is gone, and BogThing eats its boglings.

## Changes
- **`BaseCreature.SpawnMinion(minion, target, location)`:** sets the team, places the minion and sets its combatant. Ownership: if the summoner is a champion spawn's champion, one of its creatures, or one of its minions (found through the spawn region), the minion joins that spawn. It refuses, and deletes the minion, if the summoner isn't on a real map. `SummonPixiesCounter` read `source.Map` even though `MonsterAbility.Trigger` notes it can fire after the creature has left the world.
- **`ChampionSpawn.Minions`:** a new serialized list (v12, `MigrateFrom(V11Content)`) kept apart from `Creatures`:
  - killing a minion never counts toward a level, so a leftover summoner can't feed a restarted spawn;
  - `DeleteCreatures` deletes minions along with the creatures, which matches when the spawn is deactivated (`ExpireCreatures`, 10 minutes after `Stop`) or deleted.
- **Callers:** LordOaks, `SummonPixiesCounter` and Barracoon spawn through `SpawnMinion`. A summoner that isn't part of a spawn (a GM `[add]`) still makes standalone minions, as today.

## Testing
- `ChampionMinionTests`:
  - the champion's queen is listed in `Minions` and deleted by `DeleteCreatures`;
  - a minion's minion also belongs to the spawn;
  - a Lord Oaks in the region that isn't the spawn's champion keeps a standalone queen.
- UOContent.Tests: 1237 passed, 2 skipped. The Application build is clean.
This commit is contained in:
Kamron Batman 2026-10-18 17:48:31 -07:00 • committed by GitHub
parent 4e57ec2373
commit 69ff5f3940
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 402 additions and 12 deletions

View file

@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server;
using Server.Engines.CannedEvil;
using Server.Mobiles;
using Xunit;
namespace UOContent.Tests.Engines.CannedEvil;
// Minions summoned by a champion belong to its spawn, so clearing the spawn removes them instead of
// leaving them behind for good.
[Collection("Sequential UOContent Tests")]
public class ChampionMinionTests : IDisposable
{
private static readonly Point3D _location = new(1500, 1500, 0);
private readonly List<IEntity> _created = [];
public void Dispose()
{
foreach (var m in World.Mobiles.Values.OfType<Silvani>().ToList())
{
m.Delete();
}
for (var i = 0; i < _created.Count; i++)
{
_created[i].Delete();
}
}
private ChampionSpawn NewSpawn()
{
var spawn = new ChampionSpawn();
_created.Add(spawn);
spawn.MoveToWorld(_location, Map.Felucca);
spawn.SpawnArea = new Rectangle2D(new Point2D(_location.X - 24, _location.Y - 24), new Point2D(_location.X + 24, _location.Y + 24));
return spawn;
}
private LordOaks NewOaks()
{
var oaks = new LordOaks();
_created.Add(oaks);
oaks.MoveToWorld(_location, Map.Felucca);
return oaks;
}
private Mobile NewAttacker()
{
var attacker = new Mongbat();
_created.Add(attacker);
return attacker;
}
[Fact]
public void AChampionsMinion_IsDeletedWithTheSpawnsCreatures()
{
var spawn = NewSpawn();
var oaks = NewOaks();
spawn.Champion = oaks;
oaks.AggressiveAction(NewAttacker(), false);
var queen = World.Mobiles.Values.OfType<Silvani>().Single();
Assert.Contains(queen, spawn.Minions);
spawn.DeleteCreatures();
Assert.True(queen.Deleted);
Assert.Empty(spawn.Minions);
}
[Fact]
public void AMinionOfAMinion_AlsoBelongsToTheSpawn()
{
var spawn = NewSpawn();
var oaks = NewOaks();
spawn.Champion = oaks;
oaks.AggressiveAction(NewAttacker(), false);
var queen = World.Mobiles.Values.OfType<Silvani>().Single();
var pixie = new Pixie();
_created.Add(pixie);
Assert.True(queen.SpawnMinion(pixie));
Assert.Contains(pixie, spawn.Minions);
}
[Fact]
public void ACreatureOutsideAnySpawn_SummonsAStandaloneMinion()
{
var spawn = NewSpawn();
var oaks = NewOaks(); // in the spawn's region, but not its champion
oaks.AggressiveAction(NewAttacker(), false);
var queen = World.Mobiles.Values.OfType<Silvani>().Single();
spawn.DeleteCreatures();
Assert.False(queen.Deleted);
Assert.Null(ChampionSpawn.FindSpawnOf(oaks));
}
}