shemetz / roll-from-compendium

FoundryVTT module that adds easy buttons to post things to chat.
MIT License
5 stars 2 forks source link

Dummy actor creation fails in PF2e #21

Closed danheuck closed 1 year ago

danheuck commented 1 year ago

It seems like there was a change in PF2e which is causing the module to fail when it attempts to create the dummy actor:

image

The issue seems to be at quick-send-to-chat.js:270

    type: types[0],  // e.g. 'character' in dnd5e and pf2e
    types: types[0],

Presumably types[0] used to be character but it's now base which seems to be causing the constructor to fail:

image

If I modify those two lines to use types[1], it seems to work (the message gets posted to chat), but there's still an error in the console for spell casts (and maybe other things, I haven't checked extensively):

image

This seems to be due to the PF2e system doing some checks where it assumes a token exists to cast the spell, but it works if you aren't looking at the log, so I wouldn't call it critical:

function getCondition(token, target, isSpell) {
  const checkingAttacker = target === null;
  const currentActor = checkingAttacker ? token?.actor : target?.actor;
  const conditionMap = checkingAttacker ? { ...actorConditionMap } : targetConditionMap;
  const attackerBlinded = !!token.actor?.items?.find(i => i.slug === "blinded");
  const attackerDazzled = !!token.actor?.items?.find(i => i.slug === "dazzled");
  const attackerHasBlindFight = !!token.actor?.items?.find((i) => i.slug === "blind-fight");
  const attackerHasLiminalFetchling = !!token.actor?.items?.find((i) => i.slug === "liminal-fetchling");
  ...
shemetz commented 1 year ago

Thanks for the detailed report!

I fixed the main bug here now, v1.7.1.

I can't reproduce the console errors, though. Can you try doing it again after updating? I wonder if it's a weird race condition.

danheuck commented 1 year ago

Sorry, looks like the console errors were due to another module I had accidentally left enabled during testing, PF2e Flat Check; not an issue with this module.

They seem to work fine together if I make sure to select a token before casting (which I should probably do anyway most of the time) and it's the other modules job to check that token exists before it tries to read properties from it regardless.

Thanks for getting the issue fixed, sorry again if I wasted any of your time looking for those console errors.

shemetz commented 1 year ago

You helped a lot with finding the real bug, don't worry!