Skip to content

Commit

Permalink
Merge pull request #832 from Muttley/815-thrown-weapon-update
Browse files Browse the repository at this point in the history
Implemented ranged bonuses on melee thrown weapons
  • Loading branch information
Muttley authored Jul 8, 2024
2 parents 18f5a47 + fa380e7 commit cf1ac81
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 24 deletions.
11 changes: 6 additions & 5 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@
* [#740] Holding shift now rolls some rolls without a prompt
* [#769] UI has been updated

- User interface has been redesigned with a new look and feel.
- Character inventory supports drag and drop reordering.
- Holding shift while clicking on a rollable links will bypass the roll prompt, rolling with unmodified values.
- User interface has been redesigned with a new look and feel
- Character inventory now supports drag and drop reordering of items
- Holding shift while clicking on a rollable link will bypass the roll prompt, rolling with normal values

* [#798] Allow for tokens and combat tracker to display dynamic AC

- `system.attributes.ac.value` now always holds the current AC

* [#820] All ability scores now store a total value of bast stats + modifiers e.g. system.abilities.str.total
* [#820] All ability scores now store a total value of base stats + modifiers. e.g. `system.abilities.str.total`

## Bugfixes
* [#809] Add new `grid.distance` and `grid.units` values to `system.json` *(Foundry V12 compatibility)*
* [#811] `description` typo in `system.json`
* [#814] The roll initiative button on the player sheet will no longer double roll when re-rolling initiative
* [#816] Updated Ranger Herbalism talent description to the latest version
* [#822] The spellbook now works for Knight of St. Ydris and other such classes using another class's spell lists.
* [#822] The spellbook now works for Knight of St. Ydris and other classes that use another class's spell list
* [#832] Melee weapons with the "Thrown" property now rolling correctly when used as a ranged attack
* [#835] Update Sleep spell description to the latest version

## Chores
Expand Down
26 changes: 23 additions & 3 deletions system/src/documents/ActorSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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"),
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions system/src/documents/ItemSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 8 additions & 4 deletions system/src/sheets/ActorSheetSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
24 changes: 22 additions & 2 deletions system/templates/actors/player/abilities/attacks.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@
</div>
<div class="content">
{{#each attacks.melee as |attack|}}
<div>{{{attack.display}}}</div>
<div>
<a
class="rollable"
data-action="item-attack"
data-item-id="{{attack.itemId}}"
data-attack-type="melee"
>
<i class="fa-solid fa-dice-d20"></i>
{{{attack.display}}}
</a>
</div>
{{/each}}
</div>
</div>
Expand All @@ -17,7 +27,17 @@
</div>
<div class="content">
{{#each attacks.ranged as |attack|}}
<div>{{{attack.display}}}</div>
<div>
<a
class="rollable"
data-action="item-attack"
data-item-id="{{attack.itemId}}"
data-attack-type="ranged"
>
<i class="fa-solid fa-dice-d20"></i>
{{{attack.display}}}
</a>
</div>
{{/each}}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion system/templates/chat/item-card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<ul class="tags">
<li class="tag tag_secondary tag_small">
{{localize "SHADOWDARK.item.weapon_type"}}:
{{fromConfig "WEAPON_TYPES" data.item.system.type}}
{{fromConfig "WEAPON_TYPES" data.attackType}}
</li>
<li class="tag tag_secondary tag_small">
{{localize "SHADOWDARK.item.weapon_range"}}:
Expand Down
10 changes: 1 addition & 9 deletions system/templates/partials/weapon-attack.hbs
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<a
class="rollable"
data-action="item-attack"
data-item-id="{{weaponId}}"
>
<i class="fa-solid fa-dice-d20"></i>
<b style="font-size:16px">{{weaponName}}</b>

<b style="font-size:16px">{{weaponName}}</b>
({{handedness}}),
{{numberFormat attackBonus decimals=0 sign=true}}
({{attackRange}}),
{{baseDamage}}{{#ifCond bonusDamage '!=' 0}}{{numberFormat bonusDamage decimals=0 sign=true}}{{/ifCond}}{{#ifCond extraDamageDice '!==' ''}}+{{extraDamageDice}}{{/ifCond}}{{#ifCond properties '!==' ''}}, {{properties}}{{/ifCond}}
</a>

0 comments on commit cf1ac81

Please sign in to comment.