Skip to content

Commit

Permalink
Merge pull request #75 from addtheletters/external-effect-fix
Browse files Browse the repository at this point in the history
Retrieve effects using actor.allApplicableEffects
  • Loading branch information
Larkinabout authored Mar 24, 2024
2 parents 883a87f + 1b9cdb7 commit d5ad474
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion scripts/action-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,10 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
const actionType = 'effect'

// Get effects
const effects = this.actor.effects
const effects = new Map()
for (const effect of this.actor.allApplicableEffects()) {
effects.set(effect.id, effect)
}

// Exit if no effects exist
if (effects.size === 0) return
Expand Down
11 changes: 10 additions & 1 deletion scripts/roll-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,16 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
*/
async #toggleEffect (event, actor, actionId) {
const effects = 'find' in actor.effects.entries ? actor.effects.entries : actor.effects
const effect = effects.find(effect => effect.id === actionId)
let effect = effects.find(effect => effect.id === actionId)

// if the effect isn't directly on the actor, search all applicable effects for it
if (!effect) {
for (const e of actor.allApplicableEffects()) {
if (e.id === actionId) {
effect = e
}
}
}

if (!effect) return

Expand Down

0 comments on commit d5ad474

Please sign in to comment.