HitDice hooks MR

I just added my first merge request 😄 https://gitlab.com/foundrynet/dnd5e/-/merge_requests/495
11 Replies
Wasp
Wasp•3y ago
TLDR; I want to implement a way to override hit die rolls for item and feats such as Periapt of Wound Closure and Durable
ccjmk
ccjmk•3y ago
i understand what you want to change is on parts ?
Wasp
Wasp•3y ago
Since Actor5e#rollHitDie uses the native damageRoll in the 5e system, there's no distinct way to easily change it
ccjmk
ccjmk•3y ago
would it make sense to return a new Parts ?
Wasp
Wasp•3y ago
Hooks.on("preRollHitDie", (actor, parts) => {

let periapt = actor.items.getName(game.i18n.format("REST-RECOVERY.FeatureNames.Periapt"));
periapt = periapt && periapt.data.data.attunement === 2;

let durable = actor.items.getName(game.i18n.format("REST-RECOVERY.FeatureNames.Durable"));
durable = durable && durable.data.type === "feat";

const conMod = actor.data.data.abilities.con.mod;

if (periapt && durable) {

parts = [`{1${denomination}+${conMod},${Math.max(conMod,2)}}kh*2`]

} else {

if (periapt) {
parts[0] = "(" + parts[0];
parts[1] += ")*2";
}

if (durable) {
parts[0] = "{" + parts[0]
parts[1] += `,${conMod*2}}kh`
}
}

});
Hooks.on("preRollHitDie", (actor, parts) => {

let periapt = actor.items.getName(game.i18n.format("REST-RECOVERY.FeatureNames.Periapt"));
periapt = periapt && periapt.data.data.attunement === 2;

let durable = actor.items.getName(game.i18n.format("REST-RECOVERY.FeatureNames.Durable"));
durable = durable && durable.data.type === "feat";

const conMod = actor.data.data.abilities.con.mod;

if (periapt && durable) {

parts = [`{1${denomination}+${conMod},${Math.max(conMod,2)}}kh*2`]

} else {

if (periapt) {
parts[0] = "(" + parts[0];
parts[1] += ")*2";
}

if (durable) {
parts[0] = "{" + parts[0]
parts[1] += `,${conMod*2}}kh`
}
}

});
That could work, yeah If multiple hooks are called, I don't think it will properly mutate though? ie, if module A and B both use preRollHitDie, and they both return the parts data, only one will win out?
ccjmk
ccjmk•3y ago
i just started a dota match so my attenetion is a little limted xD brb
Wasp
Wasp•3y ago
all good crush the opposition
ccjmk
ccjmk•3y ago
back! you closed it! xD also, I think you should not change the system version on your mr 😛
Wasp
Wasp•3y ago
I saw in a different MR that it was recommended to make em for 1.6.x
ccjmk
ccjmk•3y ago
hmm no I mean, not change the version on the system.json you just make the MR to the current next version, let them change the version & download link when ready for release
Calego
Calego•3y ago
I do want to put in a bunch of hooks in various places (see the more-hooks-5e module for my proof of concept), so I'm definitely interested in what your use case is and hwo to accomodate. I havne't fully caught up here but when I do I'll see about adding some hooks to the more-hooks module on this front