forked from GitHub-Mirrors/foundry-sw5e
Powercasting works based on school of power
Updated power items to automatically change mod used when set to powercasting
This commit is contained in:
parent
8134ee4f09
commit
ad50d1549f
5 changed files with 45 additions and 12 deletions
|
@ -144,6 +144,10 @@
|
||||||
"SW5E.BonusRWDamage": "Ranged Weapon Damage Bonus",
|
"SW5E.BonusRWDamage": "Ranged Weapon Damage Bonus",
|
||||||
"SW5E.BonusSaveForm": "Update Bonuses",
|
"SW5E.BonusSaveForm": "Update Bonuses",
|
||||||
"SW5E.BonusPowerDC": "Global Power DC Bonus",
|
"SW5E.BonusPowerDC": "Global Power DC Bonus",
|
||||||
|
"SW5E.BonusForceLightPowerDC": "Global Force Light Power DC Bonus",
|
||||||
|
"SW5E.BonusForceDarkPowerDC": "Global Force Dark Power DC Bonus",
|
||||||
|
"SW5E.BonusForceUnivPowerDC": "Global Force Universal Power DC Bonus",
|
||||||
|
"SW5E.BonusTechPowerDC": "Global Tech Power DC Bonus",
|
||||||
"SW5E.BonusTitle": "Configure Actor Bonuses",
|
"SW5E.BonusTitle": "Configure Actor Bonuses",
|
||||||
"SW5E.Bonuses": "Global Bonuses",
|
"SW5E.Bonuses": "Global Bonuses",
|
||||||
"SW5E.BonusesHint": "Define global bonuses as formulas which are added to certain rolls. For example: 1d4 + 2",
|
"SW5E.BonusesHint": "Define global bonuses as formulas which are added to certain rolls. For example: 1d4 + 2",
|
||||||
|
|
|
@ -94,7 +94,7 @@ export default class Actor5e extends Actor {
|
||||||
// Prepare power-casting data
|
// Prepare power-casting data
|
||||||
data.attributes.powerForceLightDC = 8 + data.abilities.wis.mod + data.attributes.prof ?? 10;
|
data.attributes.powerForceLightDC = 8 + data.abilities.wis.mod + data.attributes.prof ?? 10;
|
||||||
data.attributes.powerForceDarkDC = 8 + data.abilities.cha.mod + data.attributes.prof ?? 10;
|
data.attributes.powerForceDarkDC = 8 + data.abilities.cha.mod + data.attributes.prof ?? 10;
|
||||||
data.attributes.powerForceUnivDC = Math.ceil(data.attributes.powerForceLightDC,data.attributes.powerForceDarkDC) ?? 10;
|
data.attributes.powerForceUnivDC = Math.max(data.attributes.powerForceLightDC,data.attributes.powerForceDarkDC) ?? 10;
|
||||||
data.attributes.powerTechDC = 8 + data.abilities.int.mod + data.attributes.prof ?? 10;
|
data.attributes.powerTechDC = 8 + data.abilities.int.mod + data.attributes.prof ?? 10;
|
||||||
this._computePowercastingProgression(this.data);
|
this._computePowercastingProgression(this.data);
|
||||||
|
|
||||||
|
@ -1119,8 +1119,6 @@ export default class Actor5e extends Actor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Note the change in HP and HD and TP which occurred
|
// Note the change in HP and HD and TP which occurred
|
||||||
const dhd = this.data.data.attributes.hd - hd0;
|
const dhd = this.data.data.attributes.hd - hd0;
|
||||||
const dhp = this.data.data.attributes.hp.value - hp0;
|
const dhp = this.data.data.attributes.hp.value - hp0;
|
||||||
|
|
|
@ -74,7 +74,11 @@ export default class ActorSheetFlags extends BaseEntitySheet {
|
||||||
{name: "data.bonuses.abilities.check", label: "SW5E.BonusAbilityCheck"},
|
{name: "data.bonuses.abilities.check", label: "SW5E.BonusAbilityCheck"},
|
||||||
{name: "data.bonuses.abilities.save", label: "SW5E.BonusAbilitySave"},
|
{name: "data.bonuses.abilities.save", label: "SW5E.BonusAbilitySave"},
|
||||||
{name: "data.bonuses.abilities.skill", label: "SW5E.BonusAbilitySkill"},
|
{name: "data.bonuses.abilities.skill", label: "SW5E.BonusAbilitySkill"},
|
||||||
{name: "data.bonuses.power.dc", label: "SW5E.BonusPowerDC"}
|
{name: "data.bonuses.power.dc", label: "SW5E.BonusPowerDC"},
|
||||||
|
{name: "data.bonuses.power.forceLightDC", label: "SW5E.BonusForceLightPowerDC"},
|
||||||
|
{name: "data.bonuses.power.forceDarkDC", label: "SW5E.BonusForceDarkPowerDC"},
|
||||||
|
{name: "data.bonuses.power.forceUnivDC", label: "SW5E.BonusForceUnivPowerDC"},
|
||||||
|
{name: "data.bonuses.power.techDC", label: "SW5E.BonusTechPowerDC"}
|
||||||
];
|
];
|
||||||
for ( let b of bonuses ) {
|
for ( let b of bonuses ) {
|
||||||
b.value = getProperty(this.object._data, b.name) || "";
|
b.value = getProperty(this.object._data, b.name) || "";
|
||||||
|
|
|
@ -25,8 +25,17 @@ export default class Item5e extends Item {
|
||||||
else if (this.actor) {
|
else if (this.actor) {
|
||||||
const actorData = this.actor.data.data;
|
const actorData = this.actor.data.data;
|
||||||
|
|
||||||
// Powers - Use Actor powercasting modifier
|
// Powers - Use Actor powercasting modifier based on power school
|
||||||
if (this.data.type === "power") return actorData.attributes.powercasting || "int";
|
if (this.data.type === "power") {
|
||||||
|
switch (this.data.data.school) {
|
||||||
|
case "lgt": return "wis";
|
||||||
|
case "uni": return (actorData.abilities["wis"].mod >= actorData.abilities["cha"].mod) ? "wis" : "cha";
|
||||||
|
case "drk": return "cha";
|
||||||
|
case "tec": return "int";
|
||||||
|
}
|
||||||
|
return "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Tools - default to Intelligence
|
// Tools - default to Intelligence
|
||||||
else if (this.data.type === "tool") return "int";
|
else if (this.data.type === "tool") return "int";
|
||||||
|
@ -291,7 +300,24 @@ export default class Item5e extends Item {
|
||||||
|
|
||||||
// Actor power-DC based scaling
|
// Actor power-DC based scaling
|
||||||
if ( save.scaling === "power" ) {
|
if ( save.scaling === "power" ) {
|
||||||
save.dc = this.isOwned ? getProperty(this.actor.data, "data.attributes.powerdc") : null;
|
switch (this.data.data.school) {
|
||||||
|
case "lgt": {
|
||||||
|
save.dc = this.isOwned ? getProperty(this.actor.data, "data.attributes.powerForceLightDC") : null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "uni": {
|
||||||
|
save.dc = this.isOwned ? getProperty(this.actor.data, "data.attributes.powerForceUnivDC") : null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "drk": {
|
||||||
|
save.dc = this.isOwned ? getProperty(this.actor.data, "data.attributes.powerForceDarkDC") : null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "tec": {
|
||||||
|
save.dc = this.isOwned ? getProperty(this.actor.data, "data.attributes.powerTechDC") : null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ability-score based scaling
|
// Ability-score based scaling
|
||||||
|
@ -394,6 +420,7 @@ export default class Item5e extends Item {
|
||||||
const recharge = id.recharge || {}; // Recharge mechanic
|
const recharge = id.recharge || {}; // Recharge mechanic
|
||||||
const uses = id?.uses ?? {}; // Limited uses
|
const uses = id?.uses ?? {}; // Limited uses
|
||||||
const isPower = this.type === "power"; // Does the item require a power slot?
|
const isPower = this.type === "power"; // Does the item require a power slot?
|
||||||
|
// TODO: Possibly Mod this to not consume slots based on class?
|
||||||
const requirePowerSlot = isPower && (id.level > 0) && CONFIG.SW5E.powerUpcastModes.includes(id.preparation.mode);
|
const requirePowerSlot = isPower && (id.level > 0) && CONFIG.SW5E.powerUpcastModes.includes(id.preparation.mode);
|
||||||
|
|
||||||
// Define follow-up actions resulting from the item usage
|
// Define follow-up actions resulting from the item usage
|
||||||
|
@ -420,12 +447,12 @@ export default class Item5e extends Item {
|
||||||
// Handle power upcasting
|
// Handle power upcasting
|
||||||
if ( requirePowerSlot ) {
|
if ( requirePowerSlot ) {
|
||||||
const slotLevel = configuration.level;
|
const slotLevel = configuration.level;
|
||||||
const powerLevel = slotLevel === "pact" ? actor.data.data.powers.pact.level : parseInt(slotLevel);
|
const powerLevel = parseInt(slotLevel);
|
||||||
if (powerLevel !== id.level) {
|
if (powerLevel !== id.level) {
|
||||||
const upcastData = mergeObject(this.data, {"data.level": powerLevel}, {inplace: false});
|
const upcastData = mergeObject(this.data, {"data.level": powerLevel}, {inplace: false});
|
||||||
item = this.constructor.createOwned(upcastData, actor); // Replace the item with an upcast version
|
item = this.constructor.createOwned(upcastData, actor); // Replace the item with an upcast version
|
||||||
}
|
}
|
||||||
if ( consumePowerSlot ) consumePowerSlot = slotLevel === "pact" ? "pact" : `power${powerLevel}`;
|
if ( consumePowerSlot ) consumePowerSlot = `power${powerLevel}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,7 +522,7 @@ export default class Item5e extends Item {
|
||||||
const level = this.actor?.data.data.powers[consumePowerSlot];
|
const level = this.actor?.data.data.powers[consumePowerSlot];
|
||||||
const powers = Number(level?.value ?? 0);
|
const powers = Number(level?.value ?? 0);
|
||||||
if ( powers === 0 ) {
|
if ( powers === 0 ) {
|
||||||
const label = game.i18n.localize(consumePowerSlot === "pact" ? "SW5E.PowerProgPact" : `SW5E.PowerLevel${id.level}`);
|
const label = game.i18n.localize(`SW5E.PowerLevel${id.level}`);
|
||||||
ui.notifications.warn(game.i18n.format("SW5E.PowerCastNoSlots", {name: this.name, level: label}));
|
ui.notifications.warn(game.i18n.format("SW5E.PowerCastNoSlots", {name: this.name, level: label}));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -772,7 +799,7 @@ export default class Item5e extends Item {
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare chat card data for tool type items
|
* Prepare chat card data for loot type items
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_lootChatData(data, labels, props) {
|
_lootChatData(data, labels, props) {
|
||||||
|
|
|
@ -292,7 +292,7 @@ function _migrateActorPowers(actorData, updateData) {
|
||||||
updateData["data.bonuses.power.forceLightDC"] = "";
|
updateData["data.bonuses.power.forceLightDC"] = "";
|
||||||
updateData["data.bonuses.power.forceDarkDC"] = "";
|
updateData["data.bonuses.power.forceDarkDC"] = "";
|
||||||
updateData["data.bonuses.power.forceUnivDC"] = "";
|
updateData["data.bonuses.power.forceUnivDC"] = "";
|
||||||
updateData["data.bonuses.power.TechDC"] = "";
|
updateData["data.bonuses.power.techDC"] = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the Power DC Bonus
|
// Remove the Power DC Bonus
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue