Jagusti/fvtt-wfrp4e-gmtoolkit

Advantage macros affect actors rather than tokens

Jagusti opened this issue · 1 comments

image

The add, clear and reduce macros are updating the advantage on the actor rather than the token. Where multiple tokens are created from (and therefore share) the same actor, they are equally affected by the advantage change, even when Link Actor Data is not selected on the token.

  • The current actor-based behaviour is fine when you only have a single token for an actor (such as with PCs or main NPCs).
  • If you drag actors direct from a compendium (eg, Bestiary), that generates additional (unique) actor-tokens, and also avoids the issue. It's a workaround, but it does mean you end up with multiple copies of the compendium entry in your actor list.

To fix this

  • change the macro to affect the token's advantage rather than the related actor data

This needs tidying and reincorporating to take account of linked tokens, but should work:

let tokenData = token.data
let newStatus = Number(0)
// Get max based on base actor
// Check if unlinked
// Apply min/max
if (tokenData.actorData.data !== undefined) {
   newStatus = Number(tokenData.actorData.data.status.advantage.value)+1
   token.update({"actorData.data.status.advantage.value": Number(newStatus)});
} else {
   token.update({"actorData.data.status.advantage.value" : newStatus})
   return;
}