damage application hooks

New 5e Hook ideas, gimme yer thoughts: Hooks.call('Actor5e.preDamageApplied') args: damageAmount, actor, damageType (if available) Goal: Allow modules to intercept damage being applied to an actor and change it. Mutating damageAmount would affect the amount the actor takes. E.g. automating something like Heavy Armor Master, immunities, etc. --- Hooks.callAll('Actor5e.damageApplied') args: damageAmount, actor, damageType (if available) Goal: Allow modules to react to damage being taken from an actor. E.g. concentration checks, saying "ow" Problems: - Running these on/pre actor update is feasible, but tricky because of temphp. It would be simpler to rely on Actor5e#applyDamage, but that doesn't cover the HP on a sheet being updated manually. - Unlinked Tokens and all that mess (not really sure this is a problem, just something to be wary of). - Currently the system's damage rolls strip out damageType a long time before Actor5e#applyDamage enters the picture.
C
Calego861d ago
How bulletproof should a hook like this be? Is it "fine" that it relies on a specific API path (i.e. Actor.applyDamage) instead of being essentially an alias for the existing Actor update hooks? That kind of feels like making something 'worse' just to avoid a little complexity.
B
BadIdeasBureau861d ago
Calling it on every change to hp.value seems like it would produce a lot of false positives (e.g. changing HP when levelling up, or just editing an actor), and I'm not really sure how you'd distinguish those. In particular, a GM adjusting monster HP due to something else going wrong (e.g. "this goblin has 10 hp but should have 5") shouldn't trigger this hook if it's then going to allow modules to mutate the "damage" - could resolve this by requiring a damage type, but then it makes it potentially less useful for the "roll dice -> right click -> apply damage" workflow. Roughly, I think Actor#ApplyDamage is a reasonable flag for "is this actually damage rather than an HP update", but maybe with an explicit ask for other modules to call this hook as needed. Unlinked tokens aren't actually a mess in the updateActor hook, since that passes token.actor for an unlinked token, so the same behaviour here would be fine.
C
Calego861d ago
We'd be putting this into the Actor#applyDamage method, so as long as modules call that when things damage creatures (which they are incentivized to do anyways because it handles temphp correctly), the hooks would fire. also that's good to hear about unlinked tokens, that's one of the last bastions of things that still scare me because I haven't looked too closely yet I agree that having a distinction between "yes I definitely meant to change the actor" and "this is the actor taking damage" is a good one to have. I think an additional UI way to trigger this method would be helpful to really drive home the difference. E.g. a "manage HP" button on the sheet or something like that
B
BadIdeasBureau861d ago
Yeah, I expected to run into that minefield when doing Memento Mori, and then it just worked.
UU
Unknown User859d ago
Want results from more Discord servers?
Add your server
More Posts
hook conventionsRegarding hooks, is the convention that _all_ `pre...` hooks are executed on the machine that initiaexpand arraysIs there a way to `expandObject` except for an Array?edit-owned-item-effectI've made an abomination. This hacks its way past the limitations surrounding editing effects on ownItem Pile feedbackSimple is king!effects to chat@badideasbureau is the `temporary` flag you look for in Effects to Chat a convention from somewhere 5e AEsI've been messing pretty heavily with some Active Effect assumptions and mechanisms in 5e. This is mhero creator ui feedbackI'm trying to refactor the abilities' tab on the hero creation room to accomodate Race ASIs, but I deffect mechanic searchingI need someone to check me on a null hypothesis I'm making. > There are no abilities in 5e RAW whicDialog shennaneginsTIL the button callbacks for `Dialog.prompt` and `Dialog.confirm` can be asynchronous. ```js const Advancement Hooks@kandashi @ccjmk and anyone else who is currently working on modules that would interact with the AdAPI doc topicsGive me some ideas for what areas of the foundry core API would benefit from a wiki documentation paDiscord Permission IssueOh, I think you also need a Typescript roleDevelopment-APIA new section of the Wiki was created today: `development/api` This section is dedicated to documentitem to actors scriptI have this macro for updating actors in a compendium with spells from a compendium of spells (i.e. Primary and Embedded UpdatesTIL how to update embedded documents at the same time as parent documents. ``` game.actors.getName(compendium errors upgrading to v9hmm im not entirely sure how this will work though.. because I did just a quick smell test to my mod