FIX: Monster rolls
parent
573c9fe23c
commit
ebcdcc8465
|
@ -51,8 +51,6 @@ export class OseActorSheetCharacter extends OseActorSheet {
|
|||
data.config.ascendingAC = game.settings.get("ose", "ascendingAC");
|
||||
data.config.individualInit = game.settings.get("ose", "individualInit");
|
||||
|
||||
data.mods = this.actor.computeModifiers();
|
||||
|
||||
// Compute treasure
|
||||
let total = 0;
|
||||
data.owned.items.forEach(item => {
|
||||
|
|
|
@ -9,12 +9,14 @@ export class OseActor extends Actor {
|
|||
super.prepareData();
|
||||
const data = this.data.data;
|
||||
|
||||
// Compute modifiers from actor scores
|
||||
this.computeModifiers();
|
||||
|
||||
// Determine Initiative
|
||||
if (game.settings.get("ose", "individualInit")) {
|
||||
data.initiative.value = data.initiative.mod;
|
||||
if (this.data.type == "character") {
|
||||
const mods = this.computeModifiers();
|
||||
data.initiative.value += mods.dex;
|
||||
data.initiative.value += data.scores.dex.mod;
|
||||
}
|
||||
} else {
|
||||
data.initiative.value = 0;
|
||||
|
@ -105,111 +107,101 @@ export class OseActor extends Actor {
|
|||
rollAttack(attack, options = {}) {
|
||||
const label = game.i18n.localize(`OSE.${attack}`);
|
||||
const rollParts = ["1d20"];
|
||||
const data = this.data.data;
|
||||
|
||||
const mods = this.computeModifiers();
|
||||
if (attack == "Missile") {
|
||||
rollParts.push(
|
||||
"+",
|
||||
mods.dex.toString(),
|
||||
data.scores.dex.mod.toString(),
|
||||
"+",
|
||||
this.data.data.thac0.mod.missile.toString()
|
||||
data.thac0.mod.missile.toString()
|
||||
);
|
||||
} else if (attack == "Melee") {
|
||||
rollParts.push(
|
||||
"+",
|
||||
mods.str.toString(),
|
||||
data.scores.str.mod.toString(),
|
||||
"+",
|
||||
this.data.data.thac0.mod.melee.toString()
|
||||
data.thac0.mod.melee.toString()
|
||||
);
|
||||
}
|
||||
if (game.settings.get("ose", "ascendingAC")) {
|
||||
rollParts.push("+", this.data.data.thac0.bba.toString());
|
||||
}
|
||||
|
||||
const data = {
|
||||
const rollData = {
|
||||
...this.data,
|
||||
...{
|
||||
rollData: {
|
||||
type: "Attack",
|
||||
stat: attack,
|
||||
mods: mods,
|
||||
scores: data.scores,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// Roll and return
|
||||
return OseDice.Roll({
|
||||
event: options.event,
|
||||
parts: rollParts,
|
||||
data: data,
|
||||
data: rollData,
|
||||
speaker: ChatMessage.getSpeaker({ actor: this }),
|
||||
flavor: `${label} ${game.i18n.localize("OSE.Attack")}`,
|
||||
title: `${label} ${game.i18n.localize("OSE.Attack")}`,
|
||||
});
|
||||
}
|
||||
|
||||
static _valueToMod(val) {
|
||||
switch (val) {
|
||||
case 3:
|
||||
return -3;
|
||||
case 4:
|
||||
case 5:
|
||||
return -2;
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
return -1;
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
return 0;
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
return 1;
|
||||
case 16:
|
||||
case 17:
|
||||
return 2;
|
||||
case 18:
|
||||
return 3;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static _cappedMod(val) {
|
||||
let mod = OseActor._valueToMod(val);
|
||||
if (mod > 1) {
|
||||
mod -= 1;
|
||||
} else if (mod < -1) {
|
||||
mod += 1;
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
computeModifiers() {
|
||||
if (this.data.type != "character") {
|
||||
return {
|
||||
str: 0,
|
||||
dex: 0,
|
||||
int: 0,
|
||||
con: 0,
|
||||
wis: 0,
|
||||
cha: 0,
|
||||
npc: 0,
|
||||
init: 0,
|
||||
};
|
||||
return;
|
||||
}
|
||||
let _valueToMod = (val) => {
|
||||
switch (val) {
|
||||
case 3:
|
||||
return -3;
|
||||
case 4:
|
||||
case 5:
|
||||
return -2;
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
return -1;
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
return 0;
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
return 1;
|
||||
case 16:
|
||||
case 17:
|
||||
return 2;
|
||||
case 18:
|
||||
return 3;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
let mods = {
|
||||
str: _valueToMod(this.data.data.scores.str.value),
|
||||
int: _valueToMod(this.data.data.scores.int.value),
|
||||
dex: _valueToMod(this.data.data.scores.dex.value),
|
||||
init: _valueToMod(this.data.data.scores.dex.value),
|
||||
cha: _valueToMod(this.data.data.scores.cha.value),
|
||||
npc: _valueToMod(this.data.data.scores.cha.value),
|
||||
wis: _valueToMod(this.data.data.scores.wis.value),
|
||||
con: _valueToMod(this.data.data.scores.con.value),
|
||||
};
|
||||
if (mods.init > 1) {
|
||||
mods.init -= 1;
|
||||
} else if (mods.init < -1) {
|
||||
mods.init += 1;
|
||||
}
|
||||
if (mods.npc > 1) {
|
||||
mods.npc -= 1;
|
||||
} else if (mods.npc < -1) {
|
||||
mods.npc += 1;
|
||||
}
|
||||
return mods;
|
||||
const data = this.data.data;
|
||||
data.scores.str.mod = OseActor._valueToMod(this.data.data.scores.str.value);
|
||||
data.scores.int.mod = OseActor._valueToMod(this.data.data.scores.int.value);
|
||||
data.scores.dex.mod = OseActor._valueToMod(this.data.data.scores.dex.value);
|
||||
data.scores.cha.mod = OseActor._valueToMod(this.data.data.scores.cha.value);
|
||||
data.scores.wis.mod = OseActor._valueToMod(this.data.data.scores.wis.value);
|
||||
data.scores.con.mod = OseActor._valueToMod(this.data.data.scores.con.value);
|
||||
|
||||
data.scores.dex.init = OseActor._cappedMod(this.data.data.scores.dex.value);
|
||||
data.scores.cha.npc = OseActor._cappedMod(this.data.data.scores.cha.value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
export class OseDice {
|
||||
static digestResult(data, roll) {
|
||||
let details = "";
|
||||
|
||||
// ATTACKS
|
||||
let die = roll.parts[0].total;
|
||||
if (data.rollData.type == "Attack") {
|
||||
if (game.settings.get("ose", "ascendingAC")) {
|
||||
let bba = data.data.thac0.bba;
|
||||
bba +=
|
||||
data.rollData.stat == "Melee"
|
||||
? data.data.thac0.mod.melee + data.rollData.mods.str
|
||||
: data.data.thac0.mod.missile + data.rollData.mods.dex;
|
||||
if (data.rollData.stat == "Melee") {
|
||||
bba += data.data.thac0.mod.melee + data.rollData.scores.str.mod;
|
||||
} else if (data.rollData.stat == "Missile") {
|
||||
bba += data.data.thac0.mod.missile + data.rollData.scores.dex.mod;
|
||||
}
|
||||
|
||||
details = `<div class='roll-result roll-fail'><b>Failure</b> (${bba})</div>`;
|
||||
if (die == 1) {
|
||||
return details;
|
||||
|
@ -19,11 +20,11 @@ export class OseDice {
|
|||
} else {
|
||||
// B/X Historic THAC0 Calculation
|
||||
let thac = data.data.thac0.value;
|
||||
thac -=
|
||||
data.rollData.stat == "Melee"
|
||||
? data.data.thac0.mod.melee + data.rollData.mods.str
|
||||
: data.data.thac0.mod.missile + data.rollData.mods.dex;
|
||||
|
||||
if (data.rollData.stat == "Melee") {
|
||||
thac -= data.data.thac0.mod.melee + data.rollData.scores.str.mod;
|
||||
} else if (data.rollData.stat == "Missile") {
|
||||
thac -= data.data.thac0.mod.missile + data.rollData.scores.dex.mod;
|
||||
}
|
||||
details = `<div class='roll-result roll-fail'><b>Failure</b> (${thac})</div>`;
|
||||
if (thac - roll.total > 9) {
|
||||
return details;
|
||||
|
|
|
@ -54,6 +54,8 @@ export class OseItem extends Item {
|
|||
} else if (this.data.data.melee) {
|
||||
this.actor.rollAttack('Melee');
|
||||
return true;
|
||||
} else {
|
||||
this.actor.rollAttack();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -84,6 +86,7 @@ export class OseItem extends Item {
|
|||
* @return {Promise}
|
||||
*/
|
||||
async roll({ configureDialog = true } = {}) {
|
||||
console.log(this.data);
|
||||
if (this.data.type == 'weapon') {
|
||||
if (this.rollWeapon()) return;
|
||||
}
|
||||
|
|
|
@ -72,8 +72,7 @@
|
|||
position: absolute;
|
||||
transform: rotate(90deg);
|
||||
top: 365px;
|
||||
right: -168px;
|
||||
border-bottom: 1px solid black;
|
||||
right: -169px;
|
||||
width: 320px;
|
||||
z-index: -1;
|
||||
.item {
|
||||
|
|
|
@ -97,27 +97,27 @@
|
|||
"scores": {
|
||||
"str": {
|
||||
"value": 0,
|
||||
"mod": 0
|
||||
"bonus": 0
|
||||
},
|
||||
"int": {
|
||||
"value": 0,
|
||||
"mod": 0
|
||||
"bonus": 0
|
||||
},
|
||||
"wis": {
|
||||
"value": 0,
|
||||
"mod": 0
|
||||
"bonus": 0
|
||||
},
|
||||
"dex": {
|
||||
"value": 0,
|
||||
"mod": 0
|
||||
"bonus": 0
|
||||
},
|
||||
"con": {
|
||||
"value": 0,
|
||||
"mod": 0
|
||||
"bonus": 0
|
||||
},
|
||||
"cha": {
|
||||
"value": 0,
|
||||
"mod": 0
|
||||
"bonus": 0
|
||||
}
|
||||
},
|
||||
"encumbrance": {
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
|
||||
</div>
|
||||
<div class="attribute-bonuses">
|
||||
{{localize 'OSE.Melee'}} ({{mods.str}})<br/>
|
||||
{{localize 'OSE.Melee'}} ({{data.scores.str.mod}})<br/>
|
||||
{{localize 'OSE.exploration.od.long'}}
|
||||
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
|
||||
</div>
|
||||
|
@ -39,7 +39,7 @@
|
|||
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
|
||||
</div>
|
||||
<div class="attribute-bonuses">
|
||||
{{localize 'OSE.saves.magic.long'}}({{mods.wis}})
|
||||
{{localize 'OSE.saves.magic.long'}}({{data.scores.wis.mod}})
|
||||
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
|
||||
</div>
|
||||
</li>
|
||||
|
@ -52,9 +52,9 @@
|
|||
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
|
||||
</div>
|
||||
<div class="attribute-bonuses">
|
||||
{{localize 'OSE.Missile'}} ({{mods.dex}})<br/>
|
||||
{{localize 'OSE.Initiative'}} ({{mods.init}})<br/>
|
||||
{{localize 'OSE.ArmorClass'}} ({{mods.dex}})
|
||||
{{localize 'OSE.Missile'}} ({{data.scores.dex.mod}})<br/>
|
||||
{{localize 'OSE.Initiative'}} ({{data.scores.dex.init}})<br/>
|
||||
{{localize 'OSE.ArmorClass'}} ({{data.scores.dex.mod}})
|
||||
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
|
||||
</div>
|
||||
</li>
|
||||
|
@ -67,7 +67,7 @@
|
|||
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
|
||||
</div>
|
||||
<div class="attribute-bonuses">
|
||||
{{localize 'OSE.Health'}} ({{mods.con}})
|
||||
{{localize 'OSE.Health'}} ({{data.scores.con.mod}})
|
||||
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
|
||||
</div>
|
||||
</li>
|
||||
|
@ -80,9 +80,9 @@
|
|||
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
|
||||
</div>
|
||||
<div class="attribute-bonuses">
|
||||
{{localize 'OSE.NPCReaction'}} ({{mods.npc}})<br/>
|
||||
{{localize 'OSE.RetainersMax'}} ({{add mods.cha 4}})<br/>
|
||||
{{localize 'OSE.Loyalty'}} ({{add mods.cha 7}})
|
||||
{{localize 'OSE.NPCReaction'}} ({{data.scores.cha.npc}})<br/>
|
||||
{{localize 'OSE.RetainersMax'}} ({{add data.scores.cha.mod 4}})<br/>
|
||||
{{localize 'OSE.Loyalty'}} ({{add data.scores.cha.mod 7}})
|
||||
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
|
||||
</div>
|
||||
</li>
|
||||
|
@ -114,12 +114,12 @@
|
|||
{{#if config.ascendingAC}}
|
||||
<input class="health-top" name="data.aac.value" type="text" value="{{data.aac.value}}"
|
||||
data-dtype="Number" placeholder="0" title="{{localize 'OSE.ArmorClass'}}" />
|
||||
<input class="health-bottom" type="text" value="{{add 10 mods.dex}}"
|
||||
<input class="health-bottom" type="text" value="{{add 10 data.scores.dex.mod}}"
|
||||
title="{{localize 'OSE.ArmorClassNaked'}}" disabled />
|
||||
{{else}}
|
||||
<input class="health-top" name="data.ac.value" type="text" value="{{data.ac.value}}" data-dtype="Number"
|
||||
placeholder="0" title="{{localize 'OSE.ArmorClass'}}" />
|
||||
<input class="health-bottom" type="text" value="{{subtract mods.dex 9}}"
|
||||
<input class="health-bottom" type="text" value="{{subtract data.scores.dex.mod 9}}"
|
||||
title="{{localize 'OSE.ArmorClass'}}" disabled />
|
||||
{{/if}}
|
||||
</div>
|
||||
|
@ -140,8 +140,8 @@
|
|||
<h4 class="attribute-name box-title" title="{{ localize 'OSE.Initiative' }}">
|
||||
{{ localize "OSE.InitiativeShort" }}</h4>
|
||||
<div class="attribute-value"
|
||||
title="{{localize 'OSE.scores.dex.long'}}({{mods.init}}) + {{localize 'OSE.Modifier'}}({{data.initiative.mod}})">
|
||||
{{add mods.init data.initiative.mod}}
|
||||
title="{{localize 'OSE.scores.dex.long'}}({{data.scores.dex.init}}) + {{localize 'OSE.Modifier'}}({{data.initiative.mod}})">
|
||||
{{add data.scores.dex.init data.initiative.mod}}
|
||||
</div>
|
||||
</li>
|
||||
{{/if}}
|
||||
|
@ -155,13 +155,13 @@
|
|||
<div class="flexrow">
|
||||
{{#if config.ascendingAC}}
|
||||
<div class="attribute-value"
|
||||
title="{{localize 'OSE.AB'}}({{data.thac0.bba}}) + {{localize 'OSE.scores.str.long'}}({{mods.str}}) + {{localize 'OSE.Modifier'}}({{data.thac0.mod.melee}})">
|
||||
{{add data.thac0.mod.melee (add mods.str data.thac0.bba)}}
|
||||
title="{{localize 'OSE.AB'}}({{data.thac0.bba}}) + {{localize 'OSE.scores.str.long'}}({{data.scores.str.mod}}) + {{localize 'OSE.Modifier'}}({{data.thac0.mod.melee}})">
|
||||
{{add data.thac0.mod.melee (add data.scores.str.mod data.thac0.bba)}}
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="attribute-value"
|
||||
title="{{localize 'OSE.Thac0'}}({{data.thac0.value}}) - {{localize 'OSE.scores.str.long'}}({{mods.str}}) - {{localize 'OSE.Modifier'}}({{data.thac0.mod.melee}})">
|
||||
{{subtract data.thac0.mod.melee (subtract mods.str data.thac0.value)}}
|
||||
title="{{localize 'OSE.Thac0'}}({{data.thac0.value}}) - {{localize 'OSE.scores.str.long'}}({{data.scores.str.mod}}) - {{localize 'OSE.Modifier'}}({{data.thac0.mod.melee}})">
|
||||
{{subtract data.thac0.mod.melee (subtract data.scores.str.mod data.thac0.value)}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
@ -195,13 +195,13 @@
|
|||
<div class="flexrow">
|
||||
{{#if config.ascendingAC}}
|
||||
<div class="attribute-value"
|
||||
title="{{localize 'OSE.AB'}}({{data.thac0.bba}}) + {{localize 'OSE.scores.dex.long'}}({{mods.dex}}) + {{localize 'OSE.Modifier'}}({{data.thac0.mod.missile}})">
|
||||
{{add data.thac0.mod.missile (add mods.dex data.thac0.bba)}}
|
||||
title="{{localize 'OSE.AB'}}({{data.thac0.bba}}) + {{localize 'OSE.scores.dex.long'}}({{data.scores.dex.mod}}) + {{localize 'OSE.Modifier'}}({{data.thac0.mod.missile}})">
|
||||
{{add data.thac0.mod.missile (add data.scores.dex.mod data.thac0.bba)}}
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="attribute-value"
|
||||
title="{{localize 'OSE.Thac0'}}({{data.thac0.value}}) - {{localize 'OSE.scores.dex.long'}}({{mods.dex}}) - {{localize 'OSE.Modifier'}}({{data.thac0.mod.missile}})">
|
||||
{{subtract data.thac0.mod.missile (subtract mods.dex data.thac0.value)}}
|
||||
title="{{localize 'OSE.Thac0'}}({{data.thac0.value}}) - {{localize 'OSE.scores.dex.long'}}({{data.scores.dex.mod}}) - {{localize 'OSE.Modifier'}}({{data.thac0.mod.missile}})">
|
||||
{{subtract data.thac0.mod.missile (subtract data.scores.dex.mod data.thac0.value)}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
@ -280,8 +280,8 @@
|
|||
<li class="attribute saving-throw">
|
||||
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.magic.long' }}">
|
||||
{{ localize "OSE.saves.magic.long"}}</h4>
|
||||
<div class="attribute-value flat" title="{{localize 'OSE.scores.wis.long'}}({{mods.wis}})">
|
||||
{{mods.wis}}
|
||||
<div class="attribute-value flat" title="{{localize 'OSE.scores.wis.long'}}({{data.scores.wis.mod}})">
|
||||
{{data.scores.wis.mod}}
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
</div>
|
||||
{{/if}}
|
||||
</li>
|
||||
<li class="attribute attack" data-attack="Melee">
|
||||
<li class="attribute attack" data-attack="Attack">
|
||||
{{#if config.ascendingAC}}
|
||||
<h4 class="attribute-name box-title" title="{{localize 'OSE.AB'}}"><a>{{ localize "OSE.ABShort" }}</a></h4>
|
||||
<div class="attribute-value">
|
||||
|
@ -130,7 +130,7 @@
|
|||
<div class="attribute-group">
|
||||
<div class="attacks-description">
|
||||
<label>{{ localize "OSE.Attacks" }}</label>
|
||||
<input name="data.att" type="text" value="{{data.att}}" placeholder="0" data-dtype="String" />
|
||||
<input name="data.att" type="text" value="{{data.att}}" data-dtype="String" />
|
||||
</div>
|
||||
<ul class="attributes">
|
||||
<li class="attribute saving-throw" data-save="death">
|
||||
|
|
Loading…
Reference in New Issue