diff --git a/src/module/combat.js b/src/module/combat.js index 96966be..ad64c8c 100644 --- a/src/module/combat.js +++ b/src/module/combat.js @@ -1,5 +1,3 @@ -import { OseDice } from "./dice.js"; - export class OseCombat { static rollInitiative(combat, data) { // Check groups @@ -27,6 +25,14 @@ export class OseCombat { } } + static individualInitiative(combat, data) { + let ids = []; + combat.data.combatants.forEach(cbt => { + ids.push(cbt._id); + }) + combat.rollInitiative(ids); + } + static format(object, html, user) { html.find('.combat-control[data-control="rollNPC"]').remove(); html.find('.combat-control[data-control="rollAll"]').remove(); diff --git a/src/ose.js b/src/ose.js index ba72bf8..77ec6be 100644 --- a/src/ose.js +++ b/src/ose.js @@ -77,6 +77,7 @@ Hooks.once("ready", async () => { ); }); +// License and KOFI infos Hooks.on("renderSidebarTab", async (object, html) => { if (object instanceof Settings) { const template = "systems/ose/templates/chat/license.html"; @@ -106,6 +107,10 @@ Hooks.on("preUpdateCombatant", (combat, combatant, data, diff, id) => { data.initiative = parseInt(groupInit); } }); + } else if (data.initiative && init) { + if (combatant.actor.data.data.isSlow) { + data.initiative = -1; + } } }); @@ -118,10 +123,14 @@ Hooks.on("renderCombatTracker", (object, html, data) => { Hooks.on("preUpdateCombat", async (combat, data, diff, id) => { let init = game.settings.get("ose", "individualInit"); - if (!data.round || init) { + if (!data.round) { return; } - OseCombat.rollInitiative(combat, data, diff, id); + if (!init) { + OseCombat.rollInitiative(combat, data, diff, id); + } else { + OseCombat.individualInitiative(combat, data, diff, id); + } }); Hooks.on("renderChatLog", (app, html, data) => OseItem.chatListeners(html));