From d42ab07cb38cb0477e20c2fd600df74b5d0e4c0d Mon Sep 17 00:00:00 2001 From: Prototype Date: Sun, 7 Jul 2024 20:48:18 -0700 Subject: [PATCH 1/2] Ranged bonus on melee thrown weapons --- system/src/documents/ActorSD.mjs | 26 ++++++++++++++++--- system/src/documents/ItemSD.mjs | 4 +++ system/src/sheets/ActorSheetSD.mjs | 12 ++++++--- .../actors/player/abilities/attacks.hbs | 24 +++++++++++++++-- system/templates/chat/item-card.hbs | 2 +- system/templates/partials/weapon-attack.hbs | 10 +------ 6 files changed, 59 insertions(+), 19 deletions(-) diff --git a/system/src/documents/ActorSD.mjs b/system/src/documents/ActorSD.mjs index f438248aa..ca4925c29 100644 --- a/system/src/documents/ActorSD.mjs +++ b/system/src/documents/ActorSD.mjs @@ -481,8 +481,12 @@ export default class ActorSD extends Actor { itemId, }); } + // if thrown build range attack option if (await item.hasProperty("thrown")) { - weaponOptions.attackBonus = baseAttackBonus + + const thrownBaseBonus = Math.max(meleeAttack, rangedAttack); + + weaponOptions.attackBonus = thrownBaseBonus + parseInt(this.system.bonuses.rangedAttackBonus, 10) + parseInt(item.system.bonuses.attackBonus, 10) + weaponMasterBonus; @@ -494,6 +498,10 @@ export default class ActorSD extends Actor { item.system.range ]; + weaponOptions.bonusDamage += + parseInt(this.system.bonuses.rangedDamageBonus, 10) + + parseInt(item.system.bonuses.damageBonus, 10); + weaponDisplays.ranged.push({ display: await this.buildWeaponDisplay(weaponOptions), itemId, @@ -995,7 +1003,10 @@ export default class ActorSD extends Actor { data.canBackstab = await this.canBackstab(); - if (item.system.type === "melee") { + // Use set options for type of attack or assume item type + data.attackType = options.attackType ?? item.system.type; + + if (data.attackType === "melee") { if (await item.isFinesseWeapon()) { data.abilityBonus = Math.max( this.abilityModifier("str"), @@ -1011,7 +1022,16 @@ export default class ActorSD extends Actor { data.damageParts.push("@meleeDamageBonus"); } else { - data.abilityBonus = this.abilityModifier("dex"); + // if thrown item used as range, use highest modifier. + if (await item.isThrownWeapon()) { + data.abilityBonus = Math.max( + this.abilityModifier("str"), + this.abilityModifier("dex") + ); + } + else { + data.abilityBonus = this.abilityModifier("dex"); + } data.talentBonus = bonuses.rangedAttackBonus; data.rangedDamageBonus = bonuses.rangedDamageBonus * damageMultiplier; diff --git a/system/src/documents/ItemSD.mjs b/system/src/documents/ItemSD.mjs index dc613a09c..322e301da 100644 --- a/system/src/documents/ItemSD.mjs +++ b/system/src/documents/ItemSD.mjs @@ -271,6 +271,10 @@ export default class ItemSD extends Item { return this.hasProperty("finesse"); } + isThrownWeapon() { + return this.hasProperty("thrown"); + } + isMagicItem() { return this.system.isPhysical && this.system.magicItem; } diff --git a/system/src/sheets/ActorSheetSD.mjs b/system/src/sheets/ActorSheetSD.mjs index 34f4f1e17..1dd3f3ed4 100644 --- a/system/src/sheets/ActorSheetSD.mjs +++ b/system/src/sheets/ActorSheetSD.mjs @@ -237,14 +237,18 @@ export default class ActorSheetSD extends ActorSheet { event.preventDefault(); const itemId = $(event.currentTarget).data("item-id"); + const attackType = $(event.currentTarget).data("attack-type"); + + const options = { + attackType, + }; // skip roll prompt if shift clicked if (event.shiftKey) { - this.actor.rollAttack(itemId, {fastForward: true}); - } - else { - this.actor.rollAttack(itemId); + options.fastForward = true; } + + this.actor.rollAttack(itemId, options); } async _onToggleLost(event) { diff --git a/system/templates/actors/player/abilities/attacks.hbs b/system/templates/actors/player/abilities/attacks.hbs index 2e40819c0..80bda28dd 100644 --- a/system/templates/actors/player/abilities/attacks.hbs +++ b/system/templates/actors/player/abilities/attacks.hbs @@ -5,7 +5,17 @@
{{#each attacks.melee as |attack|}} -
{{{attack.display}}}
+
+ + + {{{attack.display}}} + +
{{/each}}
@@ -17,7 +27,17 @@
{{#each attacks.ranged as |attack|}} -
{{{attack.display}}}
+
+ + + {{{attack.display}}} + +
{{/each}}
diff --git a/system/templates/chat/item-card.hbs b/system/templates/chat/item-card.hbs index af9bec5a6..22f1167a0 100644 --- a/system/templates/chat/item-card.hbs +++ b/system/templates/chat/item-card.hbs @@ -121,7 +121,7 @@