neilbenson / foundryvtt-whitehack-3e

9 stars 5 forks source link

Enhancement: Roll Monster HP from HD #8

Open tuirgin opened 2 years ago

tuirgin commented 2 years ago

It'd be nice to be able to roll monster HP from the sheet and have it auto-populate the current/max hp fields replacing any existing values.

fred-o commented 1 year ago

I made a script macro for this. It rolls HP for all select monster tokens that don't already have it:

for await (const token of canvas.tokens.controlled) {
  const a = token.actor
  if (a.type === 'Monster' && !a.system.hitPoints.max) {
    const hd = a.system.combat.hitDice
    let r = new Roll(`${hd.base}d6 + @modifier`, hd)
    await r.evaluate()
    a.update({
      system: {
        hitPoints: {
          max: r.total,
          value: r.total
        }
      }
    })
    console.log(`Rolled HP ${r.total} for ${a.name}`)
  }
}

Just create a new script macro and paste this into the Command field.

neilbenson commented 1 year ago

Hi fred-o, I'm no longer maintaining this repo due to time constraints. Feel free to create a fork and release it to Foundry.