- Macro: Request fear check specialization macro
- Macro: Fear Table to call the new fearTable api endpoint
- API: rulesVersion property
- API: fearTable(actor) calls the relevant premium core rules module's fear
table
- API: added requestFearRollFromTokens special helper
- Trait roll hooks for:
- Glow/Shroud
- Range modifiers
- added a summary chat message for the roll results to requested rolls.
- added a target number option to requested rolls.
73 lines
2.2 KiB
JavaScript
73 lines
2.2 KiB
JavaScript
const requestRollFromTokens = game.modules.get('swade-mb-helpers').api.requestRollFromTokens
|
|
|
|
async function main () {
|
|
let tokens = Array.from(game.user.targets)
|
|
if (tokens.length < 1) {
|
|
tokens = canvas.tokens.controlled
|
|
}
|
|
if (tokens.length < 1) {
|
|
ui.notifications.error('Please target or select some tokens')
|
|
return
|
|
}
|
|
|
|
const menuData = {
|
|
inputs: [
|
|
{ type: 'info', label: `Requesting roll from ${tokens.map(t => t.name).join(', ')}` },
|
|
{
|
|
type: 'select',
|
|
label: 'Trait to roll',
|
|
options: []
|
|
},
|
|
{ type: 'number', label: 'Roll Modifier', options: 0 },
|
|
{ type: 'text', label: 'Roll Modifier Description', options: 'Roll Modifier' },
|
|
{ type: 'number', label: 'Target Number', options: 4 }
|
|
],
|
|
buttons: [
|
|
{ label: 'Request roll', value: 'ok', default: true },
|
|
{ label: 'Cancel', value: 'cancel' }
|
|
]
|
|
}
|
|
const menuConfig = {
|
|
title: 'Request roll...'
|
|
}
|
|
for (const attribute of ['Agility', 'Smarts', 'Spirit', 'Strength', 'Vigor']) {
|
|
menuData.inputs[1].options.push(
|
|
{ html: `Attribute | ${attribute}`, value: `a|${attribute}` }
|
|
)
|
|
}
|
|
const skillSet = new Set()
|
|
for (const token of tokens) {
|
|
const skills = token.actor.items.filter(i => i.type === 'skill' &&
|
|
!['Untrained', 'Unskilled Attempt'].includes(i.name))
|
|
for (const skill of skills) {
|
|
skillSet.add(skill.name)
|
|
}
|
|
}
|
|
for (const skill of Array.from(skillSet).sort()) {
|
|
menuData.inputs[1].options.push(
|
|
{ html: `Skill | ${skill}`, value: `s|${skill}` })
|
|
}
|
|
menuData.inputs[1].options.push(
|
|
{ html: 'Skill | Untrained', value: 's|NOSKILL' })
|
|
const result = await warpgate.menu(menuData, menuConfig)
|
|
|
|
if (result.buttons !== 'ok') {
|
|
return
|
|
}
|
|
console.log(result)
|
|
const rollMod = result.inputs[2]
|
|
const rollModDesc = result.inputs[3]
|
|
const rollParts = result.inputs[1].split('|')
|
|
const rollType = (rollParts[0] === 'a' ? 'attribute' : 'skill')
|
|
const rollDesc = rollParts[1]
|
|
const targetNumber = result.inputs[4] || 4
|
|
const options = { targetNumber }
|
|
if (rollMod !== 0) {
|
|
options.mods = [{ label: rollModDesc, value: rollMod }]
|
|
}
|
|
|
|
requestRollFromTokens(tokens, rollType, rollDesc, options)
|
|
}
|
|
|
|
main()
|