Cheat Sheet ‐ (Midi and DAE) Macros - MotoMoto1234/Midi-Wiki GitHub Wiki
CPR v11 top of macro helpers:
const chris = chrisPremades.helpers;
const queue = chrisPremades.queue;
const tashaSummon = chrisPremades.tashaSummon;
const tokenMove = chrisPremades.tokenMove;
const constants = chrisPremades.constants;
const translate = chrisPremades.translate;
const effectAuras = chrisPremades.effectAuras;
const summons = chrisPremades.summons;
CPR v12 3.3.1 top of macro helpers:
const {DialogApp, Crosshairs, Summons, Teleport} = chrisPremades;
const {actorUtils, animationUtils, combatUtils, compendiumUtils, constants, crosshairUtils, dialogUtils, effectUtils, errors, genericUtils, itemUtils, rollUtils, socketUtils, templateUtils, tokenUtils, workflowUtils, spellUtils} = chrisPremades.utils;
Macropass
preItemRoll: Called before the item is rolled (*)
templatePlaced: Only callled once a template is placed
preambleComplete: Called after all targeting is complete
preAttackRoll: Called before the attack roll is made
preCheckHits: Called after the attack roll is made but before hits are adjudicated
postAttackRoll: Called after the attack is adjudicated
preDamageRoll: Called before damage is rolled
postDamageRoll: Called after the damage roll is made
preSave: Called before saving throws are rolled
postSave: Called after saves are rolled
damageBonus: Called when computing the actor damage bonus but the macro is only called when the specific item is rolled
preDamageApplication: Called before Damage Application
preActiveEffects: Called before applying active effects
postActiveEffects: Called after applying active effects
all: Called at each of the above
Console commands to get data of things: Token:
_token.actor
Item:
_token.actor.items.getName('name of the Item')
Effect on actor in midiqol 11.4.x+:
_token.actor.appliedEffects.find(ef => ef.name === "name of the effect")
Effect on actor in midiqol earlier than 11.4.x:
_token.actor.effects.getName('name of the effect')
Console commands to get info:
MidiQOL.Workflow.stateHooks
MidiQOL.Workflow.stateTable, MidiQOL.DamageOnlyWorkflow.stateTable
DAE.daeSpecialDurations()
useful Blurb from the readme about macro helpers:
OnUse/damageBonus macros are passed the following data: args[0] = macroData (a sanitized version of the workflow that triggered the macro being called). This in artefact of using advanced macros to call the macro (Since the data might be sent to another client for execution -it had to be data only, not objects). This is obsolete and it is recommended (version 10.0.44 and above) that you simply refer to workflow in your macro.
And in preparation for v11 within the macro you can refer to:
scope.workflow or just workflow, the workflow that triggered the macro to be called
scope.item or just item, the item that triggered the macro to be called.
actor, the actor that used the item that triggered the macro to be called.
token, the token (if any) that used the item that triggered the macro to be called.
For Actor onUse macros args[0].options.actor and args[0].options.token refer to the actor/token that was targeted by the item roll that triggered the macro being called (similarly scope.options and options are also supported).
Delete all active combats in a world:
Combat.deleteDocuments([],{deleteAll:true})
View all combats made in world currently:
game.combats
The perfect damageBonusMacro....macro
const rollOptions = args[0].damageRolls[0].options;
const isCritical = !args[0].isCritical
? rollOptions.critical
: args[0].isCritical;
const damageBonusFormula = new CONFIG.Dice.DamageRoll(
'2d6',
actor.getRollData(),
{
critical: isCritical,
criticalBonusDamage: rollOptions.criticalBonusDamage,
criticalBonusDice: rollOptions.criticalBonusDice,
criticalMultiplier: rollOptions.criticalMultiplier,
multiplyNumeric: rollOptions.multiplyNumeric,
powerfulCritical: rollOptions.powerfulCritical,
}
).formula;
return { damageRoll: damageBonusFormula, flavor: 'Surprise Attack' };
Replacement for Reverse DR keys in 11.6+ midi(meant to be an onUseMacroName, macropass isDamaged or isHealed
let damageType = 'piercing';
let extraDamage = '1d4';
for (let [idx, detail] of workflow.damageItem.rawDamageDetail.entries()) {
if (detail.type === damageType) {
let extraRoll = await new Roll(extraDamage).evaluate();
detail.value += extraRoll.total;
let modifiedTotal = extraRoll.total * (workflow.damageItem.damageDetail[idx].active.multiplier ?? 1)
workflow.damageItem.damageDetail[idx].value += modifiedTotal;
workflow.damageItem.hpDamage += modifiedTotal;
}
}
CONFIG.DND5E.damageTypes CONFIG.DND5E.healingTypes