diff --git a/ChangeLog.md b/ChangeLog.md index 5a674db..7191ecb 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,6 @@ +# v1.11.1 +* Fix error at combat start if an avoiding combatant has sent a non-roll chat card after the initiative roll. + # v1.11.0 * If an avoiding combatant has its initiative set manually by the GM using the 'Set as *Combatant's* initiative' button on a check result card, update that card with visibility results when combat is started. * Fix a benign error that happened when setting/clearing hidden/undetected conditions via token HUD on a token that didn't have any pf2e-perception status flags on it. diff --git a/README.md b/README.md index aaa377b..de3d693 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ An *Unnoticed* setting controls whether or not to use `Unnoticed` rather than `U *PF2e Avoid Notice* also can remove the GM hidden states of combatants if enabled in the game settings, since forgetting to toggle combatant visibility happens to me far too often. +Initiative sometimes comes from a previous roll like a sneak check or the use of the avoid notice exploration activity in the Basic Action Macros. In these cases, if the GM has chosen to use the "Set as *Combatant's*initiative" button on the skill check card, there won't be an initiative card and the visibility results will be written to the check card instead. It finds it by looking for the latest message from that combatant with a check result that matches the combatant's initiative roll, so it possible that the visibility result could end up on the wrong card if the combatant has rolled some other kind of check that had the same check value after the designated initiative roll but prior to combat being started. + ## Condition Handling This module provides the GM a number of options in the game settings for automating the application of status results at combat start. Note that an avoider might end up with `undetected`, `hidden`, and `observed` on the same roll vs different observers, and target-relative conditions aren't handled by the base system (only *PF2e perception* can do this) * It can do nothing and let the GM handle everything. diff --git a/esmodules/combat.js b/esmodules/combat.js index ef3f570..5944958 100644 --- a/esmodules/combat.js +++ b/esmodules/combat.js @@ -171,7 +171,7 @@ Hooks.once('init', () => { // Find the last card with a check roll matching initiative for the avoider const messages = game.messages.contents.filter((m) => - m.speaker.token === avoider.tokenId && m.rolls[0].total === avoider.initiative + m.speaker.token === avoider.tokenId && m.rolls?.[0]?.total === avoider.initiative ); if (!messages.length) { log(`Couldn't find initiative card for ${avoider.token.name}`);