diff --git a/src/module/actor/entity.js b/src/module/actor/entity.js index b6c18b2..c7552bf 100644 --- a/src/module/actor/entity.js +++ b/src/module/actor/entity.js @@ -418,6 +418,7 @@ export class OseActor extends Actor { thac0: thac0, dmg: dmgParts, save: attData.roll.save, + target: attData.roll.target }, }; @@ -576,7 +577,7 @@ export class OseActor extends Actor { let AcShield = 0; let AacShield = 0; const data = this.data.data; - data.aac.naked = baseAc + data.scores.dex.mod; + data.aac.naked = baseAac + data.scores.dex.mod; data.ac.naked = baseAc - data.scores.dex.mod; const armors = this.data.items.filter((i) => i.type == "armor"); armors.forEach((a) => { @@ -635,9 +636,6 @@ export class OseActor extends Actor { data.scores.con.value ); - data.ac.naked = 9 + data.scores.dex.mod; - data.aac.naked = 10 - data.scores.dex.mod; - const capped = { 0: -2, 3: -2, diff --git a/src/module/dice.js b/src/module/dice.js index 6692fdf..8e64225 100644 --- a/src/module/dice.js +++ b/src/module/dice.js @@ -124,14 +124,25 @@ export class OseDice { total: roll.total, }; result.target = data.roll.thac0; + + const targetAc = data.roll.target ? data.roll.target.actor.data.data.ac.value : 9; + const targetAac = data.roll.target ? data.roll.target.actor.data.data.aac.value : 0; + result.victim = data.roll.target ? data.roll.target.actor.name : null; + if (game.settings.get("ose", "ascendingAC")) { + if (roll.total < targetAac) { + result.details = game.i18n.format("OSE.messages.AttackFailure", { + bonus: result.target, + }); + return result; + } result.details = game.i18n.format("OSE.messages.AttackAscendingSuccess", { result: roll.total, }); result.isSuccess = true; } else { // B/X Historic THAC0 Calculation - if (result.target - roll.total > 9) { + if (result.target - roll.total > targetAc) { result.details = game.i18n.format("OSE.messages.AttackFailure", { bonus: result.target, }); diff --git a/src/module/item/entity.js b/src/module/item/entity.js index 8995acf..d386749 100644 --- a/src/module/item/entity.js +++ b/src/module/item/entity.js @@ -66,8 +66,31 @@ export class OseItem extends Item { rollWeapon(options = {}) { let isNPC = this.actor.data.type != "character"; + const targets = 5; const data = this.data.data; let type = isNPC ? "attack" : "melee"; + const rollData = + { + item: this.data, + actor: this.actor.data, + roll: { + save: this.data.data.save, + target: null + } + }; + + // rollAttack to target helper + const rollAttack = async (type) => { + if (game.user.targets.size > 0) { + for (let t of game.user.targets.values()) { + rollData.roll.target = t; + await this.actor.rollAttack(rollData, { type: type, skipDialog: options.skipDialog }); + } + } else { + this.actor.rollAttack(rollData, { type: type, skipDialog: options.skipDialog }); + } + }; + if (data.missile && data.melee && !isNPC) { // Dialog new Dialog({ @@ -78,32 +101,14 @@ export class OseItem extends Item { icon: '', label: "Melee", callback: () => { - this.actor.rollAttack( - { - item: this.data, - actor: this.actor.data, - roll: { - save: this.data.data.save, - }, - }, - { type: "melee", skipDialog: options.skipDialog } - ); + rollAttack("melee"); }, }, missile: { icon: '', label: "Missile", callback: () => { - this.actor.rollAttack( - { - roll: { - save: this.data.data.save, - }, - actor: this.actor.data, - item: this.data, - }, - { type: "missile", skipDialog: options.skipDialog } - ); + rollAttack("missile"); }, }, }, @@ -113,17 +118,7 @@ export class OseItem extends Item { } else if (data.missile && !isNPC) { type = "missile"; } - this.actor.rollAttack( - { - actor: this.actor.data, - item: this.data, - roll: { - save: this.data.data.save, - }, - }, - { type: type, skipDialog: options.skipDialog } - ); - + rollAttack(type); return true; } diff --git a/src/scss/apps.scss b/src/scss/apps.scss index 1055f58..f5799ff 100644 --- a/src/scss/apps.scss +++ b/src/scss/apps.scss @@ -216,6 +216,11 @@ background-size: cover; } } + .chat-target { + text-align: right; + font-style: italic; + padding: 2px; + } .chat-details { padding: 4px; font-size: 13px; diff --git a/src/template.json b/src/template.json index dff2113..6cb8e8f 100644 --- a/src/template.json +++ b/src/template.json @@ -218,7 +218,8 @@ "rollType": "result", "rollTarget": 0, "blindroll": false, - "description": "" + "description": "", + "save": "" } } } diff --git a/src/templates/chat/roll-attack.html b/src/templates/chat/roll-attack.html index 6167d41..ac74c29 100644 --- a/src/templates/chat/roll-attack.html +++ b/src/templates/chat/roll-attack.html @@ -7,6 +7,11 @@
+ {{#if result.victim}} +
+ targeting {{result.victim}} +
+ {{/if}}
{{{result.details}}}
diff --git a/src/templates/items/ability-sheet.html b/src/templates/items/ability-sheet.html index 8749bec..3529df0 100644 --- a/src/templates/items/ability-sheet.html +++ b/src/templates/items/ability-sheet.html @@ -46,6 +46,19 @@ +
+ +
+ +
+
{{editor content=data.description target="data.description" button=true