forked from GitHub-Mirrors/foundry-sw5e

System main update to be inline with dnd5e 1.1.1 Added active effects to as many sheets as I thought applicable. Please check loot, I made an attempt but it may be broken All .less .css and actor .html updates were made to the old actors. New actors may be broken with this update removed templates\actors\oldActor\parts\actor-effects.html for newer templates\actors\parts\active-effects.html removed module\apps\cast-dialog, templates\apps\cast-cast.html, and templates\items\cast.html. I do not think they are used, I think they were deprecated when powers were treated as items, if not we can add them back in. **NOTE** REQUIRES Foundry 0.7.6
40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
|
|
/**
|
|
* Override the default Initiative formula to customize special behaviors of the SW5e system.
|
|
* Apply advantage, proficiency, or bonuses where appropriate
|
|
* Apply the dexterity score as a decimal tiebreaker if requested
|
|
* See Combat._getInitiativeFormula for more detail.
|
|
*/
|
|
export const _getInitiativeFormula = function(combatant) {
|
|
const actor = combatant.actor;
|
|
if ( !actor ) return "1d20";
|
|
const init = actor.data.data.attributes.init;
|
|
|
|
let nd = 1;
|
|
let mods = "";
|
|
|
|
if (actor.getFlag("sw5e", "halflingLucky")) mods += "r=1";
|
|
if (actor.getFlag("sw5e", "initiativeAdv")) {
|
|
nd = 2;
|
|
mods += "kh";
|
|
}
|
|
|
|
const parts = [`${nd}d20${mods}`, init.mod, (init.prof !== 0) ? init.prof : null, (init.bonus !== 0) ? init.bonus : null];
|
|
|
|
// Optionally apply Dexterity tiebreaker
|
|
const tiebreaker = game.settings.get("sw5e", "initiativeDexTiebreaker");
|
|
if ( tiebreaker ) parts.push(actor.data.data.abilities.dex.value / 100);
|
|
return parts.filter(p => p !== null).join(" + ");
|
|
};
|
|
|
|
/**
|
|
* When the Combat encounter updates - re-render open Actor sheets for combatants in the encounter.
|
|
*/
|
|
Hooks.on("updateCombat", (combat, data, options, userId) => {
|
|
const updateTurn = ("turn" in data) || ("round" in data);
|
|
if ( !updateTurn ) return;
|
|
for ( let t of combat.turns ) {
|
|
const a = t.actor;
|
|
if ( t.actor ) t.actor.sheet.render(false);
|
|
}
|
|
});
|