ATtempt to fix init rolls

This commit is contained in:
2026-04-07 20:43:15 +02:00
parent 3ad5681539
commit 1bf88bac06
33 changed files with 134 additions and 124 deletions

View File

@@ -620,6 +620,7 @@ export default class LethalFantasyRoll extends Roll {
rollBase.options.badResult = badResult
rollBase.options.rollData = foundry.utils.duplicate(rollData)
rollBase.options.defenderId = options.defenderId
rollBase.options.defenderTokenId = options.defenderTokenId
/**
* A hook event that fires after the roll has been made.
@@ -698,7 +699,7 @@ export default class LethalFantasyRoll extends Roll {
if (options.combatId && options.combatantId) {
let combat = game.combats.get(options.combatId)
await combat.updateEmbeddedDocuments("Combatant", [{ _id: options.combatantId, initiative: initRoll.total, 'system.progressionCount': 0 }])
await combat.updateEmbeddedDocuments("Combatant", [{ _id: options.combatantId, initiative: initRoll.total, 'system.progressionCount': 0, [`flags.${SYSTEM.id}.firstActionTaken`]: false }])
}
}
@@ -835,7 +836,11 @@ export default class LethalFantasyRoll extends Roll {
let selectedItem = combatant.actor.items.find(i => i.id === selectedChoice)
// Setup flag for combat action usage
let actionItem = foundry.utils.duplicate(selectedItem)
actionItem.progressionCount = 1
// First action of this combat: use the class-based starting threshold;
// all subsequent actions reset to 1 (normal progression).
const firstActionTaken = combatant.getFlag(SYSTEM.id, "firstActionTaken")
actionItem.progressionCount = firstActionTaken ? 1 : (combatant.actor.system.combat?.combatProgressionStart ?? 1)
if (!firstActionTaken) await combatant.setFlag(SYSTEM.id, "firstActionTaken", true)
actionItem.rangedMode = rangedMode
actionItem.castingTime = 1
actionItem.spellStatus = "castingTime"