diff --git a/ffg-star-wars-enhancements.js b/ffg-star-wars-enhancements.js index d8cf921..9c17cdb 100644 --- a/ffg-star-wars-enhancements.js +++ b/ffg-star-wars-enhancements.js @@ -148,11 +148,12 @@ function register_hooks() { libWrapper.register( "ffg-star-wars-enhancements", "game.ffg.RollFFG.prototype.toMessage", - function (wrapped, ...args) { + async function (wrapped, ...args) { /* we may want to monkeypatch a different function in the future. this location doesn't seem to have access to the actual weapon in use. I'm not sure if we actually care yet, but worth considering. */ + if (!this.evaluated) await this.evaluate(); var data = attack_animation(this, ...args); return wrapped(...data); } diff --git a/release-notes.md b/release-notes.md index ef8944a..9d990f3 100644 --- a/release-notes.md +++ b/release-notes.md @@ -2,6 +2,7 @@ - COMPATABILITY: Module updated to work with FoundryVTT v12 - FIX: Correct Bounty CSS datapad breaking after editing +- FIX: Attack animations are now properly aligned when the system is set to any language other than English `2.0.6` - 2024-04-06 diff --git a/scripts/animation.js b/scripts/animation.js index f44a27e..a6ce50e 100644 --- a/scripts/animation.js +++ b/scripts/animation.js @@ -360,7 +360,10 @@ export function attack_animation(...args) { } // todo: based on dice results, we could have the animation miss - log("attack_animation", "Playing the attack animation: " + animation_file + " / " + sound_file); + log( + "attack_animation", + "Playing the attack animation: " + animation_file + " / " + sound_file + ", hit: " + hit + ); // noinspection JSIgnoredPromiseFromCall play_animation(animation_file, sound_file, skill, source, count, hit); return args; @@ -378,6 +381,17 @@ async function play_animation(animation_file, sound_file, skill, source, count, let max_miss_offset = 50; var arrayLength = game.user.targets.size; let position; + const ranged_skills = [ + game.i18n.localize("SWFFG.SkillsNameRangedLight"), + game.i18n.localize("SWFFG.SkillsNameRangedHeavy"), + game.i18n.localize("SWFFG.SkillsNameGunnery"), + ]; + const melee_skills = [ + game.i18n.localize("SWFFG.SkillsNameMelee"), + game.i18n.localize("SWFFG.SkillsNameBrawl"), + game.i18n.localize("SWFFG.SkillsNameLightsaber"), + ]; + for (var i = 0; i < arrayLength; i++) { if (count !== null) { var range = count.split("-"); @@ -388,7 +402,7 @@ async function play_animation(animation_file, sound_file, skill, source, count, var lower_bound = 2; var num_shots = parseInt(count); } - } else if (["Melee", "Brawl", "Lightsaber"].indexOf(skill) > -1 || skill === "grenade") { + } else if (melee_skills.indexOf(skill) > -1 || skill === "grenade") { // noinspection JSDuplicatedDeclaration var lower_bound = 1; var num_shots = 1; @@ -445,7 +459,7 @@ async function play_animation(animation_file, sound_file, skill, source, count, }, angle: -90, }; - } else if (skill.toLowerCase().includes("ranged") || skill.toLowerCase().includes("gunnery")) { + } else if (ranged_skills.includes(skill)) { var ray = new Ray(tokens[0].center, position); var animation_config = { position: tokens[0].center, diff --git a/scripts/dice_helper.js b/scripts/dice_helper.js index 32b8d5d..e1e3a65 100644 --- a/scripts/dice_helper.js +++ b/scripts/dice_helper.js @@ -68,7 +68,7 @@ export function dice_helper() { } var msg = { - type: CONST.CHAT_MESSAGE_TYPES.OTHER, + type: CONST.CHAT_MESSAGE_STYLES.OTHER, content: '