diff --git a/CHANGELOG.md b/CHANGELOG.md index 46e4f78..f385cdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Fix js error when Advancement is not embed in a actor - Click on a weapon show the DicePicker with the weapon skill selected - Display Rarity in Compendiums for Items, Armors and Weapons +- Minion can now choose a stance and if they are prepared - Other minors fix ## 1.1.1 - The Huns War diff --git a/system/scripts/combat.js b/system/scripts/combat.js index a2787a0..2370b5e 100644 --- a/system/scripts/combat.js +++ b/system/scripts/combat.js @@ -52,25 +52,21 @@ export class CombatL5r5e extends Combat { // Shortcut to data const data = combatant.actor.data.data; + // Prepared is a boolean or if null we get the info in the actor sheet + const isPc = combatant.actor.data.type === "character"; + let isPrepared = isPc ? cfg.prepared.character : cfg.prepared[data.type]; + if (isPrepared === "null") { + isPrepared = data.prepared ? "true" : "false"; + } + // A character’s initiative value is based on their state of preparedness when the conflict began. // If the character was ready for the conflict, their base initiative value is their focus attribute. // If the character was unprepared (such as when surprised), their base initiative value is their vigilance attribute. - let initiative; - - if (combatant.actor.data.type === "npc" && combatant.actor.data.data.type === "minion") { - // Minion NPCs can generate initiative value without a check, using their focus or vigilance attribute - initiative = cfg.prepared.minion === "true" ? data.focus : data.is_compromised ? 1 : data.vigilance; - } else { - // PC and Adversary - const isPc = combatant.actor.data.type === "character"; - - // prepared is a boolean or if null we get the info in the actor sheet - let isPrepared = isPc ? cfg.prepared.character : cfg.prepared.adversary; - if (isPrepared === "null") { - isPrepared = data.prepared ? "true" : "false"; - } - initiative = isPrepared === "true" ? data.focus : data.is_compromised ? 1 : data.vigilance; + // Minion NPCs can generate initiative value without a check, using their focus or vigilance attribute + let initiative = isPrepared === "true" ? data.focus : data.is_compromised ? 1 : data.vigilance; + // Roll only for PC and Adversary + if (isPc || data.type === "adversary") { // Roll formula if (!formula) { const createFormula = [`${data.rings[data.stance]}dr`]; @@ -131,8 +127,22 @@ export class CombatL5r5e extends Combat { _sortCombatants(a, b) { // if tie, sort by honor, less honorable first if (a.initiative === b.initiative) { + // if tie, Character > Adversary > Minion + if (a.actor.data.data.social.honor === b.actor.data.data.social.honor) { + return ( + CombatL5r5e._getWeightByActorType(a.actor.data) - CombatL5r5e._getWeightByActorType(b.actor.data) + ); + } return a.actor.data.data.social.honor - b.actor.data.data.social.honor; } return b.initiative - a.initiative; } + + /** + * Basic weight system for sorting Character > Adversary > Minion + * @private + */ + static _getWeightByActorType(data) { + return data.type === "npc" ? (data.data.type === "minion" ? 3 : 2) : 1; + } } diff --git a/system/scripts/hooks.js b/system/scripts/hooks.js index fb14fe5..373314e 100644 --- a/system/scripts/hooks.js +++ b/system/scripts/hooks.js @@ -135,7 +135,7 @@ export default class HooksL5r5e { value = "true"; break; case "true": - value = preparedId === "minion" ? "false" : "null"; + value = "null"; break; case "null": value = "false"; diff --git a/system/scripts/settings.js b/system/scripts/settings.js index ea58180..882f1bc 100644 --- a/system/scripts/settings.js +++ b/system/scripts/settings.js @@ -56,6 +56,6 @@ export const RegisterSettings = function () { scope: "world", config: false, type: String, - default: "true", + default: "null", }); }; diff --git a/system/templates/actors/npc-sheet.html b/system/templates/actors/npc-sheet.html index 9e2c167..23b81fe 100644 --- a/system/templates/actors/npc-sheet.html +++ b/system/templates/actors/npc-sheet.html @@ -22,9 +22,7 @@
{{> 'systems/l5r5e/templates/actors/npc/skill.html' }} - {{#ifCond data.type '==' 'adversary'}} - {{> 'systems/l5r5e/templates/actors/npc/conflict.html' }} - {{/ifCond}} + {{> 'systems/l5r5e/templates/actors/npc/conflict.html' }}
{{> 'systems/l5r5e/templates/actors/npc/narrative.html' }}