Combat engine: pay off the N-body debt, and hire Pete

N3 widened the combat *roster* from 1 to N but never widened the action model,
the scaling model, or the test net to match. Building the hireable companion
walked into all three. Only one of the four defects found was the companion's;
the rest have been live in prod for every human party since N3.

The party golden did not exist (§5)
  Solo combat is pinned exhaustively (7468 lines); the entire N-body layer had
  nothing. That is why a healer class that cannot heal shipped without a test
  going red. Adds party_characterization.golden (9 scenarios x 5 seeds, incl.
  weak and dying seats) and TestPartyCharacterization_OneSeatIsStillSolo, so the
  N-body path can never quietly stop being a superset of the balance corpus.
  Regenerate only on purpose: -update-party.

No action could target another seat (§1)
  Every heal in the engine was self-scoped. A party cleric could not put one hit
  point on a friend. Adds turnActionEffect.AllyHeal/AllySeat, `!cast <spell>
  @user` and `--target @user` -- the latter has been advertised in !help and
  silently swallowed by parseCombatCast since SP2 ("reserved for SP3"). The auto
  picker uses it too (simPickAllyHeal), so away-players and engine-driven healers
  behave like competent ones. It will not raise the dead.

Corpses kept buffing the boss (§2b)
  enemyActionsThisRound counted len(st.actors), dead included -- so a party that
  lost a member kept paying for them, and the survivor faced a boss still swinging
  at two-player cadence, alone. A death spiral with the arrow pointing the wrong
  way. Now counts livingActors(). Party golden moved deliberately for this.

An engine-driven seat was a bool any command could clear (§3)
  autoDriveCombat drives a party by dispatching each seat's turn AS that seat, so
  a companion's own auto-played move arrived at beginCombatTurn looking like a
  player returning to the keyboard and cleared the latch that was moving him. He
  then stood in the fight doing nothing while the boss he had inflated killed
  everyone. ActorStatuses.EngineDriven is now a persisted seat property that no
  command clears, and the driver calls driveEngineSeat instead of impersonating.

"The party" could be empty (§4)
  A solo expedition has no expedition_party rows, so asking the roster who was in
  the party answered "nobody" -- and every caller fell back to something plausible.
  That is how the companion got hired at level 1 for exactly the player the feature
  exists for. expeditionParty()/partyHumans() always include the owner.

The companion himself (!expedition hire [class] / !expedition dismiss)
  Day 1, leader only, costs coins, role-fills the gap, globally exclusive. He is an
  NPC seat and must never become a player: no player_meta, no dnd_character, no
  inventory, no DM room -- mint him a player_meta row and
  ensureDnDCharacterForCombat will auto-build the news bot a real character, and
  he starts appearing in the graveyard and filing death notices about himself.
  Mail and seats are different sets: he fights, he does not get written to.

Measured on millenia, n=750/arm. Before these fixes he was -28pp -- worse than no
companion at all. After: solo 48.5% -> 63.9% clear (+15.3pp), with +28.0pp for
trailing players and +2.0pp for leaders. Help, never a carry.

The solo golden is byte-identical throughout: solo combat provably did not move,
and the balance corpus is intact.

Known gap: the companion cannot cast (castActionForSeat loads a sheet from the DB
and he has none by design), so a hired Cleric is still just a bad fighter.

Claude-Session: https://claude.ai/code/session_01J5SQZWoLmL3M3mw2XmHHdy
This commit is contained in:
prosolis
2026-07-11 12:39:01 -07:00
parent f4a4c0d30b
commit d538f91cf7
23 changed files with 3924 additions and 38 deletions

View File

@@ -51,6 +51,11 @@ func (p *AdventurePlugin) runZoneCombatRoster(
advChar *AdventureCharacter
equip map[EquipmentSlot]*AdvEquipment
mods CombatModifiers
// companion marks the hired NPC seat: it fights, but it owns none of the
// character-scoped effects the close-out loop applies, and its dndChar /
// advChar / equip are nil precisely so a missed guard panics loudly here
// rather than silently writing rows for a bot.
companion bool
}
var (
@@ -69,6 +74,22 @@ func (p *AdventurePlugin) runZoneCombatRoster(
return PartyCombatResult{}, nil, err
}
// The hired companion fights here too — the auto-resolve path is where
// most expedition rooms are actually decided. He is synthesized rather
// than loaded, and his seatBuild is flagged so the close-out loop below
// gives him no XP, no loot, and no post-combat persistence.
if isCompanionSeat(uid) {
class, level := companionLoadout(companionExpeditionFor(roster[0]))
player, e, _ := p.companionCombatant(class, level, monster, tier, dmMood)
if leader {
enemy = e
}
players = append(players, player)
builds = append(builds, seatBuild{uid: uid, mods: player.Mods, companion: true})
seated = append(seated, uid)
continue
}
advChar, err := loadAdvCharacter(uid)
if err != nil || advChar == nil {
if leader {
@@ -137,6 +158,14 @@ func (p *AdventurePlugin) runZoneCombatRoster(
for i, b := range builds {
seatRes := res.Seats[i]
// The companion swings and then goes back to filing copy: no inventory to
// deduct from, no sheet to persist to, no XP to earn. Every call below
// would either write rows for a bot or log an error about the rows it
// hasn't got.
if b.companion {
continue
}
// Remove the actual heal items consumed during combat (one inventory item
// per heal_item event this seat fired). Cheapest-tier first.
consumeFiredHealingItems(b.uid, countHealEventsFired(seatRes))
@@ -193,6 +222,12 @@ func (p *AdventurePlugin) closeOutZoneWin(
) (leaderDrop string, downed []id.UserID) {
party := len(seated) > 1
for i, uid := range seated {
// The companion takes no cut and cannot die. He is not in the downed list
// either: that list is what the room narration mourns, and the party did
// not lose a friend when the hireling took a nap.
if isCompanionSeat(uid) {
continue
}
if res.Seats[i].PlayerEndHP > 0 {
drop := p.dropZoneLoot(uid, zone.ID, monster, isBoss, elite)
if i == 0 {
@@ -217,6 +252,12 @@ func (p *AdventurePlugin) closeOutZoneWin(
// fight.
func closeOutZoneLoss(res PartyCombatResult, seated []id.UserID, zone ZoneDefinition, deathSource string) (killed []id.UserID) {
for i, uid := range seated {
// The companion is not killed and is not counted among the dead — he is
// not in the graveyard, and a wipe that lists him would have the news bot
// reporting its own funeral.
if isCompanionSeat(uid) {
continue
}
if res.Seats[i].PlayerEndHP <= 0 {
markAdventureDead(uid, deathSource, zone.Display)
killed = append(killed, uid)