ENH: Rework attack roll

master
U~man 2020-07-09 00:40:07 +02:00
parent b78de8fffc
commit 0c9282b8a5
9 changed files with 58 additions and 39 deletions

View File

@ -1,6 +1,7 @@
{
"OSE.Edit": "Edit",
"OSE.Delete": "Delete",
"OSE.Show": "Show",
"OSE.Add": "Add",
"OSE.Ok": "Ok",
"OSE.Cancel": "Cancel",
@ -150,6 +151,7 @@
"OSE.items.Slow": "Slow",
"OSE.items.ArmorAC": "AC",
"OSE.items.ArmorAAC": "AAC",
"OSE.items.Bonus": "Bonus",
"OSE.armor.type": "Armor Type",
"OSE.armor.unarmored": "Unarmored",
@ -185,6 +187,7 @@
"OSE.messages.GetExperience": "{name} gained {value} experience points!",
"OSE.messages.AttackSuccess": "<b>Hits AC {result}!</b> ({bonus})",
"OSE.messages.AttackAscendingSuccess": "<b>Hits AC {result}!</b>",
"OSE.messages.AttackFailure": "<b>Attack fails</b> ({bonus})",
"OSE.messages.InflictsDamage": "Inflicts damage!",
"OSE.ChatContextDamage": "Apply Damage",

View File

@ -72,7 +72,7 @@ export class OseActor extends Actor {
rollData: {
type: "Above",
target: this.data.data.saves[save].value,
details: game.i18n.format("OSE.SavingThrowDetails", {save: label}),
details: game.i18n.format("OSE.SavingThrowDetails", { save: label }),
},
},
};
@ -127,7 +127,9 @@ export class OseActor extends Actor {
rollData: {
type: "Check",
target: this.data.data.scores[score].value,
details: game.i18n.format("OSE.AttributeCheckDetails", {score: label}),
details: game.i18n.format("OSE.AttributeCheckDetails", {
score: label,
}),
},
},
};
@ -181,7 +183,9 @@ export class OseActor extends Actor {
rollData: {
type: "Below",
target: this.data.data.exploration[expl],
details: game.i18n.format("OSE.ExplorationCheckDetails", {expl: label}),
details: game.i18n.format("OSE.ExplorationCheckDetails", {
expl: label,
}),
},
},
};
@ -215,7 +219,10 @@ export class OseActor extends Actor {
};
let dmgParts = [];
if ((!attData.dmg || !game.settings.get("ose", "variableWeaponDamage")) && this.type == "character") {
if (
(!attData.dmg || !game.settings.get("ose", "variableWeaponDamage")) &&
this.type == "character"
) {
dmgParts.push("1d6");
} else {
dmgParts.push(attData.dmg);
@ -243,38 +250,35 @@ export class OseActor extends Actor {
const rollParts = ["1d20"];
const dmgParts = [];
if ((!attData.dmg || !game.settings.get("ose", "variableWeaponDamage")) && this.data.type == "character") {
if ((!attData.dmg || !game.settings.get("ose", "variableWeaponDamage")) &&
this.data.type == "character") {
dmgParts.push("1d6");
} else {
dmgParts.push(attData.dmg);
}
let ascending = game.settings.get("ose", "ascendingAC");
if (ascending) {
rollParts.push(data.thac0.bba.toString());
if (attData.type == "missile") {
rollParts.push(
data.scores.dex.mod.toString(),
data.thac0.mod.missile.toString()
);
} else if (attData.type == "melee") {
rollParts.push(
data.scores.str.mod.toString(),
data.thac0.mod.melee.toString()
);
}
}
let thac0 = 0;
if (attData.type == "missile") {
rollParts.push(
data.scores.dex.mod.toString(),
data.thac0.mod.missile.toString()
);
} else if (attData.type == "melee") {
rollParts.push(
data.scores.str.mod.toString(),
data.thac0.mod.melee.toString()
);
}
if (attData.bonus) {
rollParts.push(attData.bonus);
}
let thac0 = data.thac0.value;
if (attData.type == "melee") {
dmgParts.push(data.scores.str.mod);
thac0 = data.thac0.melee;
} else if (attData.type == "missile") {
thac0 = data.thac0.missile;
} else {
thac0 = data.thac0.value;
}
const rollData = {
@ -290,7 +294,7 @@ export class OseActor extends Actor {
},
};
let skip = options.event && options.event.ctrlKey;
// Roll and return
return OseDice.Roll({
event: options.event,
@ -303,7 +307,7 @@ export class OseActor extends Actor {
});
}
async applyDamage(amount=0, multiplier=1) {
async applyDamage(amount = 0, multiplier = 1) {
amount = Math.floor(parseInt(amount) * multiplier);
const hp = this.data.data.hp;
@ -312,7 +316,7 @@ export class OseActor extends Actor {
// Update the Actor
return this.update({
"data.hp.value": dh
"data.hp.value": dh,
});
}

View File

@ -112,7 +112,7 @@ export class OseDice {
};
result.target = data.rollData.thac0;
if (game.settings.get("ose", "ascendingAC")) {
result.details = game.i18n.format('OSE.messages.AttackSuccess', {result: roll.total, bonus: result.target});
result.details = game.i18n.format('OSE.messages.AttackAscendingSuccess', {result: roll.total});
result.isSuccess = true;
} else {
// B/X Historic THAC0 Calculation

View File

@ -53,14 +53,19 @@ export class OseItem extends Item {
// Dialog
new Dialog({
title: "Choose Attack Range",
content: '',
content: "",
buttons: {
melee: {
icon: '<i class="fas fa-fist-raised"></i>',
label: "Melee",
callback: () => {
this.actor.rollAttack(
{ type: "melee", label: this.name, dmg: this.data.data.damage },
{
type: "melee",
label: this.name,
dmg: this.data.data.damage,
bonus: data.bonus,
},
{ event: { ctrlKey: skipDialog } }
);
},
@ -89,7 +94,7 @@ export class OseItem extends Item {
type = "melee";
}
this.actor.rollAttack(
{ type: type, label: this.name, dmg: this.data.data.damage },
{ type: type, label: this.name, dmg: data.damage, bonus: data.bonus },
{ event: { ctrlKey: skipDialog } }
);

View File

@ -11,7 +11,7 @@
padding-right: 2px;
font-size: 13px;
.form-group {
margin: 2px;
margin: 1px;
border: 1px solid rgba(0, 0, 0, 0.15);
label {
background: rgba(0, 0, 0, 0.1);

View File

@ -166,6 +166,7 @@
"weapon": {
"description": "",
"damage": "1d6",
"bonus": 0,
"qualities": "",
"slow": false,
"missile": true,

View File

@ -54,8 +54,8 @@
</div>
<div class="item-controls">
{{#if ../owner}}
<a class="item-control item-edit" title='{{localize "Ose.Edit"}}'><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title='{{localize "Ose.Delete"}}'><i class="fas fa-trash"></i></a>
<a class="item-control item-edit" title='{{localize "OSE.Edit"}}'><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title='{{localize "OSE.Delete"}}'><i class="fas fa-trash"></i></a>
{{/if}}
</div>
</div>

View File

@ -160,8 +160,8 @@
</div>
{{else}}
<div class="attribute-value"
title="{{localize 'OSE.Thac0'}}({{data.thac0.value}}) - {{localize 'OSE.scores.str.long'}}({{data.scores.str.mod}}) - {{localize 'OSE.Modifier'}}({{data.thac0.mod.melee}})">
{{data.thac0.melee}}
title="{{localize 'OSE.scores.str.long'}}({{data.scores.str.mod}}) + {{localize 'OSE.Modifier'}}({{data.thac0.mod.melee}})">
{{add data.scores.str.mod data.thac0.mod.melee}}
</div>
{{/if}}
</div>
@ -200,8 +200,8 @@
</div>
{{else}}
<div class="attribute-value"
title="{{localize 'OSE.Thac0'}}({{data.thac0.value}}) - {{localize 'OSE.scores.dex.long'}}({{data.scores.dex.mod}}) - {{localize 'OSE.Modifier'}}({{data.thac0.mod.missile}})">
{{data.thac0.missile}}
title="{{localize 'OSE.scores.dex.long'}}({{data.scores.dex.mod}}) + {{localize 'OSE.Modifier'}}({{data.thac0.mod.missile}})">
{{add data.scores.dex.mod data.thac0.mod.missile}}
</div>
{{/if}}
</div>

View File

@ -19,6 +19,12 @@
<input type="text" name="data.damage" value="{{data.damage}}" data-dtype="String" />
</div>
</div>
<div class="form-group">
<label>{{localize 'OSE.items.Bonus'}}</label>
<div class="form-fields">
<input type="text" name="data.bonus" value="{{data.bonus}}" data-dtype="Number" />
</div>
</div>
<div class="form-group">
<label>{{localize 'OSE.items.Slow'}}</label>
<div class="form-fields">