From f4303761d6ef9f50d81ededd000c0705fd0224c5 Mon Sep 17 00:00:00 2001 From: cadowtin Date: Tue, 19 Mar 2024 00:36:19 -0500 Subject: [PATCH] Fixed crit animation visibility fixed tokens dissappearing --- scripts/helpers/anim.js | 6 ++++++ scripts/helpers/animation/crit-animation.js | 4 ++-- scripts/helpers/animation/shakeOnDamageToken.js | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/helpers/anim.js b/scripts/helpers/anim.js index 3981e5d..dbf23c3 100644 --- a/scripts/helpers/anim.js +++ b/scripts/helpers/anim.js @@ -127,3 +127,9 @@ export function getTokenShakeScale(token, dmg) { } }); } + +export function getVisibleAndMsgVisibleUsers(roll_deets) { + getVisibleUsers(roll_deets.token).filter((player) => + (roll_deets.whisper.length === 0 ? game.users.map((u) => u.id) : roll_deets.whisper).includes(player) + ); +} diff --git a/scripts/helpers/animation/crit-animation.js b/scripts/helpers/animation/crit-animation.js index cc0b234..2079579 100644 --- a/scripts/helpers/animation/crit-animation.js +++ b/scripts/helpers/animation/crit-animation.js @@ -1,11 +1,11 @@ -import { getVisibleUsers } from "../anim.js"; +import { getVisibleAndMsgVisibleUsers} from "../anim.js"; import { MODULE_ID } from "../misc.js"; export function createCritAnimation(roll_deets) { const isAttack = roll_deets.type === "attack-roll"; const showOn = game.settings.get(MODULE_ID, "critical.show-on"); if ((showOn === "checks" && isAttack) || (showOn === "attacks" && !isAttack)) return; - const users = getVisibleUsers(roll_deets.token); + const users = getVisibleAndMsgVisibleUsers(roll_deets) switch (game.settings.get(MODULE_ID, "critical.type")) { case "persona": personaCrit(roll_deets.token, users); diff --git a/scripts/helpers/animation/shakeOnDamageToken.js b/scripts/helpers/animation/shakeOnDamageToken.js index d19a4ab..4377a24 100644 --- a/scripts/helpers/animation/shakeOnDamageToken.js +++ b/scripts/helpers/animation/shakeOnDamageToken.js @@ -24,6 +24,7 @@ export function shakeOnDamageToken(actor_uuid, dmg) { new Sequence() .animation() .on(token) + .delay(duration / 10) .opacity(0) .effect() .atLocation(token) @@ -36,10 +37,10 @@ export function shakeOnDamageToken(actor_uuid, dmg) { pingPong: true, }) .duration(duration) + .waitUntilFinished() .forUsers(usersToPlayFor) .animation() .on(token) .opacity(original_opacity) - .waitUntilFinished() .play(); }