Ajout distance

This commit is contained in:
sladecraven 2022-10-08 17:43:09 +02:00
parent edf8325109
commit 815b5ff2ac
4 changed files with 76 additions and 2 deletions

View File

@ -392,6 +392,20 @@
"BOL.chat.nodamagesummary": "Aucun dégats n'a été subi ....", "BOL.chat.nodamagesummary": "Aucun dégats n'a été subi ....",
"BOL.chat.damageresume": "{name} a subi des blessures ...", "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.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.soeasy": "Inmanquable (+4)",
"BOL.dialog.veryeasy": "Trés Facile (+2)", "BOL.dialog.veryeasy": "Trés Facile (+2)",

View File

@ -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) { static weaponCheckWithWeapon(actor, weapon) {
@ -76,6 +114,9 @@ export class BoLRoll {
let attribute = eval(`actor.system.attributes.${weaponData.properties.attackAttribute}`) let attribute = eval(`actor.system.attributes.${weaponData.properties.attackAttribute}`)
let aptitude = eval(`actor.system.aptitudes.${weaponData.properties.attackAptitude}`) let aptitude = eval(`actor.system.aptitudes.${weaponData.properties.attackAptitude}`)
// Compute distance
this.detectDistance( weapon, target)
// Manage specific case // Manage specific case
let fightOption = actor.getActiveFightOption() let fightOption = actor.getActiveFightOption()
if (fightOption && fightOption.system.fightoptiontype == "fulldefense") { if (fightOption && fightOption.system.fightoptiontype == "fulldefense") {

View File

@ -14,7 +14,7 @@
], ],
"url": "https://www.uberwald.me/gitea/public/bol", "url": "https://www.uberwald.me/gitea/public/bol",
"license": "LICENSE.txt", "license": "LICENSE.txt",
"version": "10.2.0", "version": "10.2.1",
"compatibility": { "compatibility": {
"minimum": "10" "minimum": "10"
}, },
@ -192,7 +192,7 @@
], ],
"socket": true, "socket": true,
"manifest": "https://www.uberwald.me/gitea/public/bol/raw/v10/system.json", "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", "background": "systems/images/map_lemurie.webp",
"gridDistance": 1.5, "gridDistance": 1.5,
"gridUnits": "m", "gridUnits": "m",

View File

@ -0,0 +1,19 @@
<div>
<img class="chat-icon" src="{{weapon.img}}" alt="{{weapon.name}}"/>
<h2 class="bad"><strong>{{localize "BOL.chat.rangetitle"}}</strong></h2>
</div>
<div class="flexrow">
{{localize "BOL.chat.rangeinfo" attackerName=attackerName defenderName=defenderName}}
{{#if visible}}
<br>{{localize "BOL.chat.rangevisible"}}
{{else}}
<br>{{localize "BOL.chat.rangenotvisible"}}
{{/if}}
<br>{{localize "BOL.chat.rangeweaponinfo" weaponName=weapon.name weaponRange=weaponRange}} m.
<br>{{localize "BOL.chat.rangeprefix"}} {{distance}} m.
<br>{{localize rangeMsg}}
</div>