#Execute as GM in midiQOL in macros
1 messages ยท Page 1 of 1 (latest)
Okay thanks a lot
should have done this a bit sooner, always forgot we helpers can create threads ๐
That's cool ahah
My main suggestion when writing Midi and DAE macros is,...
DAE args to Midi args โ
Midi args to DAE args ๐
because they both use args[0]
if you have a question on this topic i think you can ping us here and the thread will appear in the side bar for the pinged user, right?
Yes
Sorry I don't think I understand the difference
so you're using macro.execute launched from which source? Dae?
DAE > launches on the target
On Use Midi > launches on the caster
from ... I can't remember let me check
both have different provided variables
So your rule for macro.executes is?
usually when called in an active effect it's launched through DAE
so all your midi args won't work in it
Okay in truth it's a bit weird
So I use OnUse ItemMacro, then from the ItemMacro I create and item (with margeObject) that has a dae with macro.execute in it
yeah then you step into DAE at that point
yep
You could technically run both an on use and dae macro on top of it eachother, but you have to start from on use
In the macro.execute I use lastArg does that change anything?
everything, the variables are different
You can piggy back and transfer over variables from On use into the active effect you're creating if you want
I stuff in all sorts of data
You can either create your own midi flag, or toss it in under dae flags
I actually already doing that, I create an Active Effect from the ItemMacro OnUse and then what?
depends what you're end result is
like do you need to refer to back to the caster?
do you need to refer to one of the casters stats?
Okay so, the end result for this specific thing is to deal additional damage based on data on the original item
It's an infusion of ammunition so I have to "mark" the target so it takes more damage from the ammunition
You could just write a DamageBonus macro
apply an active effect to the target with nothing special on it
on the DamageBonus macro you check for the effect, check if they have that ammo equipped on the weapon
it was junky as heck
it's just a bunch of filtering
Yeah
It's doable
Okay yeah I'll re-write it
But not now my brain hurts I have like 2 hours of sleep at best right now
Thank you so much, I'll come back later when I had a bit of sleep
sure have a good night
Sadly it's morning ahaha I'll try to rest a bit, see you later!
I would hate to throw another wrench into this, but creating a temporary item on an unowned actor is a prime application for warp gate
In fact, you use the exact same syntax regardless of ownership
Ahah don't worry, I needed to redo it regardless that one was a bit junk from the beginning
After a bit of work and a close inspection I have the last two items that don't work
But I'm a bit stuck
I have this macro that throws this error: dae | Error evaluating macro for onUpdateActor ReferenceError: targetActor is not defined
The macro is a macro.execute called form dae => flags.dae.onUpdateTarget
Okay found the problem it was a small silly thing
Btw since I always wanted to use warpgate I saw that there's a readme on the project page but I wonder is there others official documents that I can read about to learn all things I can do with warpgate?
the readme is the official API documentation, the wiki has examples and discussion of its use
So in the read me I find everything I need correct?
that's my hope! ๐
Grazie!
Ah now I remember why I didn't do the flags.dnd5e.DamageBonusMacro, it's because since the item can be handed to other players and it's supposed to work but damageBonusMacro works only on the source of the dae
So I opted for a super convoluted solution
Which works even tho it's super ugly in my opinion
But now that I think about it maybe there's a way to make that also work
If I modify the item so the effects is on transfer and on it
When you unequip the item, it should remove the active effect. So when the new player equips it, it should place the active effect on them.
Yeah
I'm trying to rewrite it right now
How do I save a previous item effect when I mergeObject to create the new one with the new effect?
Like if the item before had an active effect I don't want to overwrite it
But how do I save the one there was before?
well it's only going to apply it when transfer to equipped is checked
Sorry I don't understand
I'm doing a mergeObject to overwrite the old item to give it the new infusion active effect that deals the additional damage under the right conditions, and I want to save the old active effect that the item could have had
You can just use duplicate
And the new effect?
then update the duplicant and update the active effect, if you want to modify it on the fly
although it depends, is this a permanent change?
like in concept what I want to do is: new_effect = new_effect + old_effect (if present);
you could use warpgate and modify the flags
But that's already sorted out as a problem
At the very moment I do not know how to use Warpgate, I do not need to modify the flags, I'm trying to add the old active effect into the new one
Like a c++ list if you know what I mean
active effects just flags
[old_data] ---pointer--->[new_data]
Okay didn't know that one
if you don't want to use warpgate, then you'll need to look up the active effect, duplicate it to a temporary object. Make the changes to that object, then update the main active effect with those changes.
I just did this:
let old_effect = duplicate(weaponItem.data.effects);
bla bla stuff stuff
effects: [new_effect, old_effect]
I would love to use warpgate I just need to study it a bit
I feel like this would not work or does it?
it wouldn't be that way, you would need to push in the new flags
if new effects were being added
so lets say.. this is our primary effect..
let effectData = [{
changes: [
{ key: `flags.midi-qol.disadvantage.attack.all`, mode: CONST.ACTIVE_EFFECT_MODES.CUSTOM, value: 1, priority: 20 },
{ key: `flags.midi-qol.grants.advantage.attack.mwak`, mode: CONST.ACTIVE_EFFECT_MODES.CUSTOM, value: 1, priority: 20 },
{ key: `flags.midi-qol.grants.advantage.attack.msak`, mode: CONST.ACTIVE_EFFECT_MODES.CUSTOM, value: 1, priority: 20 },
{ key: `flags.midi-qol.grants.disadvantage.attack.rwak`, mode: CONST.ACTIVE_EFFECT_MODES.CUSTOM, value: 1, priority: 20 },
{ key: `flags.midi-qol.grants.disadvantage.attack.rsak`, mode: CONST.ACTIVE_EFFECT_MODES.CUSTOM, value: 1, priority: 20 },
{ key: `data.attributes.movement.walk`, mode: CONST.ACTIVE_EFFECT_MODES.OVERRIDE, value: Math.floor(target.actor.data.data.attributes.movement.walk / 3), priority: 20 }
],
origin: itemUuid,
disabled: false,
flags: conditionFlags,
duration: { rounds: 10, startRound: gameRound, startTime: game.time.worldTime },
icon: conditionIcon,
label: condition
}];
let prone = target.actor.effects.find(i => i.data.label === condition);
if (!prone) await MidiQOL.socket().executeAsGM("createEffects", { actorUuid: target.actor.uuid, effects: effectData });
This is a portion of the macro in question
arrays are merged as atomic values, btw
if there are two changes array, they will not be concatenated
ehm yes I totally know what that means, totallyyyy ahaha sorry I'm kinda new to Javascript
you also wont be able to update the embedded ActiveEffect collection of an owned item
Why is that?
well....i guess this way you can, but its a bit dangerous. Typically you do not update collections by updating its parent embedded array directly
then you'd need to find it..
let effect = token.actor.effects.find(i=> i.data.label === "prone");
let updates = duplicate(effect.changes);
await updates.push({ key: "flags.dnd5e.meleeCriticalDamageDice", mode: CONST.ACTIVE_EFFECT_MODES.ADD, value: 1, priority: 20 });
effect.update([updates]);
haven't actually tested this, paths are probably wrong to changes
uhmmmm I'm gonna be honest here, I'm understanding little of this, I'll try and test all this stuff to try and make the end of it
Actually i think theres a much easier method with SetProperty, oh wait that's for updating
what's the overall goal again?
The overall goal is to infuse a weapon or ammunition in order to make it deal more damage (damage depends on the item that "summons" the infusion)
With a save and stuff
I have the code for it and it works I'm just trying to clean it up using DamageBonusMacro
yea, the number of hoops you will need to jump through for this operation in core is...as you can tell...a bit much
Okay I'll go and study Warpgate ahah
AE is great for duration effects
Ah yes this is a duration effect
After a minute it vanishes
Again I actually made it work, I just wanted to make it look prettier
I mean you could add additional active effects.. but i think in this case, warpgate might just be easier
if you have something working, go with it, maybe revisit wg in the future -- one of its main features is a highly abstracted API for modifying tokens/actors/items/AEs/etc (anything associated with an actor)
Okay so I should just leave it be for the moment you think?
I'm actually a bit proud of it, it's just doesn't look super good
oh anything you don't need in your active effect, don't include it
for example, this will make the target's Longsword a +1 weapon
const updates = {
embedded: { Item: {
'Longsword':
'data.attackBonus': '+1',
'data.damage.parts': [['1d8 + @mod + 1', 'slashing']],
'name': 'Longsword +1'
}}}
await warpgate.mutate(game.user.targets.first(), updates, {}, {name: 'Magical Weapon'});
and thats all you need!
i think so, soak up your success before bashing your face more ๐
I remade Shillelagh in warpgate, made things a lot of easier
i just did Magic Stone as well
Thank you all!
let itemId = html.find('[name=weapons]')[0].value;
let weaponItem = tactor.items.get(itemId);
let weaponName = weaponItem.name;
let weaponDamage = weaponItem.data.data.damage.parts[0][0];
let adjustedDamage = weaponDamage.replace(/1d(4|6)/g, "1d8");
let itemUpdates = {
"data": {
"ability": tactor.data.data.attributes.spellcasting,
"properties.mgc": true,
"damage": { "parts": [[adjustedDamage, "bludgeoning"]] }
}
};
let updates = { embedded: { Item: { [weaponItem.name]: itemUpdates } } };
await warpgate.mutate(target.document, updates, {}, { name: itemName });
lovely, even going as far as modifying the actual damage die portion, rather than just flat replacing it!
theres a ton more logic before that hehe
but that's the main guts after all the filtering
Shillelagh in warpgate
well a snippet from my macro of it
I get the weapon from a list of available weapons on the actor, then pass that through a dialog which the player selects. Then you get the weapon properties and make the changes needed. then you use warpgate to apply those changes
Ah yes I did something similar just with macros
Warpgate seems really really cool I'm sure I'll look into it soon enough!
Probably tomorrow morning or something
warpgate is the bomb
I am biased to favourite midi but just because tposney is basically my teacher at this point
But yes Warpgate seems like an extremely powerful tool
(its about to get twice as powerful in the near future, too)
Ahaha yeah I like foundry for the freedom I have as a programmer
Tbh it's pretty straightforward too since it's been like, how much? A month at best that I started programming in it and I'm already doing some interesting stuff in it
I don't even care to do insane things with it, just practical stuff
Yeah I often revise my stuff all the time after I've learned better techniques when writings things