Skip to content

Commit 39a0dcc

Browse files
committed
Fix manually loading repeater weapons, fix rolling trait tests with overriden skill (or traits from data), fix enchanted staff script, fix various scripts that allow using ones as SL
close #2576 close #2572
1 parent 26f9f03 commit 39a0dcc

6 files changed

Lines changed: 41 additions & 33 deletions

File tree

scripts/Qgn92fZyc3Psn8QJ.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
if (args.test.options.useOnesAttractive && (args.test.result.roll <= game.settings.get("wfrp4e", "automaticSuccess") || args.test.result.roll <= args.test.target))
2-
{
1+
if (args.test.options.useOnesAttractive && (args.test.result.roll <= game.settings.get("wfrp4e", "automaticSuccess") || args.test.result.roll <= args.test.target)) {
32

4-
let SL = Math.floor(args.test.target / 10) - Math.floor(args.test.result.roll / 10)
5-
let ones = Number(args.test.result.roll.toString().split("").pop())
3+
let SL = Math.floor(args.test.target / 10) - Math.floor(args.test.result.roll / 10)
4+
let ones = Number(args.test.result.roll.toString().split("").pop())
65

7-
if (ones == 0)
8-
{
9-
ones = 10;
10-
}
6+
if (ones == 0) {
7+
ones = 10;
8+
}
119

12-
if (ones > SL)
13-
args.test.data.result.SL = "+" + (ones + args.test.successBonus + args.test.slBonus)
14-
args.test.result.other.push(`<b>${this.effect.name}</b>: Used unit dice as SL`)
10+
if (ones > SL) {
11+
args.test.data.result.SL = "+" + (ones + args.test.successBonus + args.test.slBonus)
12+
args.test.result.other.push(`<b>${this.effect.name}</b>: Used unit dice as SL`)
13+
}
1514
}

scripts/qu194dVXm9Vx1TGk.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
if (args.test.options.useOnesSupportive && (args.test.result.roll <= game.settings.get("wfrp4e", "automaticSuccess") || args.test.result.roll <= args.test.target))
2-
{
1+
if (args.test.options.useOnesSupportive && (args.test.result.roll <= game.settings.get("wfrp4e", "automaticSuccess") || args.test.result.roll <= args.test.target)) {
32

4-
let SL = Math.floor(args.test.target / 10) - Math.floor(args.test.result.roll / 10)
5-
let ones = Number(args.test.result.roll.toString().split("").pop())
3+
let SL = Math.floor(args.test.target / 10) - Math.floor(args.test.result.roll / 10)
4+
let ones = Number(args.test.result.roll.toString().split("").pop())
65

7-
if (ones > SL)
8-
args.test.data.result.SL = "+" + (ones + args.test.successBonus + args.test.slBonus)
9-
args.test.result.other.push(`<b>${this.effect.name}</b>: Used unit dice as SL`)
6+
if (ones > SL) {
7+
args.test.data.result.SL = "+" + (ones + args.test.successBonus + args.test.slBonus)
8+
args.test.result.other.push(`<b>${this.effect.name}</b>: Used unit dice as SL`)
9+
}
1010
}

scripts/s6eZXfZkC1My6EXl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
let lore = this.effect.name.split(" ")[2].toLowerCase();
22
if (args.item.type == "spell" && args.item.system.lore.value == lore)
33
{
4-
args.item.system.cn.value -= 1
4+
args.item.system.cn.value = Math.max(0, args.item.system.cn.value - 1);
55
}

scripts/sbK1a7txpSoXFzyB.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
if (args.test.options.useOnesArgumentative && (args.test.result.roll <= game.settings.get("wfrp4e", "automaticSuccess") || args.test.result.roll <= args.test.target))
2-
{
1+
if (args.test.options.useOnesArgumentative && (args.test.result.roll <= game.settings.get("wfrp4e", "automaticSuccess") || args.test.result.roll <= args.test.target)) {
32

4-
let SL = Math.floor(args.test.target / 10) - Math.floor(args.test.result.roll / 10)
5-
let ones = Number(args.test.result.roll.toString().split("").pop())
3+
let SL = Math.floor(args.test.target / 10) - Math.floor(args.test.result.roll / 10)
4+
let ones = Number(args.test.result.roll.toString().split("").pop())
65

7-
if (ones == 0)
8-
{
9-
ones = 10;
10-
}
6+
if (ones == 0) {
7+
ones = 10;
8+
}
119

12-
if (ones > SL)
13-
args.test.data.result.SL = "+" + (ones + args.test.successBonus + args.test.slBonus)
14-
args.test.result.other.push(`<b>${this.effect.name}</b>: Used unit dice as SL`)
10+
11+
if (ones > SL) {
12+
args.test.data.result.SL = "+" + (ones + args.test.successBonus + args.test.slBonus)
13+
args.test.result.other.push(`<b>${this.effect.name}</b>: Used unit dice as SL`)
14+
}
1515
}

src/apps/roll-dialog/trait-dialog.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,16 @@ export default class TraitDialog extends AttackDialog {
3636

3737
static async setupData(trait, actor, context={}, options={})
3838
{
39-
if (!trait.rollable.value)
39+
if (!trait.system.rollable.value)
4040
{
4141
return ui.notifications.notify("Non-rollable trait");
4242
}
4343

44+
else if (!(trait instanceof Item))
45+
{
46+
trait = new Item.implementation(trait);
47+
}
48+
4449
// TODO account for skill
4550
context.title = context.title || game.wfrp4e.config.characteristics[trait.system.rollable.rollCharacteristic] + ` ${game.i18n.localize("Test")} - ` + trait.name;
4651
context.title += context.appendTitle || "";
@@ -51,7 +56,7 @@ export default class TraitDialog extends AttackDialog {
5156
let skill
5257
if (trait.system.rollable.skill)
5358
{
54-
skill = data.actor.itemTags["skill"].find(sk => sk.name == trait.system.rollable.skill)
59+
skill = actor.itemTags["skill"].find(sk => sk.name == trait.system.rollable.skill)
5560
if (!skill)
5661
{
5762
skill = {
@@ -84,7 +89,7 @@ export default class TraitDialog extends AttackDialog {
8489
data.chargingOption = true;
8590
}
8691

87-
data.scripts = data.scripts.concat(data.trait?.getScripts("dialog").filter(s => !s.options.defending), skill?.getScripts("dialog").filter(s => !s.options.defending) || [])
92+
data.scripts = data.scripts.concat(data.trait?.getScripts("dialog").filter(s => !s.options.defending), skill?.getScripts?.("dialog").filter(s => !s.options.defending) || [])
8893

8994

9095
return dialogData;

src/model/item/weapon.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ export class WeaponModel extends PropertiesMixin(EquippableItemModel) {
225225
{
226226
loaded.value = false;
227227
}
228+
else if (loaded.amt)
229+
{
230+
loaded.value = true;
231+
}
228232

229233
if (options.changed.system?.loaded?.value)
230234
{

0 commit comments

Comments
 (0)