EndlesNights / dnd4eBeta

An implementation of the dnd4e game system for Foundry Virtual Tabletop (http://foundryvtt.com).
https://foundryvtt.com/packages/dnd4e
GNU Affero General Public License v3.0
37 stars 30 forks source link

Unlinked Actor effect tracking for toggles. #223

Open NuptupTDOW opened 2 years ago

NuptupTDOW commented 2 years ago

Not sure if relevant here or in the Active Effects module, but figured I'd ask here.

Anyway, I was hoping to be able to use a power that simply calls this post-use macro to run to toggle on or off the Guard Drake's bonus damage when within 2 of an ally. Anyway, if the token isn't Linked to the Actor, which is mandatory for enemies where there are multiple copies of it, (unless you make copies of the enemy entries) then it doesn't work. As soon as I turn on link actor data it works flawlessly. Is it possible for an effect like this to be usable with unlinked actors, so the token refers to it's own specific stats, not the base actor?

const effect = actor.effects.filter(i => i.data.label === 'Within 2 of Ally')[0]; if(!effect) return ui.notifications.error('Error: Effect not found.'); await effect.update({'disabled': !effect.data.disabled});

For example, when unlinked, I can take my guard drake in the actor directory and drop it to the field, and token mold assigns it it's own unique name. When I double click that token, it opens a new, separate sheet that isn't the original guard drake sheet. Is it possible for my toggle to work using THAT sheet instead of having to duplicate the actor and have them all linked?

EndlesNights commented 2 years ago

Stop gap fix you can use, instead of calling actor call this.data.actor, while I get around to fixing this.

const effect = this.data.actor.effects.filter(i => i.data.label === 'Within 2 of Ally')[0];
if(!effect) return ui.notifications.error('Error: Effect not found.');
await effect.update({'disabled': !effect.data.disabled});