diff --git a/src/lang/en.json b/src/lang/en.json
index e947c39..db99edc 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -88,6 +88,7 @@
"OSE.InitiativeShort": "INIT",
"OSE.Attacks": "Attacks Usable per Round",
"OSE.AttacksShort": "ATT",
+ "OSE.Damage": "Damage",
"OSE.Spellcaster": "Spellcaster",
"OSE.SpokenLanguages": "Spoken Languages",
diff --git a/src/module/actor/entity.js b/src/module/actor/entity.js
index d09a4e3..707b38d 100644
--- a/src/module/actor/entity.js
+++ b/src/module/actor/entity.js
@@ -104,6 +104,44 @@ export class OseActor extends Actor {
});
}
+ rollDamage(attData, options = {}) {
+ const data = this.data.data;
+
+ const rollData = {
+ ...this.data,
+ ...{
+ rollData: {
+ type: "Damage",
+ stat: attData.type,
+ scores: data.scores
+ },
+ },
+ };
+
+ let dmgParts = [];
+ if (!attData.dmg || !game.settings.get('ose', 'variableWeaponDamage')) {
+ dmgParts.push("1d6");
+ } else {
+ dmgParts.push(attData.dmg);
+ }
+
+ // Add Str to damage
+ if (attData.type == 'melee') {
+ dmgParts.push("+", data.scores.str.mod);
+ }
+
+ // Damage roll
+ OseDice.Roll({
+ event: options.event,
+ parts: dmgParts,
+ data: rollData,
+ skipDialog: true,
+ speaker: ChatMessage.getSpeaker({ actor: this }),
+ flavor: `${attData.label} - ${game.i18n.localize("OSE.Damage")}`,
+ title: `${attData.label} - ${game.i18n.localize("OSE.Damage")}`,
+ })
+ }
+
rollAttack(attData, options = {}) {
const rollParts = ["1d20"];
const data = this.data.data;
@@ -133,7 +171,7 @@ export class OseActor extends Actor {
rollData: {
type: "Attack",
stat: attData.type,
- scores: data.scores,
+ scores: data.scores
},
},
};
@@ -145,6 +183,8 @@ export class OseActor extends Actor {
speaker: ChatMessage.getSpeaker({ actor: this }),
flavor: `${attData.label} - ${game.i18n.localize("OSE.Attack")}`,
title: `${attData.label} - ${game.i18n.localize("OSE.Attack")}`,
+ }).then(() => {
+ this.rollDamage(attData, {});
});
}
diff --git a/src/module/dice.js b/src/module/dice.js
index a6766c1..4444fa5 100644
--- a/src/module/dice.js
+++ b/src/module/dice.js
@@ -29,7 +29,11 @@ export class OseDice {
if (thac - roll.total > 9) {
return details;
}
- details = `
Hits AC ${Math.clamped(thac - roll.total,-3,9)} (${thac})
`;
+ details = `Hits AC ${Math.clamped(
+ thac - roll.total,
+ -3,
+ 9
+ )} (${thac})
`;
// ADD DAMAGE ROLL
}
} else if (data.rollData.type == "Save") {
@@ -60,14 +64,14 @@ export class OseDice {
return details;
}
- static async sendRoll(
+ static async sendRoll({
parts = [],
data = {},
title = null,
flavor = null,
speaker = null,
- form = null
- ) {
+ form = null,
+ } = {}) {
const template = "systems/ose/templates/chat/roll-attack.html";
let chatData = {
@@ -80,7 +84,7 @@ export class OseDice {
flavor: flavor,
data: data,
};
-
+
// Optionally include a situational bonus
if (form !== null) data["bonus"] = form.bonus.value;
if (data["bonus"]) parts.push(data["bonus"]);
@@ -92,36 +96,42 @@ export class OseDice {
rollMode = form ? form.rollMode.value : rollMode;
templateData.details = OseDice.digestResult(data, roll);
- roll.render().then((r) => {
- templateData.rollOSE = r;
- renderTemplate(template, templateData).then((content) => {
- chatData.content = content;
- chatData.sound = CONFIG.sounds.dice;
- if (game.dice3d) {
- game.dice3d
- .showForRoll(
- roll,
- game.user,
- true,
- chatData.whisper,
- chatData.blind
- )
- .then((displayed) => ChatMessage.create(chatData));
- } else {
- ChatMessage.create(chatData);
- }
+
+ return new Promise((resolve) => {
+ roll.render().then((r) => {
+ templateData.rollOSE = r;
+ renderTemplate(template, templateData).then((content) => {
+ chatData.content = content;
+ // Dice So Nice
+ if (game.dice3d) {
+ game.dice3d
+ .showForRoll(
+ roll,
+ game.user,
+ true,
+ chatData.whisper,
+ chatData.blind
+ )
+ .then((displayed) => {
+ ChatMessage.create(chatData);
+ resolve();
+ });
+ } else {
+ chatData.sound = CONFIG.sounds.dice;
+ ChatMessage.create(chatData);
+ resolve();
+ }
+ });
});
});
-
- return roll;
}
- // eslint-disable-next-line no-unused-vars
static async Roll({
parts = [],
data = {},
options = {},
event = null,
+ skipDialog = false,
speaker = null,
flavor = null,
title = null,
@@ -143,14 +153,14 @@ export class OseDice {
label: game.i18n.localize("OSE.Roll"),
icon: '',
callback: (html) => {
- roll = OseDice.sendRoll(
- parts,
- data,
- title,
- flavor,
- speaker,
- html[0].children[0]
- );
+ roll = OseDice.sendRoll({
+ parts: parts,
+ data: data,
+ title: title,
+ flavor: flavor,
+ speaker: speaker,
+ form: html[0].children[0],
+ });
},
},
cancel: {
@@ -159,7 +169,15 @@ export class OseDice {
},
};
- if (!item) delete buttons.raise;
+ if (skipDialog) {
+ return OseDice.sendRoll({
+ parts,
+ data,
+ title,
+ flavor,
+ speaker,
+ });
+ }
const html = await renderTemplate(template, dialogData);
let roll;
diff --git a/src/module/item/entity.js b/src/module/item/entity.js
index 2882b9e..35eed8c 100644
--- a/src/module/item/entity.js
+++ b/src/module/item/entity.js
@@ -49,9 +49,9 @@ export class OseItem extends Item {
rollWeapon() {
if (this.data.data.missile) {
- this.actor.rollAttack({type: 'missile', label: this.name});
+ this.actor.rollAttack({type: 'missile', label: this.name, dmg: this.data.data.damage});
} else if (this.data.data.melee) {
- this.actor.rollAttack({type: 'melee', label: this.name});
+ this.actor.rollAttack({type: 'melee', label: this.name, dmg: this.data.data.damage});
} else {
this.actor.rollAttack({type: 'raw', label: this.name});
}