Manage ranged weapons

This commit is contained in:
2025-01-30 20:55:22 +01:00
parent d3302386ca
commit e3727a8374
30 changed files with 129 additions and 74 deletions

View File

@ -602,7 +602,7 @@ export default class LethalFantasyRoll extends Roll {
buttons: [
{
action: "roll",
label: label,
label: "Roll Progression Dice or Continue Loading",
callback: (event, button, dialog) => {
const output = Array.from(button.form.elements).reduce((obj, input) => {
if (input.name) obj[input.name] = input.value
@ -632,10 +632,39 @@ export default class LethalFantasyRoll extends Roll {
// Get the weapons from the actor items
let actor = game.actors.get(options.actorId)
let weapon = actor.items.find(i => i.type === "weapon" && i.id === rollContext.progressionDiceId)
let isMonster = actor.type === "monster"
// Get the dice and roll it
let rangedMode
let searchId = rollContext.progressionDiceId
if ( searchId.match("simpleAim")) {
searchId = searchId.replace("simpleAim", "")
rangedMode = "simpleAim"
}
if ( searchId.match("carefulAim")) {
searchId = searchId.replace("carefulAim", "")
rangedMode = "carefulAim"
}
if ( searchId.match("focusedAim")) {
searchId = searchId.replace("focusedAim", "")
rangedMode = "focusedAim"
}
let weapon = actor.items.find(i => i.type === "weapon" && i.id === searchId)
let formula = weapon.system.combatProgressionDice
let rangedLoad
if (rangedMode) {
let toSplit = weapon.system.speed[rangedMode]
let split = toSplit.split("+")
rangedLoad = Number(split[0]) || 0
formula = split[1]
console.log("Ranged Mode", rangedMode, rangedLoad, formula, options.rollProgressionCount)
}
if (rangedLoad && options.rollProgressionCount <= rangedLoad ) {
let message = `Ranged weapon ${weapon.name} is loading, loading count : ${options.rollProgressionCount}/${rangedLoad}`
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: actor }) })
return
}
let isMonster = actor.type === "monster"
// Get the dice and roll it if
let roll = new Roll(formula)
await roll.evaluate()