diff --git a/system/src/documents/FalloutActor.mjs b/system/src/documents/FalloutActor.mjs index 1f27cac3..e1197f33 100644 --- a/system/src/documents/FalloutActor.mjs +++ b/system/src/documents/FalloutActor.mjs @@ -2,7 +2,7 @@ export default class FalloutActor extends Actor { isSleeping = false; - constructor(object, options={}) { + constructor(object, options = {}) { super(object, options); } @@ -26,7 +26,7 @@ export default class FalloutActor extends Actor { const settlement = await fromUuid(settlementUuid); if (settlement) { if (settlement.system.leader === actor.uuid) { - await settlement.update({"system.leader": ""}); + await settlement.update({ "system.leader": "" }); settlement.sheet.render(false); } } @@ -135,7 +135,7 @@ export default class FalloutActor extends Actor { incrementJunk() { const newJunk = this.system.materials.junk + 1; - this.update({"system.materials.junk": newJunk}); + this.update({ "system.materials.junk": newJunk }); } isFieldOverridden(fieldName) { @@ -175,8 +175,11 @@ export default class FalloutActor extends Actor { prepareDerivedData() { // Make separate methods for each Actor type (character, npc, etc.) to keep // things organized. + const disableAutoDerivedStats = game.settings.get( + SYSTEM_ID, "disableAutoDerivedStats" + ); - if (this.type === "character" || this.type === "robot") { + if (!disableAutoDerivedStats && (this.type === "character" || this.type === "robot")) { this._calculateDefense(); this._calculateInitiative(); this._calculateMaxHp(); @@ -295,8 +298,8 @@ export default class FalloutActor extends Actor { let outfit = this.items.find( i => i.type === "apparel" - && i.system.apparelType === "outfit" - && i.system.equipped + && i.system.apparelType === "outfit" + && i.system.equipped ); if (outfit) { for (let [k, v] of Object.entries(outfit.system.location)) { @@ -323,8 +326,8 @@ export default class FalloutActor extends Actor { let clothing = this.items.find( i => i.type === "apparel" - && i.system.apparelType === "clothing" - && i.system.equipped + && i.system.apparelType === "clothing" + && i.system.equipped ); if (clothing) { @@ -354,14 +357,14 @@ export default class FalloutActor extends Actor { for (let [k, bodyPart] of Object.entries(this.system.body_parts)) { if (outfittedLocations[k]) { bodyPart.resistance.physical = - parseInt(outfittedLocations[k].system.resistance.physical) - + parseInt(this.system.resistance.physical); + parseInt(outfittedLocations[k].system.resistance.physical) + + parseInt(this.system.resistance.physical); bodyPart.resistance.energy = - parseInt(outfittedLocations[k].system.resistance.energy) - + parseInt(this.system.resistance.energy); + parseInt(outfittedLocations[k].system.resistance.energy) + + parseInt(this.system.resistance.energy); bodyPart.resistance.radiation = - parseInt(outfittedLocations[k].system.resistance.radiation) - + parseInt(this.system.resistance.radiation); + parseInt(outfittedLocations[k].system.resistance.radiation) + + parseInt(this.system.resistance.radiation); } else { bodyPart.resistance.physical = parseInt(this.system.resistance.physical); @@ -541,8 +544,8 @@ export default class FalloutActor extends Actor { } // ADD PLATING AND RESISTANCE BONUSES let plating = this.items.find(i => i.type === "robot_armor" - && i.system.apparelType === "plating" - && i.system.equipped + && i.system.apparelType === "plating" + && i.system.equipped ); if (plating) { @@ -550,14 +553,14 @@ export default class FalloutActor extends Actor { if (outfittedLocations[k] && v) { outfittedLocations[k].name += ` over ${plating.name}`; outfittedLocations[k].system.resistance.physical = - parseInt(outfittedLocations[k].system.resistance.physical) - + parseInt(plating.system.resistance.physical); + parseInt(outfittedLocations[k].system.resistance.physical) + + parseInt(plating.system.resistance.physical); outfittedLocations[k].system.resistance.energy = - parseInt(outfittedLocations[k].system.resistance.energy) - + parseInt(plating.system.resistance.energy); + parseInt(outfittedLocations[k].system.resistance.energy) + + parseInt(plating.system.resistance.energy); outfittedLocations[k].system.resistance.radiation = - parseInt(outfittedLocations[k].system.resistance.radiation) - + parseInt(plating.system.resistance.radiation); + parseInt(outfittedLocations[k].system.resistance.radiation) + + parseInt(plating.system.resistance.radiation); } else if (!outfittedLocations[k] && v) { outfittedLocations[k] = foundry.utils.duplicate(plating.toObject()); @@ -569,14 +572,14 @@ export default class FalloutActor extends Actor { for (let [k, bodyPart] of Object.entries(this.system.body_parts)) { if (outfittedLocations[k]) { bodyPart.resistance.physical = - parseInt(outfittedLocations[k].system.resistance.physical) - + parseInt(this.system.resistance.physical); + parseInt(outfittedLocations[k].system.resistance.physical) + + parseInt(this.system.resistance.physical); bodyPart.resistance.energy = - parseInt(outfittedLocations[k].system.resistance.energy) - + parseInt(this.system.resistance.energy); + parseInt(outfittedLocations[k].system.resistance.energy) + + parseInt(this.system.resistance.energy); bodyPart.resistance.radiation = - parseInt(outfittedLocations[k].system.resistance.radiation) - + parseInt(this.system.resistance.radiation); + parseInt(outfittedLocations[k].system.resistance.radiation) + + parseInt(this.system.resistance.radiation); } else { bodyPart.resistance.physical = parseInt(this.system.resistance.physical); @@ -779,7 +782,7 @@ export default class FalloutActor extends Actor { /** * Prepare NPC roll data. */ - _getNpcRollData(data) {} + _getNpcRollData(data) { } async _preCreate(data, options, user) { await super._preCreate(data, options, user); @@ -866,7 +869,7 @@ export default class FalloutActor extends Actor { for (const category of Object.keys(categoryTableDefaults)) { const key = `system.item_types.${category}.table`; - scavengingLocationUpdate[key] = categoryTableDefaults[category]; + scavengingLocationUpdate[key] = categoryTableDefaults[category]; } await this.updateSource(scavengingLocationUpdate); @@ -1394,7 +1397,7 @@ export default class FalloutActor extends Actor { let scenes = item.system.duration === "lasting" ? 2 : 1; - let newDosage = this.system.chemDoses[chemId]?.doses ?? 0; + let newDosage = this.system.chemDoses[chemId]?.doses ?? 0; newDosage = alreadyAddicted ? 1 : newDosage + 1; const addictionNumberExceeded = @@ -1623,7 +1626,7 @@ export default class FalloutActor extends Actor { // Reduce Ammo - async reduceAmmo(ammoName="", roundsToUse=0) { + async reduceAmmo(ammoName = "", roundsToUse = 0) { const [ammoItems, shotsAvailable] = this._getAvailableAmmoType(ammoName); if (shotsAvailable <= 0) return; @@ -1730,7 +1733,7 @@ export default class FalloutActor extends Actor { this, { title: game.i18n.localize("FALLOUT.AvailabilityRoll.result.title"), - body: game.i18n.format("FALLOUT.AvailabilityRoll.result.body", {rarity}), + body: game.i18n.format("FALLOUT.AvailabilityRoll.result.body", { rarity }), }, CONST.DICE_ROLL_MODES.PRIVATE ); diff --git a/system/src/settings.mjs b/system/src/settings.mjs index a4f62eba..f6ff1a09 100644 --- a/system/src/settings.mjs +++ b/system/src/settings.mjs @@ -222,6 +222,16 @@ export default function registerSettings() { requiresReload: true, }); + game.settings.register(SYSTEM_ID, "disableAutoDerivedStats", { + name: "Disable Auto-calculated Player Derived Stats", + hint: "By default the system will auto-calculate derived stats for player characters based on the core rulebook. Check this if would prefer to populate these values manually.", + scope: "world", + type: Boolean, + config: true, + default: false, + requiresReload: true, + }); + game.settings.register(SYSTEM_ID, "disableAutoXpReward", { name: "Disable Auto-calculated NPC XP Reward", hint: "By default the system will auto-calculate the XP reward level of an NPC based on the core rulebook. Check this if would prefer to populate these values manually.", diff --git a/system/src/sheets/FalloutPcSheet.mjs b/system/src/sheets/FalloutPcSheet.mjs index ac944913..27ba435d 100644 --- a/system/src/sheets/FalloutPcSheet.mjs +++ b/system/src/sheets/FalloutPcSheet.mjs @@ -300,6 +300,10 @@ export default class FalloutPcSheet extends FalloutBaseActorSheet { SYSTEM_ID, "disableAutoXpTarget" ); + context.disableAutoDerivedStats = game.settings.get( + SYSTEM_ID, "disableAutoDerivedStats" + ); + this._updateChemDoseManager(); // ADD FAVOURITE ITEMS diff --git a/system/templates/actor/_shared-partials/header.hbs b/system/templates/actor/_shared-partials/header.hbs index 992d26da..63b192ac 100644 --- a/system/templates/actor/_shared-partials/header.hbs +++ b/system/templates/actor/_shared-partials/header.hbs @@ -141,9 +141,11 @@ name="system.level.nextLevelXP" type="text" value="{{system.level.nextLevelXP}}" - {{#unless disableAutoXpTarget}} - data-tooltip="{{localize 'FALLOUT.Actor.Warnings.DerivedValue'}}" - disabled + {{#unless disableAutoDerivedStats}} + {{#unless disableAutoXpTarget}} + data-tooltip="{{localize 'FALLOUT.Actor.Warnings.DerivedValue'}}" + disabled + {{/unless}} {{/unless}} /> diff --git a/system/templates/actor/pc/partials/derived.hbs b/system/templates/actor/pc/partials/derived.hbs index 6fb60581..7f000ca2 100644 --- a/system/templates/actor/pc/partials/derived.hbs +++ b/system/templates/actor/pc/partials/derived.hbs @@ -8,11 +8,13 @@