Skip to content

Commit ea4a373

Browse files
authored
Merge pull request #504 from apewall/fix-thac0-results
Fix: Return proper thac0 attack results when there is no target
2 parents 3ff050b + 0499524 commit ea4a373

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/module/helpers-dice.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,13 @@ const OseDice = {
209209
result.target = data.roll.thac0;
210210
const targetActorData = data.roll.target?.actor?.system || null;
211211

212-
const targetAc = data.roll.target ? targetActorData.ac.value : 20;
213-
const targetAac = data.roll.target ? targetActorData.aac.value : -20;
212+
const targetAc = data.roll.target ? targetActorData.ac.value : 9;
213+
const targetAac = data.roll.target ? targetActorData.aac.value : 10;
214214
result.victim = data.roll.target || null;
215215

216216
if (game.settings.get(game.system.id, "ascendingAC")) {
217-
const attackBonus = 0;
218-
if (this.attackIsSuccess(roll, targetAac, attackBonus)) {
217+
const attackBonus = 19 - data.roll.thac0;
218+
if (this.attackIsSuccess(roll, targetAac, attackBonus) || result.victim == null) {
219219
result.details = game.i18n.format(
220220
"OSE.messages.AttackAscendingSuccess",
221221
{
@@ -232,9 +232,9 @@ const OseDice = {
232232
);
233233
result.isFailure = true;
234234
}
235-
} else if (this.attackIsSuccess(roll, result.target, targetAc)) {
236-
// Answer is bounded betweewn AC -3 and 9 (unarmored) and is shown in chat card
237-
const value = Math.clamp(result.target - roll.total, -3, 9);
235+
} else if (this.attackIsSuccess(roll, result.target, targetAc) || result.victim == null) {
236+
// Show result in chat card
237+
const value = result.target - roll.total;
238238
result.details = game.i18n.format("OSE.messages.AttackSuccess", {
239239
result: value,
240240
bonus: result.target,

0 commit comments

Comments
 (0)