Skip to content
This repository has been archived by the owner on Oct 30, 2022. It is now read-only.

ElfFriend-DnD/foundryvtt-more-hooks-5e

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

More Hooks D&D5e

Foundry Core Compatible Version Latest Release Download Count Forge Installs Foundry Hub Endorsements Foundry Hub Comments

ko-fi patreon

Adds more hooks to the 5e system. This is intended to be a library module for other modules (or Hook Macro users) to leverage.

Its goal is to eventually contribute these hooks directly to the core 5e system and disappear. The API is going to follow Semantic Versioning as it is likely to undergo sizable changes as the hooks are hammered out.

LPT: Use CONFIG.debug.hooks = true or Developer Mode to more easily explore what a hook does and when it fires.

API

Actors

Actor5e.preApplyDamage(actor, amount, updates)

A hook event that fires before an Actor takes damage. Note this only fires when the applyDamage method is called, not when the actor's HP is updated manually.

Param Type Description
actor Actor5e The Actor that took the damage
amount number The total amount of damage the actor took. Informational, does not drive update.
updates object The updates about to be made to the actor's hp. This should be mutated to affect the outcome of the damage application.

Actor5e.applyDamage(actor, totalDamageTaken)

A hook event that fires after an Actor takes damage. Note this only fires when the applyDamage method is called, not when the actor's HP is updated manually.

Param Type Description
actor Actor5e The Actor after taking damage
totalDamageTaken number The total amount of damage the actor took

Actor5e.preRollAbilitySave(actor, rollData, abilityId)

A hook event that fires before an Actor rolls a Ability Save. This will fire before the configuration dialog appears.

Param Type Description
actor Actor5e The Actor that rolled the ability save
rollData object The rolldata being provided to the D20Roll instance
abilityId string The ability id (e.g. "str")

Actor5e.rollAbilitySave(actor, result, abilityId)

A hook event that fires after an Actor rolls a Ability Save

Param Type Description
actor Actor5e The Actor that rolled the ability save
result D20Roll The Result of the ability save
abilityId string The ability id (e.g. "str")

Actor5e.preRollAbilityTest(actor, rollData, abilityId)

A hook event that fires before an Actor rolls a Ability Test. This will fire before the configuration dialog appears.

Param Type Description
actor Actor5e The Actor that rolled the ability test
rollData object The rolldata being provided to the D20Roll instance
abilityId string The ability id (e.g. "str")

Actor5e.rollAbilityTest(actor, result, abilityId)

A hook event that fires after an Actor rolls a Ability Test

Param Type Description
actor Actor5e The Actor that rolled the ability test
result D20Roll The Result of the ability test
abilityId string The ability id (e.g. "str")

Actor5e.preRollDeathSave(actor, rollData)

A hook event that fires before an Actor rolls a Death Save

Param Type Description
actor Actor5e The Actor that rolled the death save
rollData object Roll config which will be provided to the d20Roll function

Actor5e.rollDeathSave(actor, result, success)

A hook event that fires after an Actor's Death Save has been evaluated

Param Type Description
actor Actor5e The Actor that rolled the death save
result D20Roll The Result of the death save
success boolean Whether or not the death save was successful

Actor5e.preRollHitDie(actor, rollData)

A hook event that fires before an Actor rolls a hit die.

Param Type Description
actor Actor5e The Actor that rolled a hitDie
rollData object The rolldata being provided to the DamageRoll instance

Actor5e.rollHitDie(actor, roll)

A hook event that fires after an Actor has healed from a hit die roll.

Param Type Description
actor Actor5e The Actor that took the damage
roll DamageRoll The resulting roll from the hit die

Actor5e.preRollSkill(actor, rollData, skillId)

A hook event that fires before an Actor rolls a Skill Check. This will fire before the configuration dialog appears.

Param Type Description
actor Actor5e The Actor that rolled the skill check
rollData object The rolldata being provided to the D20Roll instance
skillId string The skill id (e.g. "ins")

Actor5e.rollSkill(actor, result, skillId)

A hook event that fires after an Actor rolls a Skill Check

Param Type Description
actor Actor5e The Actor that rolled the skill check
result D20Roll The Result of the skill check
skillId string The skill id (e.g. "ins")

Items

Item5e.preRollDamage(item, rollConfig)

A hook event that fires before an Item rolls a Damage Roll. This happens before the Roll Config dialog appears.

Param Type Description
item Item5e The Item that rolls the Damage Roll
rollConfig object Roll config which will be provided to the damageRoll function

Item5e.rollDamage(item, result)

A hook event that fires after an Item rolls a Damage Roll

Param Type Description
item Item5e The Item that rolls the Damage Roll
result DamageRoll The Result of the Damage Roll

Item5e.preDisplayCard(item, chatData)

A hook event that fires before an Item Roll's chat message is created

Param Type Description
item Item5e The Item being rolled
chatData object The data that will be provided to the ChatMessage

Item5e.displayCard(item, chatMessage)

A hook event that fires after an Item Roll's chat message is created

Param Type Description
item Item5e The Item being rolled
chatMessage ChatMessage | object The created ChatMessage instance or ChatMessageData depending on options.createMessage

Item5e.preRoll(item, options, usageParameters)

A hook event that fires before an Item's roll workflow begins. This happens before the Ability Use Dialog is shown.

Param Type Description
item Item5e The Item that rolls the Attack Roll
options object The options passed to the Item.roll method.
[options.configureDialog] boolean Display a configuration dialog for the item roll, if applicable?
[options.rollMode] string The roll display mode with which to display (or not) the card
[options.createMessage] boolean Whether to automatically create a chat message (if true) or simply
usageParameters object Usage Parameters that will create the Ability use Dialog. These can change what the user is prompted for during the ability use dialog.
usageParameters.consumeRecharge boolean Should the item consume its recharge?
usageParameters.consumeResource boolean Should the item consume the configured resource item?
usageParameters.consumeSpellSlot boolean Should the item consume a spell slot?
usageParameters.consumeUsage boolean Should the item consume the configured charges?
usageParameters.consumeQuantity boolean Should the item consume its own quantity?

Item5e.preRollConsumption(item)

A hook event that fires before an Item's usage updates are calculated.

Param Type Description
item Item5e The Item that rolls the Attack Roll // * @param {object} usageParameters Usage Parameters from the Ability use Dialog. These are passed into Item5e._getUsageUpdates to determine the actor and item changes to be committed.
usageParameters.consumeRecharge boolean Should the item consume its recharge?
usageParameters.consumeResource boolean Should the item consume the configured resource item?
usageParameters.consumeSpellLevel string What level spell should the item consume? This should be either 'pact' or 'spell1', 'spell2', etc
usageParameters.consumeUsage boolean Should the item consume the configured charges?
usageParameters.consumeQuantity boolean Should the item consume its own quantity?

Item5e.roll(item, chatMessage)

A hook event that fires after an Item is rolled

Param Type Description
item Item5e The Item being rolled
chatMessage ChatMessage | object The created ChatMessage or ChatMessageData depending on options.createMessage

Item5e.preRollAttack(item, rollConfig)

A hook event that fires before an Item rolls an Attack Roll. This happens before the Roll Config dialog appears.

Param Type Description
item Item5e The Item that rolls the Attack Roll
rollConfig object Roll config which will be provided to the d20Roll function

Item5e.rollAttack(item, result)

A hook event that fires after an Item rolls an Attack Roll

Param Type Description
item Item5e The Item that rolls the Attack Roll
result D20Roll The Result of the Attack Roll

Item5e.preRollFormula(item, formula, rollData)

A hook event that fires before an Item rolls a Formula Roll.

Param Type Description
item Item5e The Item that rolls the Formula Roll
formula string Formula that will be rolled
rollData object Roll config which will be provided to the Roll instance

Item5e.rollFormula(item, result)

A hook event that fires after an Item's "Other Formula" is rolled

Param Type Description
item Item5e The Item being rolled
result Roll The roll instance after evaluation

Item5e.preRollRecharge(item)

A hook event that fires before an Item's Recharge attempt is rolled.

Param Type Description
item Item5e The Item that is rolling a recharge

Item5e.rollRecharge(item, result, success)

Occurs after an Item's Recharge attempt is rolled

Param Type Description
item Item5e The Item being recharged
result Roll The result of the d6 roll
success boolean Was the recharge a success?

Item5e.preRollRecharge(item, rollConfig)

A hook event that fires before an Item's Recharge attempt is rolled.

Param Type Description
item Item5e The Item that is rolling a recharge
rollConfig object Roll config which will be provided to the d20Roll function

Item5e.rollToolCheck(item, result)

A hook event that fires after an Item rolls a Tool Check

Param Type Description
item Item5e The Item that rolls the Tool Check
result D20Roll The Result of the Tool Check Roll