Skip to content

Commit

Permalink
Fix Sudden Charge and Dimension Door (#192)
Browse files Browse the repository at this point in the history
- Sudden Charge would freeze foundry for all users. Waiting until the
first step is completed before starting the second seems to fix it.
(#186)
- Dimension Door was using an old property both for spell level
- Stopped the inFlight loop from overriding the label. If one is set,
it's now appended instead,
- This only mattered for sudden charge, so I changed the localized text
to no longer contain punctuation
- Updated both macros to properly handle canceling the crosshair and
reopening the sheet

Co-authored-by: oWave <[email protected]>
  • Loading branch information
oWave and oWave authored Jun 29, 2024
1 parent edbe67a commit a6c667b
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 22 deletions.
7 changes: 5 additions & 2 deletions build/macros/Dimension Door.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (!game.modules.get("jb2a_patreon")?.active) {

const [tokenD, tokenScale] = await pf2eAnimations.macroHelpers(args)

let spellLevel = args[0]?.data?.flags?.pf2e?.casting?.level ?? 11
let spellLevel = args[0]?.item?.level ?? 11

if (spellLevel === 11 && args.length !== 0)
pf2eAnimations.debug(
Expand All @@ -20,7 +20,10 @@ const location = await pf2eAnimations.crosshairs(
{ range, openSheet: false, noCollision: spellLevel < 5 }
)

if (!location) return
if (!location || location.cancelled) {
tokenD.actor.sheet.maximize()
return
}

await Sequencer.Preloader.preloadForClients([
"jb2a.magic_signs.rune.conjuration.intro.blue",
Expand Down
15 changes: 9 additions & 6 deletions build/macros/Sudden Charge.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ for (let i = 0; i < 2; i++) {
{ tokenD },
{
crosshairConfig: {
label:
`${game.i18n.localize(
"pf2e-jb2a-macros.macro.suddenCharge.suddenCharge"
)} ` +
(i + 1),
label: `${game.i18n.localize(
"pf2e-jb2a-macros.macro.suddenCharge.suddenCharge"
)} (${i + 1}/2)`,
},
noCollisionType: "move",
openSheet: false,
}
)

console.log(location)

if (location === false || location.cancelled) return
if (location === false || location.cancelled) {
tokenD.actor.sheet.maximize()
return
}

await new Sequence({ moduleName: "PF2e Animations", softFail: true })
.animation()
Expand All @@ -47,6 +49,7 @@ for (let i = 0; i < 2; i++) {
.belowTokens()
.fadeOut(1000)
.scale(0.5 * tokenD.document.height)
.waitUntilFinished()
.play()
}

Expand Down
4 changes: 2 additions & 2 deletions languages/cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"macro": {
"suddenCharge": {
"notif": "突袭冲锋!选择你想去的位置。右键取消。",
"suddenCharge": "突袭冲锋"
"suddenCharge": "突袭冲锋"
},
"disguise": {
"illusoryDisguise": "🎭幻象伪装🎭",
Expand Down Expand Up @@ -130,4 +130,4 @@
"footer": "你可以安全地删除本消息,本消息不会被再次发送。"
}
}
}
}
4 changes: 2 additions & 2 deletions languages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"macro": {
"suddenCharge": {
"notif": "Plötzliche Attacke! Wählen Sie aus, wohin Sie sich bewegen wollen. Rechtsklick zum Abbrechen.",
"suddenCharge": "Plötzlicher Angriff."
"suddenCharge": "Plötzlicher Angriff"
},
"disguise": {
"humanoidForm": "🎭Humanoide Form🎭",
Expand Down Expand Up @@ -67,4 +67,4 @@
"outOfRange": "Außerhalb der Reichweite!"
}
}
}
}
2 changes: 1 addition & 1 deletion languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"outOfRange": "Out of Range!",
"suddenCharge": {
"notif": "Sudden Charge! Select where you want to move. Right click to cancel.",
"suddenCharge": "Sudden Charge."
"suddenCharge": "Sudden Charge"
},
"disguise": {
"humanoidForm": "🎭Humanoid Form🎭",
Expand Down
4 changes: 2 additions & 2 deletions languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"macro": {
"suddenCharge": {
"notif": "Charge soudaine ! Choisissez où vous voulez vous déplacer. Clic droit pour annuler.",
"suddenCharge": "Charge soudaine."
"suddenCharge": "Charge soudaine"
},
"disguise": {
"humanoidForm": "🎭Forme humanoïde🎭",
Expand Down Expand Up @@ -130,4 +130,4 @@
"description": "Ce module fournit des préréglages d'animation pour le système PF2e. Ces animations peuvent ralentir votre machine, que ce soit parce que vous avez un ordinateur en bout de course ou parce qu'il y a beaucoup d'effets à l'écran, ce qui est courant dans les hauts niveaux du jeu.<p/>Si vous ne voulez pas voir ces animations, veuillez consulter les paramètres du module <b>Sequencer</b> et désactiver le paramètre <b>\"Activer les effets\"</b>."
}
}
}
}
4 changes: 2 additions & 2 deletions languages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"macro": {
"suddenCharge": {
"suddenCharge": "Carica Improvvisa.",
"suddenCharge": "Carica Improvvisa",
"notif": "Carica Improvvisa! Seleziona dove vuoi moverti. Tasto destro per annullare."
},
"disguise": {
Expand Down Expand Up @@ -114,4 +114,4 @@
}
}
}
}
}
4 changes: 2 additions & 2 deletions languages/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
},
"suddenCharge": {
"notif": "Nagła Szarża! Wybierz gdzie chcesz się poruszyć. Kliknij prawy przycisk aby anulować.",
"suddenCharge": "Nagła Szarża."
"suddenCharge": "Nagła Szarża"
},
"outOfRange": "Poza zasięgiem!"
},
Expand All @@ -130,4 +130,4 @@
"footer": "Możesz bezpiecznie usunąć tę wiadomość, nie otrzymasz kolejnej."
}
}
}
}
2 changes: 1 addition & 1 deletion languages/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"macro": {
"suddenCharge": {
"notif": "突襲衝鋒!選擇你想去的位置。右鍵取消。",
"suddenCharge": "突襲衝鋒"
"suddenCharge": "突襲衝鋒"
},
"disguise": {
"illusoryDisguise": "🎭幻象偽裝🎭",
Expand Down
8 changes: 6 additions & 2 deletions module/pf2e-animations.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ pf2eAnimations.runMacro = async function runJB2Apf2eMacro(

if (macro_data) {
if (isNewerVersion(game.version, "11")) {
await macro_data.execute({args});
await macro_data.execute({ args });
} else {
const temp_macro = new Macro(macro_data.toObject());
temp_macro.ownership.default = CONST.DOCUMENT_PERMISSION_LEVELS.OWNER;
Expand Down Expand Up @@ -825,7 +825,7 @@ pf2eAnimations.crosshairs = async function crosshairs(
// make it wait or go into an unescapable infinite loop of pain
await warpgate.wait(50);

const ray = new Ray(args.token.center, crosshairs);
const ray = new Ray((args.token ?? args.tokenD).center, crosshairs);

const distance = canvas.grid.measureDistances([{ ray }], {
gridSpaces: true,
Expand Down Expand Up @@ -879,6 +879,10 @@ pf2eAnimations.crosshairs = async function crosshairs(

await Sequencer.EffectManager.endEffects({ name: "Out of Range!" });
}

if (opts.crosshairConfig?.label)
crosshairs.label += `\n${opts.crosshairConfig.label}`;

crosshairs.draw();
}
}
Expand Down

0 comments on commit a6c667b

Please sign in to comment.