diff --git a/index.ts b/index.ts index f6dcb5f9..b729d5c0 100644 --- a/index.ts +++ b/index.ts @@ -157,6 +157,7 @@ export interface CreatureState extends HomebrewCreature { tempHP: number; currentAC: number | string; initiative: number; + static: boolean; player: boolean; xp: number; active: boolean; @@ -215,6 +216,7 @@ export interface HomebrewCreature { hidden?: boolean; friendly?: boolean; active?: boolean; + static?: boolean; "statblock-link"?: string; } diff --git a/src/encounter/index.ts b/src/encounter/index.ts index 63045066..bedc4a8b 100644 --- a/src/encounter/index.ts +++ b/src/encounter/index.ts @@ -32,6 +32,7 @@ interface CreatureStats { display?: string; hidden: boolean; friendly?: boolean; + static?: boolean; } export const equivalent = ( @@ -45,7 +46,8 @@ export const equivalent = ( equivalentModifiers(creature.modifier, existing.modifier) && creature.xp == existing.xp && creature.hidden == existing.hidden && - creature.friendly == existing.friendly + creature.friendly == existing.friendly && + creature.static == existing.static ); }; diff --git a/src/tracker/stores/tracker.ts b/src/tracker/stores/tracker.ts index 71529d0c..4bb412c8 100644 --- a/src/tracker/stores/tracker.ts +++ b/src/tracker/stores/tracker.ts @@ -87,6 +87,7 @@ function createTracker() { values.forEach((creature, _, arr) => { const equiv = arr.filter((c) => equivalent(c, creature)); equiv.forEach((eq) => { + if (eq.static) return; eq.initiative = Math.max(...equiv.map((i) => i.initiative)); }); }); @@ -572,6 +573,7 @@ function createTracker() { roll: (plugin: InitiativeTracker) => updateAndSave((creatures) => { for (let creature of creatures) { + if (creature.static) continue; creature.initiative = plugin.getInitiativeValue( creature.modifier ); @@ -589,6 +591,7 @@ function createTracker() { : creatures.filter((c) => c.player); if (!state || state?.roll) { for (let creature of creatures) { + if (creature.static && creature.initiative) continue; creature.initiative = plugin.getInitiativeValue( creature.modifier ); diff --git a/src/tracker/ui/create/Create.svelte b/src/tracker/ui/create/Create.svelte index bf3cdc4d..ef398ed0 100644 --- a/src/tracker/ui/create/Create.svelte +++ b/src/tracker/ui/create/Create.svelte @@ -152,6 +152,11 @@ .setValue(creature.hidden) .onChange((v) => (creature.hidden = v)); }; + const staticToggle = (div: HTMLDivElement) => { + new ToggleComponent(div) + .setValue(creature.static) + .onChange((v) => (creature.static = v)); + }; const friendToggle = (div: HTMLDivElement) => { new ToggleComponent(div) .setValue(creature.friendly) @@ -247,6 +252,10 @@ {#key creature} +