fix(mod-api): harden deferred trainer preparation

This commit is contained in:
MaxTomahawk
2026-08-14 17:57:59 +02:00
parent a77210799f
commit 407f649e9d
8 changed files with 176 additions and 9 deletions
+7 -2
View File
@@ -436,7 +436,7 @@ mod.hooks:wrap("trainer.before_battle", function(next, game, context, continue)
continue({ playerPartyIndices = indices })
end,
onCancel = function()
continue()
continue({ cancel = true })
end,
})
return true
@@ -444,7 +444,12 @@ end)
```
Return `true` only when retaining `continue` for a later callback. Calling
`continue()` uses the full save party; passing
`continue({ cancel = true })` ends the encounter without constructing a battle;
the normal encounter completion callback returns control to the overworld and
no trainer-defeated state is written. A cancelled sight encounter is suppressed
at the current player cell so it cannot immediately reopen; moving one cell or
talking to the trainer permits a new challenge. Calling `continue()` uses the
full save party; passing
`{ playerPartyIndices = { 2, 4, 5 } }` uses those ordered, one-based party
members for initial send, switching and forced replacement, exhaustion,
experience traversal, and battle party displays. The continuation is one-shot.