MidiQOL activation conditions examples - thatlonelybugbear/FoundryMacros GitHub Wiki
Setting up.
To use them, first of all you will need to go to MidiQOL settings -> Workflow Settings -> Workflow tab
and navigate to the bottom.
Change accordingly:
Activation conditions is a handy way to test that specific conditions are met, before allowing:
- An Item to be used, or
- A reaction Item to be triggered, or
- An active effect on an Item to be applied to targets, or
- The other damage formula to be rolled and applied to targets.
These fields from MidiQOL v11.3.13 onwards, are found in the handy MidiQOL tab in any Item's details tab.
How they work.
They are small JS scripts which have access to:
- The attacking actor's rollData (everything the console returns if you type
_token.actor.getRollData()
with a token selected and hit enter), - The targeted actor's rollData, under
target
(egtarget.attributes.hp.value < target.attributes.hp.max/2
), targetActorId
,targetActorUuid
,targetId
,targetUuid
(target's token.document.uuid),- The (to be) used Item's rollData under
item
(egitem.actionType == 'mwak'
, but also some handy helpers, likeisAttuned
) - MidiQOL functions
findNearby
,checkNearby
,hasCondition
,checkDefeated
,checkIncapacitated
, - MidiQOL
workflow
humanoid
, is an Array of types considered humanoid:['human','humanoid','elven','elf','half-elf','drow','dwarf','dwarven','halfling','gnome','tiefling','orc','dragonborn','half-orc']
,
raceOrType
, checks for the race or type of the targeted creature.- First returns a lower cased
actor.system.details.race.name ?? actor.system.details?.race
if found, - Then will check and return
actor.system.details.type?.value.toLocaleLowerCase() ?? ""
- First returns a lower cased
typeOrRace
, returns the same data asraceOrType
but the other way around.reaction
, returns the type of the reaction trigger,semiSuperSaver
(typo in that one?).
Idea is to create conditional checks which will allow for the Item (use or reaction trigger)/damage roll/effect application to proceed only if the check evaluates to true
.
Item Activation conditions examples.
- Item that doesn't allow for attacks against Undead or Constructs:
!['construct', 'undead'].includes(typeOrRace)
- Item that cannot be used if an enemy is in 5ft radius:
!checkNearby(CONST.TOKEN_DISPOSITIONS.HOSTILE, tokenUuid, 5)
- Item that cannot be used if another Item is not present on the actor:
items.some((i) => i.name == 'Diamond (300gp)')
Reaction Activation conditions.
Available reaction
triggers:
'preAttack'
, called before an Item (with creates an attack roll, or in Foundry data schema termsitem.hasAttack == true
) rolls for the Attack,'isAttacked'
called when an item.hasAttack has rolled the Attack, but before checks for hit/miss,'isMissed'
, item.hasAttack misses,'isHit'
, item.hasAttack hits,'isDamaged'
, item.hasAttack deals damage,'isHealed'
, item does healing (either actionType == 'heal' OR the first damage type is 'healing' or 'temporary healing'),'isSave'
, item.hasSave triggers a saving throw, but before the result has been adjudicated'isSaveSuccess'
, item.hasSave and save success'isSaveFail'
, item.hasSave and save failure.
Examples:
- a reaction when you have to make a save against a spell:
reaction == 'isSave' && item.type == 'spell'
- a reaction that can be used when you are hit and you can see a medium sized or smaller, incapacitated creature in a 5ft radius:
reaction == 'isHit' && findNearby('all', targetUuid, 5, {includeIncapacitated: true, canSee: true}).some((t) => !!checkIncapacitated(t, false) && ['tiny','sm','med'].includes(t.actor.system.traits.size))
- a reaction when you are hit by a melee attack (the
('m')
should be catching all melee attack and(['rwak','rsak'])
all ranged attacks if needed. Play with('w')
and('s')
forweapon
andspell
attacks):
reaction == 'isHit' && item.actionType?.includes('m')
Active Effect Activation conditions.
- Effect that is only applied if the target is Grappled:
hasCondition(targetUuid, 'grappled')
- Effect that is only applied if the target is not an Elf or doesn't have the Fey Ancestry Item (feature):
!raceOrType.includes('elf') && !target.items.some((i)=>i.name=='Fey Ancestry')
Other damage formula activation conditions.
- Extra dmg against creatures that have not yet had a turn during the first round of combat:
target?.token?.combatant?.combat?.round === 1 && target.token.combatant.combat.turn < target.token.combatant.combat.turns.findIndex(i=>i.tokenId === target.tokenId)