Skip to content

Commit

Permalink
fix(animations): alignment
Browse files Browse the repository at this point in the history
* fix alignment with non-english systems
* fix await bug for dice

#182
  • Loading branch information
wrycu committed May 21, 2024
1 parent d2695f8 commit 2d578b3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
3 changes: 2 additions & 1 deletion ffg-star-wars-enhancements.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 17 additions & 3 deletions scripts/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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("-");
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion scripts/dice_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function dice_helper() {
}

var msg = {
type: CONST.CHAT_MESSAGE_TYPES.OTHER,
type: CONST.CHAT_MESSAGE_STYLES.OTHER,
content:
'<button class="effg-die-result" ' +
'data-ad="' +
Expand Down

0 comments on commit 2d578b3

Please sign in to comment.