fantasycalendar / FoundryVTT-Sequencer

This module implements a basic pipeline that can be used for managing the flow of a set of functions, effects, sounds, and macros.
Other
41 stars 19 forks source link

[BUG] - Sequences fail to locate `MeasuredTemplate#object` immediately after a template is created. #192

Open krbz999 opened 1 year ago

krbz999 commented 1 year ago

Describe the bug Sequences that are meant to play on a template fail to locate the correct coordinates. Most apparent using JB2A with a fireball animation targeting a newly created circle template, or a lightning bolt animation on a ray (line) template.

To Reproduce

  1. Enable JB2A, Sequencer, and dependencies in the dnd5e system (v2.2.2 and foundry v11.305).
  2. Run the below script for fireball and lightning bolt respectively.
  3. Cast fireball and place the template. The beam fires off into the corner.
  4. Cast lightning bolt and place the template. The animation does not play at all (see console for an error).
// quick and ugly script for a fireball anim
const tok = canvas.scene.tokens.find(e => e);
Hooks.once("createMeasuredTemplate", tem => {
  const beam = "jb2a.fireball.beam.orange";
  const expl = "jb2a.fireball.explosion.orange";
  const seq = new Sequence();
  seq.effect().file(beam).atLocation(tok).stretchTo(tem).playbackRate(2).waitUntilFinished();
  seq.effect().file(expl).atLocation(tem);
  seq.play({remote: true});
});
// and for lightning bolt
Hooks.once("createMeasuredTemplate", async function(templateDoc){
    const file = "jb2a.lightning_bolt.narrow.blue";
    return new Sequence()
      .effect()
        .file(file)
        .atLocation(templateDoc)
        .stretchTo(templateDoc)
      .play();
});

Expected behavior Animations targeting the template objects.

Setup:

Active modules:

Additional context This issue did not appear in v10 to the best of my recollection. Adding await new Promise(r => setTimeout(r, 50)) to the top of the above hooks seems to fix any issues from initial testing.