From 5fc3d1f38acfb632c4214bb1aa7a78fead5a8558 Mon Sep 17 00:00:00 2001 From: HavelockV Date: Thu, 17 Sep 2020 17:11:08 +0200 Subject: [PATCH 1/5] Penalty/malus, bullets calc correction --- README.md | 4 ++++ lang/en.json | 2 +- module/chat/rangecombat.js | 8 +++---- templates/chat/combat/melee-target.html | 2 +- templates/chat/combat/range-initiator.html | 26 +++++++++++----------- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 27e31f9e..36a457e3 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,10 @@ Compendium 'Weapons' contains a single test weapon. ## What is working +version 0.3.7 : + +* Bug correction typo on the character sheet. + version 0.3.6 : * Addition of pulp talents (To be tested, I’m not familiar with Pulp Cthulhu, all of this is mainly cosmetic, no automation implemented so far) diff --git a/lang/en.json b/lang/en.json index 42a7b95d..3c6afb88 100644 --- a/lang/en.json +++ b/lang/en.json @@ -136,7 +136,7 @@ "CoC7.Advantage": "Advantage", "CoC7.Disadvantage": "Disadvantage", "CoC7.TitleAdvantage": "Add 1 bonus die (target is prone, restrained...)", -"CoC7.TitleDisadvantage": "Add 1 malus die (for being prone, restrained...)", +"CoC7.TitleDisadvantage": "Add 1 panalty die (for being prone, restrained...)", "CoC7.TitleOutNumbered":"Add 1 bonus dice for outnumbered target", "CoC7.TitleSurprised": "Add 1 bonus dice for surprised target", "CoC7.TitleAutoSuccess": "Attack automaticaly hit", diff --git a/module/chat/rangecombat.js b/module/chat/rangecombat.js index 8df500a6..fb3b1c90 100644 --- a/module/chat/rangecombat.js +++ b/module/chat/rangecombat.js @@ -413,8 +413,8 @@ export class CoC7RangeInitiator{ let weaponMalfunction = false; let index = 0; while( !weaponMalfunction && this.shots.length > index){ - const roll = this.shootAtTarget(this.shots[index]); - await this.weapon.shootBullets( this.shots[index].bulletsShot + this.shots[index].transitBullets ); + const roll = this.shootAtTarget( this.shots[index]); + await this.weapon.shootBullets( parseInt(this.shots[index].bulletsShot) + parseInt(this.shots[index].transitBullets)); if( roll.hasMalfunction){ roll.isSuccess = false; weaponMalfunction = true; @@ -770,8 +770,8 @@ export class CoC7RangeTarget{ get sizeText(){ if( this.big) return '1 bonus die for big target (Build > +4)'; - if( this.small) return '1 malus die for a small target'; - return 'Target has a normal size, no bonus/malus'; + if( this.small) return '1 penalty die for a small target'; + return 'Target has a normal size, no bonus/penalty'; } get sizeLabel(){ diff --git a/templates/chat/combat/melee-target.html b/templates/chat/combat/melee-target.html index 2e32d3b3..398121a6 100644 --- a/templates/chat/combat/melee-target.html +++ b/templates/chat/combat/melee-target.html @@ -71,7 +71,7 @@

data-flag="advantage" data-selected={{advantage}}>{{localize 'CoC7.Advantage'}} {{localize 'CoC7.Disadvantage'}} diff --git a/templates/chat/combat/range-initiator.html b/templates/chat/combat/range-initiator.html index f182ee93..135e0009 100644 --- a/templates/chat/combat/range-initiator.html +++ b/templates/chat/combat/range-initiator.html @@ -46,7 +46,7 @@

{{#if burst}} {{localize 'CoC7.rangeCombatCard.Burst'}}{{/if}} {{#if fullAuto}} {{localize 'CoC7.rangeCombatCard.FullAuto'}} {{/if}} {{#if advantage}} {{localize 'CoC7.Advantage'}}{{/if}} - {{#if disadvantage}} {{localize 'CoC7.Disadvantage'}}{{/if}} + {{#if disadvantage}} {{localize 'CoC7.Disadvantage'}}{{/if}} {{#if aimed}} {{localize 'CoC7.rangeCombatCard.aiming'}}{{/if}} {{else}} @@ -95,7 +95,7 @@

data-flag="advantage" data-selected={{advantage}}>{{localize 'CoC7.Advantage'}} {{localize 'CoC7.Disadvantage'}} @@ -161,7 +161,7 @@

title="{{localize 'CoC7.rangeCombatCard.OutOfRange'}}" >{{localize 'CoC7.rangeCombatCard.OutOfRange'}} {{localize 'CoC7.rangeCombatCard.Cover'}} title="1 bonus die for big target (Build > +4)" >{{localize 'CoC7.rangeCombatCard.BigTarget'}} {{localize 'CoC7.combatCard.SmallTarget'}} {{localize 'CoC7.rangeCombatCard.InMelee'}} {{localize 'CoC7.rangeCombatCard.FastMovingTarget'}} {{else}}
@@ -202,7 +202,7 @@

{{localize 'CoC7.rangeCombatCard.Cover'}} @@ -230,12 +230,12 @@

{{trgt.sizeLabel}} {{localize 'CoC7.rangeCombatCard.InMelee'}} {{localize 'CoC7.rangeCombatCard.FastMovingTarget'}} @@ -258,7 +258,7 @@

title="{{localize 'CoC7.rangeCombatCard.OutOfRange'}}" >{{localize 'CoC7.rangeCombatCard.OutOfRange'}} {{localize 'CoC7.rangeCombatCard.Cover'}} title="1 bonus die for big target (Build > +4)" >{{localize 'CoC7.rangeCombatCard.BigTarget'}} {{localize 'CoC7.combatCard.SmallTarget'}} {{localize 'CoC7.rangeCombatCard.InMelee'}} {{localize 'CoC7.rangeCombatCard.FastMovingTarget'}}

From d8878ddf99d7859d5e1dd85cca1b8bd9671403cb Mon Sep 17 00:00:00 2001 From: HavelockV Date: Sat, 19 Sep 2020 05:18:24 +0200 Subject: [PATCH 2/5] Distance measurement corrections --- README.md | 10 +++++++++- lang/en.json | 4 +++- module/chat/helper.js | 8 +++++--- module/chat/rangecombat.js | 14 +++++++++++--- module/coc7.js | 8 ++++++++ templates/chat/combat/range-initiator.html | 8 ++++---- 6 files changed, 40 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 36a457e3..40342da4 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,15 @@ Compendium 'Weapons' contains a single test weapon. version 0.3.7 : -* Bug correction typo on the character sheet. +* Bug correction: + * Typo on the character sheet. + * Typo correction on the range chat-card. + * Typo correction malus->penalty. + * Calculation of bullets fired was wrongly deducted from the weapon magazine. +* Added distance to target on the range chat-card. + * You can now see the distance from the taget below the target selector in the chat-card and on the tooltip of the target. +* Added an option to restrict measurement to grid space. + * By default, for combat range calculation, the distance measured is the euclidean distance. To see that distance using the ruller you'll need to hold shift while measuring. An option is added to use grid spaces instead of euclidean distance. By selecting it, distance will be calculated as per the default ruler for that grid type (Grid less; Square, Hex...) version 0.3.6 : diff --git a/lang/en.json b/lang/en.json index 3c6afb88..45dd0c61 100644 --- a/lang/en.json +++ b/lang/en.json @@ -343,5 +343,7 @@ "SETTINGS.DisregardAmmo": "Disregard Ammo count.", "SETTINGS.DisregardAmmoHint": "Enabling this will not take in account the number of bullets loaded in the gun.", "SETTINGS.DisregardUsePerRound": "Disregard Uses per Rounds.", -"SETTINGS.DisregardUsePerRoundHint": "Enabling this will allow you to fire as much as you want, regardless of the uses per round of the weapon." +"SETTINGS.DisregardUsePerRoundHint": "Enabling this will allow you to fire as much as you want, regardless of the uses per round of the weapon.", +"SETTINGS.RestrictGridSpaces": "Restrict measurement to grid spaces", +"SETTINGS.RestrictGridSpacesHint": "For range combat, if selected the distances will be mesured in grid spaces, if not the 'real' (euclidean) distance will be used." } diff --git a/module/chat/helper.js b/module/chat/helper.js index 744f26fe..b42f0597 100644 --- a/module/chat/helper.js +++ b/module/chat/helper.js @@ -104,10 +104,12 @@ export class chatHelper{ static getDistance( startToken, endToken){ const ray = new Ray( startToken.center, endToken.center); + const segment = [{ray}]; const distance = { - gridUnit: ray.distance/game.scenes.active.data.grid, - value: (ray.distance/game.scenes.active.data.grid)*game.scenes.active.data.gridDistance, - unit: game.scenes.active.data.gridUnits + gridUnit: ray.distance/canvas.scene.data.grid, + // value: (ray.distance/canvas.scene.data.grid)*canvas.scene.data.gridDistance, + value: canvas.grid.measureDistances(segment, {gridSpaces:game.settings.get('CoC7', 'gridSpaces')})[0], + unit: canvas.scene.data.gridUnits }; return distance; } diff --git a/module/chat/rangecombat.js b/module/chat/rangecombat.js index fb3b1c90..fd431e3a 100644 --- a/module/chat/rangecombat.js +++ b/module/chat/rangecombat.js @@ -52,7 +52,8 @@ export class CoC7RangeInitiator{ this._targets.forEach( t =>{ if( t.token && this.token){ t.distance = chatHelper.getDistance( t.token, this.token); - const distInYd = chatHelper.toYards( t.distance); + t.distance.rounded = Math.round(t.distance.value * 100)/100; + const distInYd = Math.round(chatHelper.toYards( t.distance)* 100)/100; if( distInYd){ if( this.actor){ t.pointBlankRange = false; @@ -730,11 +731,17 @@ export class CoC7RangeTarget{ this._big = false; this._small = false; } + + get isFast(){ + if( this.actor && this.actor.mov) return this.actor.mov >= 8; + return false; + } get fast(){ if( undefined === this._fast){ - if( this.actor && this.actor.mov) this._fast = this.actor.mov >= 8; - else this._fast = false; + // if( this.actor && this.actor.mov) this._fast = this.actor.mov >= 8; + // else this._fast = false; + this._fast = false; } return this._fast; } @@ -835,5 +842,6 @@ export class CoC7RangeTarget{ else this.small = true; } else this[flag] = !this[flag]; + if( 'fast' === flag && this.fast && !this.isFast) ui.notifications.warn( `Fast selected on a target with less than 8 MOV. (MOV: ${this.actor.mov})`); } } \ No newline at end of file diff --git a/module/coc7.js b/module/coc7.js index dd1747b9..d8045da1 100644 --- a/module/coc7.js +++ b/module/coc7.js @@ -39,6 +39,14 @@ Hooks.once('init', async function() { CONFIG.Item.entityClass = CoC7Item; Combat.prototype.rollInitiative = rollInitiative; + game.settings.register('CoC7', 'gridSpaces', { + name: 'SETTINGS.RestrictGridSpaces', + hint: 'SETTINGS.RestrictGridSpacesHint', + scope: 'world', + config: true, + default: false, + type: Boolean + }); game.settings.register('CoC7', 'pulpRules', { name: 'SETTINGS.PulpRules', diff --git a/templates/chat/combat/range-initiator.html b/templates/chat/combat/range-initiator.html index 135e0009..604ff454 100644 --- a/templates/chat/combat/range-initiator.html +++ b/templates/chat/combat/range-initiator.html @@ -114,9 +114,9 @@

{{#each targets as |trgt key|}}
{{#if trgt.active}} - {{trgt.name}} + {{trgt.name}} {{else}} - {{trgt.name}} + {{trgt.name}} {{/if}}
{{/each}} @@ -143,7 +143,7 @@

data-is-blind="false" {{#unless trgt.active}}style='display: none;'{{/unless}}>
- +
@@ -345,7 +345,7 @@

data-bullets-shot="{{shot.bulletsShot}}" data-transit-bullets="{{shot.transitBullets}}" data-transit="{{shot.transit}}"> - ({{key}})Shoot {{shot.bulletsShot}} {{#if shot.transit}}+ {{shot.transitBullets}}{{/if}} bullets at target {{shot.actorName}}. + ({{key}})Shot {{shot.bulletsShot}} {{#if shot.transit}}+ {{shot.transitBullets}}{{/if}} bullets at target {{shot.actorName}}.

{{/each}} From 5daf8d2b654aed47897b8cf98be333f6ede94ff9 Mon Sep 17 00:00:00 2001 From: HavelockV Date: Sat, 19 Sep 2020 05:22:31 +0200 Subject: [PATCH 3/5] 0.3.7 readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 40342da4..940e58f9 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,13 @@ version 0.3.7 : * Typo correction on the range chat-card. * Typo correction malus->penalty. * Calculation of bullets fired was wrongly deducted from the weapon magazine. +* On the range chat-card, the fast option is not default anymore. + * When targeting a target with MOV of 8+, the fast option will not be selected by default. Instead, selecting fast for a target with MOV less thant 8 will trigger a warning. You will still be able to select it. * Added distance to target on the range chat-card. * You can now see the distance from the taget below the target selector in the chat-card and on the tooltip of the target. * Added an option to restrict measurement to grid space. * By default, for combat range calculation, the distance measured is the euclidean distance. To see that distance using the ruller you'll need to hold shift while measuring. An option is added to use grid spaces instead of euclidean distance. By selecting it, distance will be calculated as per the default ruler for that grid type (Grid less; Square, Hex...) +* Spanish translation updated thanks to Lozalojo. version 0.3.6 : From c3cb0e2eec24fcc07910c79b385a8690d492e2f9 Mon Sep 17 00:00:00 2001 From: HavelockV Date: Sat, 19 Sep 2020 05:26:40 +0200 Subject: [PATCH 4/5] Readme 0.3.7 --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 940e58f9..e67fd309 100644 --- a/README.md +++ b/README.md @@ -28,11 +28,12 @@ version 0.3.7 : * Typo correction malus->penalty. * Calculation of bullets fired was wrongly deducted from the weapon magazine. * On the range chat-card, the fast option is not default anymore. - * When targeting a target with MOV of 8+, the fast option will not be selected by default. Instead, selecting fast for a target with MOV less thant 8 will trigger a warning. You will still be able to select it. + * When targeting a target with MOV of 8+, the fast option will not be selected by default. Instead, selecting fast for a target with MOV less than 8 will trigger a warning. You will still be able to select it. * Added distance to target on the range chat-card. - * You can now see the distance from the taget below the target selector in the chat-card and on the tooltip of the target. + * Distance are calculated center of token to center of token. This may have an incidence on what the ruler display if for example your token is 2x2 on a square grid (in that case you can't put the ruler end on the center of the token). + * You can now see the distance from the target below the target selector in the chat-card and on the tool-tip of the target. * Added an option to restrict measurement to grid space. - * By default, for combat range calculation, the distance measured is the euclidean distance. To see that distance using the ruller you'll need to hold shift while measuring. An option is added to use grid spaces instead of euclidean distance. By selecting it, distance will be calculated as per the default ruler for that grid type (Grid less; Square, Hex...) + * By default, for combat range calculation, the distance measured is the euclidean distance. To see that distance using the ruler you'll need to hold shift while measuring. An option is added to use grid spaces instead of euclidean distance. By selecting it, distance will be calculated as per the default ruler for that grid type (Grid less; Square, Hex...) * Spanish translation updated thanks to Lozalojo. version 0.3.6 : From f46f33709570b233a52297f8538c414ddd96c6ca Mon Sep 17 00:00:00 2001 From: HavelockV Date: Sat, 19 Sep 2020 05:28:21 +0200 Subject: [PATCH 5/5] Readme 0.3.7 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e67fd309..c229cb39 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ version 0.3.7 : * On the range chat-card, the fast option is not default anymore. * When targeting a target with MOV of 8+, the fast option will not be selected by default. Instead, selecting fast for a target with MOV less than 8 will trigger a warning. You will still be able to select it. * Added distance to target on the range chat-card. - * Distance are calculated center of token to center of token. This may have an incidence on what the ruler display if for example your token is 2x2 on a square grid (in that case you can't put the ruler end on the center of the token). + * Distance are calculated center of token to center of token. This may have an incidence on what the ruler displays if, for example, your token is 2x2 on a square grid (in that case you can't put the ruler end on the center of the token). * You can now see the distance from the target below the target selector in the chat-card and on the tool-tip of the target. * Added an option to restrict measurement to grid space. * By default, for combat range calculation, the distance measured is the euclidean distance. To see that distance using the ruler you'll need to hold shift while measuring. An option is added to use grid spaces instead of euclidean distance. By selecting it, distance will be calculated as per the default ruler for that grid type (Grid less; Square, Hex...)