#Midi stuff
1 messages · Page 1 of 1 (latest)
async function wait(ms) {return new Promise(resolve => {setTimeout(resolve, ms);});}
if(args[0].hitTargets.length === 0) return {};
let tokenD = canvas.tokens.get(args[0].tokenId);
let actorD = tokenD.actor;
let target = canvas.tokens.get(args[0].hitTargets[0].id);
let itemD = args[0].item;
let gameRound = game.combat ? game.combat.round : 0;
const diceMult = args[0].isCritical ? 2: 1;
const numDice = 3 * diceMult;
let damageRoll = await new Roll(‘${numDice}d6’).evaluate();
await new MidiQOL.DamageOnlyWorkflow(actorD, tokenD, damageRoll.total, "necrotic", [target], damageRoll, {flavor: "Necrotic Bite - Damage Roll (Necrotic)", damageList: args[0].damageList, itemCardId: args[0].itemCardId });
await MidiQOL.applyTokenDamage([{damage: damageRoll.total, type: "healing"}], damageRoll.total, new Set([tokenD]), itemD.name, new Set());
const effectData = {
label : "Drain",
icon : "icons/skills/wounds/blood-drip-droplet-red.webp",
origin: args[0].uuid,
changes: [{
"key": "data.attributes.hp.max",
"value": `-${damageRoll.total}`,
"mode": 2,
"priority": 20
}],
disabled: false,
duration: {seconds: 86400,startRound: gameRound, startTime: game.time.worldTime},
}
await MidiQOL.socket().executeAsGM("createEffects", {actorUuid: target.actor.uuid, effects: [effectData]});
let hpNow = target.actor.data.data.attributes.hp.max;
let updateHP = hpNow - damageRoll.total;
let the_message = `<p>${tokenD.name} drains ${target.name} of ${damageRoll.total} pts from their maximum Hit Point value!</p><p>${target.name} now has Maximum Hit Point maximum of ${updateHP}.</p><br><p><b>If it reaches O, they die!!</b></p><br><p> ${tokenD.name} regains ${damageRoll.total} Hit Points back!</p>`;
await wait(600);
ChatMessage.create({
user: game.user._id,
speaker: ChatMessage.getSpeaker({actorD: actorD}),
content: the_message,
type: CONST.CHAT_MESSAGE_TYPES.EMOTE
});
Needs ` not ‘ where you changed the formula
in the "let actorD = tokenD.actor;" part right?
Could probably shorten up a lot of this
let damageRoll = await new Roll(`${numDice}d6`).evaluate()
I made a vampire kit a couple of months ago
2 minutes to type this on the iPad… arghhhh
there's no longer an error but idk if its working
the vampire isnt getting healed and the max hp isnt getting lowered
Towards the end change the game.user._id to game.user.id
same issue
How do you execute the macro? Midi onUse ?
yes
Yeah I cannot see anything else right now as it is difficult to go through it on the tablet. Paste it once more and if nothing else pops in mind, ping me Friday when I am back on my pc
aight
async function wait(ms) {return new Promise(resolve => {setTimeout(resolve, ms);});}
if(args[0].hitTargets.length === 0) return {};
let tokenD = canvas.tokens.get(args[0].tokenId);
let actorD = tokenD.actor;
let target = canvas.tokens.get(args[0].hitTargets[0].id);
let itemD = args[0].item;
let gameRound = game.combat ? game.combat.round : 0;
const diceMult = args[0].isCritical ? 2: 1;
const numDice = 3 * diceMult;
let damageRoll = await new Roll(`${numDice}d6`).evaluate()
await new MidiQOL.DamageOnlyWorkflow(actorD, tokenD, damageRoll.total, "necrotic", [target], damageRoll, {flavor: "Necrotic Bite - Damage Roll (Necrotic)", damageList: args[0].damageList, itemCardId: args[0].itemCardId });
await MidiQOL.applyTokenDamage([{damage: damageRoll.total, type: "healing"}], damageRoll.total, new Set([tokenD]), itemD.name, new Set());
const effectData = {
label : "Drain",
icon : "icons/skills/wounds/blood-drip-droplet-red.webp",
origin: args[0].uuid,
changes: [{
"key": "data.attributes.hp.max",
"value": `-${damageRoll.total}`,
"mode": 2,
"priority": 20
}],
disabled: false,
duration: {seconds: 86400,startRound: gameRound, startTime: game.time.worldTime},
}
await MidiQOL.socket().executeAsGM("createEffects", {actorUuid: target.actor.uuid, effects: [effectData]});
let hpNow = target.actor.data.data.attributes.hp.max;
let updateHP = hpNow - damageRoll.total;
let the_message = `<p>${tokenD.name} drains ${target.name} of ${damageRoll.total} pts from their maximum Hit Point value!</p><p>${target.name} now has Maximum Hit Point maximum of ${updateHP}.</p><br><p><b>If it reaches O, they die!!</b></p><br><p> ${tokenD.name} regains ${damageRoll.total} Hit Points back!</p>`;
await wait(600);
ChatMessage.create({
user: game.user.id,
speaker: ChatMessage.getSpeaker({actorD: actorD}),
content: the_message,
type: CONST.CHAT_MESSAGE_TYPES.EMOTE
});
In the applyTokenDamage use just itemD instead of itemD.name
patreon version