diff --git a/lang/fr.json b/lang/fr.json index e6947ed..f9a7b75 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -392,6 +392,20 @@ "BOL.chat.nodamagesummary": "Aucun dégats n'a été subi ....", "BOL.chat.damageresume": "{name} a subi des blessures ...", "BOL.chat.fumblemessage": "Si vous acceptez les conséquences d'un echec catastrophique (au choix du MJ), vous pourrez bénéficier d'1 point d'Héroïsme supplémentaire", + "BOL.chat.rangeinfo": "Tir/Lancer de {attackerName} vers {defenderName}", + "BOL.chat.rangeweaponinfo": "Arme : {weaponName} - Portée de base {weaponRange}", + "BOL.chat.rangeout": "Modificateur : Hors de portée", + "BOL.chat.range0": "Modificateur : Bout portant (+1)", + "BOL.chat.range1": "Modificateur : Portée courte (0)", + "BOL.chat.range2": "Modificateur : Portée moyenne (-1)", + "BOL.chat.range3": "Modificateur : Portée longue (-2)", + "BOL.chat.range4": "Modificateur : Portée très longue (-4)", + "BOL.chat.range5": "Modificateur : Portée extrême (-6)", + "BOL.chat.range6": "Modificateur : Portée maximale (-8)", + "BOL.chat.rangeprefix": "Distance évaluée : ", + "BOL.chat.rangevisible": "La ligne de vue est dégagée entre les protagonistes.", + "BOL.chat.rangenotvisible": "La ligne de vue est bloquée entre les protagonistes.", + "BOL.chat.rangetitle": "Information MJ", "BOL.dialog.soeasy": "Inmanquable (+4)", "BOL.dialog.veryeasy": "Trés Facile (+2)", diff --git a/module/controllers/bol-rolls.js b/module/controllers/bol-rolls.js index 8a886c5..82e4a5a 100644 --- a/module/controllers/bol-rolls.js +++ b/module/controllers/bol-rolls.js @@ -67,6 +67,44 @@ export class BoLRoll { }) } + /* -------------------------------------------- */ + static async detectDistance( weapon, target ) { + let visible, dist + if (weapon.system.properties.ranged || weapon.system.properties.throwing) { + console.log("target", target, weapon) + visible = canvas.effects.visibility.testVisibility(target.center, { object: _token }) + dist = Number(canvas.grid.measureDistances([{ ray: new Ray(_token.center, target.center) }], { gridSpaces: false })).toFixed(2) + let range = Number(weapon.system.properties.range) + let rangeMsg = "BOL.chat.rangeout" + if ( dist <= range) { + rangeMsg = "BOL.chat.range0" + } else if (dist < range*2) { + rangeMsg = "BOL.chat.range1" + } else if (dist < range*3) { + rangeMsg = "BOL.chat.range2" + } else if (dist < range*4) { + rangeMsg = "BOL.chat.range3" + } else if (dist < range*5) { + rangeMsg = "BOL.chat.range4" + } else if (dist < range*6) { + rangeMsg = "BOL.chat.range5" + } else if (dist < range*7) { + rangeMsg = "BOL.chat.range6" + } + ChatMessage.create({ + content: await renderTemplate('systems/bol/templates/chat/chat-info-range.hbs', { + weapon: weapon, + attackerName: _token.actor.name, + defenderName: target.actor.name, + weaponRange: weapon.system.properties.range, + visible: visible, + distance: dist, + rangeMsg: rangeMsg + }) + }) + } + } + /* -------------------------------------------- */ static weaponCheckWithWeapon(actor, weapon) { @@ -76,6 +114,9 @@ export class BoLRoll { let attribute = eval(`actor.system.attributes.${weaponData.properties.attackAttribute}`) let aptitude = eval(`actor.system.aptitudes.${weaponData.properties.attackAptitude}`) + // Compute distance + this.detectDistance( weapon, target) + // Manage specific case let fightOption = actor.getActiveFightOption() if (fightOption && fightOption.system.fightoptiontype == "fulldefense") { diff --git a/system.json b/system.json index 95b3ce6..c118c79 100644 --- a/system.json +++ b/system.json @@ -14,7 +14,7 @@ ], "url": "https://www.uberwald.me/gitea/public/bol", "license": "LICENSE.txt", - "version": "10.2.0", + "version": "10.2.1", "compatibility": { "minimum": "10" }, @@ -192,7 +192,7 @@ ], "socket": true, "manifest": "https://www.uberwald.me/gitea/public/bol/raw/v10/system.json", - "download": "https://www.uberwald.me/gitea/public/bol/archive/bol-v10.2.0.zip", + "download": "https://www.uberwald.me/gitea/public/bol/archive/bol-v10.2.1.zip", "background": "systems/images/map_lemurie.webp", "gridDistance": 1.5, "gridUnits": "m", diff --git a/templates/chat/chat-info-range.hbs b/templates/chat/chat-info-range.hbs new file mode 100644 index 0000000..5319ab6 --- /dev/null +++ b/templates/chat/chat-info-range.hbs @@ -0,0 +1,19 @@ +
+ {{weapon.name}} +

{{localize "BOL.chat.rangetitle"}}

+
+ +
+ + {{localize "BOL.chat.rangeinfo" attackerName=attackerName defenderName=defenderName}} + {{#if visible}} +
{{localize "BOL.chat.rangevisible"}} + {{else}} +
{{localize "BOL.chat.rangenotvisible"}} + {{/if}} +
{{localize "BOL.chat.rangeweaponinfo" weaponName=weapon.name weaponRange=weaponRange}} m. +
{{localize "BOL.chat.rangeprefix"}} {{distance}} m. +
{{localize rangeMsg}} + +
+