Skip to content

Commit

Permalink
[#4395] Populate roll data for scrolls with spell level
Browse files Browse the repository at this point in the history
Created spell scrolls are missing `@item.level` in their roll
data. This adds that value to roll data so long as the `spellLevel`
flag is present. This also sets the `flags.dnd5e.scaling` flag
when creating the scroll to ensure other scaling occurs properly.

Closes #4395
  • Loading branch information
arbron committed Sep 23, 2024
1 parent 73dd9f4 commit 035a56a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions module/data/item/consumable.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,16 @@ export default class ConsumableData extends ItemDataModel.mixin(
.filter(p => p !== "material").forEach(p => valid.add(p));
return valid;
}

/* -------------------------------------------- */
/* Helpers */
/* -------------------------------------------- */

/** @inheritDoc */
getRollData(...options) {
const data = super.getRollData(...options);
const spellLevel = this.parent.getFlag("dnd5e", "spellLevel");
if ( spellLevel ) data.item.level = spellLevel.value ?? spellLevel.base;
return data;
}
}
1 change: 1 addition & 0 deletions module/documents/item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,7 @@ export default class Item5e extends SystemDocumentMixin(Item) {
const flags = itemData.flags ?? {};
if ( Number.isNumeric(config.level) ) {
flags.dnd5e ??= {};
flags.dnd5e.scaling = Math.max(0, config.level - spell.system.level);
flags.dnd5e.spellLevel = {
value: config.level,
base: spell.system.level
Expand Down

0 comments on commit 035a56a

Please sign in to comment.