mirror of
https://github.com/migatu/vtt_work.git
synced 2026-07-14 21:38:39 +00:00
Import gk-greyknight-0.1.0.zip do wg-greyknights (2025-08-21T19:51:05Z)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
// GK – Aegis Glow Toggle (module)
|
||||
(async () => {
|
||||
const tok = canvas.tokens.controlled[0] ?? null;
|
||||
const actor = tok?.actor ?? game.user.character;
|
||||
const token = tok ?? canvas.tokens.placeables.find(t => t.actor?.id === actor?.id);
|
||||
if (!actor || !token) return ui.notifications.warn("Wybierz token lub przypisz postać do użytkownika.");
|
||||
|
||||
const aegisArm = actor.items.find(i => ["armour","armor"].includes(i.type) && /Aegis/.test(i.name));
|
||||
if (!aegisArm) return ui.notifications.warn("Nie znaleziono Aegis armour na postaci.");
|
||||
const eff = aegisArm.effects.find(e => e.name?.toLowerCase().startsWith("aegis warding runes"));
|
||||
if (!eff) return ui.notifications.warn("Nie znaleziono efektu toggle na Aegis armour.");
|
||||
const wasDisabled = eff.disabled ?? true;
|
||||
await eff.update({ disabled: !wasDisabled });
|
||||
|
||||
const FLAG_SCOPE = "wng-gk"; const FLAG_KEY = "prevLight";
|
||||
const setGlowOn = async () => {
|
||||
const prev = token.document.getFlag(FLAG_SCOPE, FLAG_KEY);
|
||||
if (!prev) await token.document.setFlag(FLAG_SCOPE, FLAG_KEY, foundry.utils.deepClone(token.document.light));
|
||||
await token.document.update({
|
||||
light: { color:"#66ccff", coloration:2, alpha:0.7, dim:16, bright:0, angle:360,
|
||||
luminosity:0.5, attenuation:0.35, saturation:0, contrast:0, shadows:0,
|
||||
animation:{ type:"pulse", speed:3, intensity:4, reverse:false } }
|
||||
});
|
||||
await canvas.perception.update({ lighting: { refresh: true } });
|
||||
};
|
||||
const setGlowOff = async () => {
|
||||
const prev = token.document.getFlag(FLAG_SCOPE, FLAG_KEY);
|
||||
if (prev) { await token.document.update({ light: prev }); await token.document.unsetFlag(FLAG_SCOPE, FLAG_KEY); }
|
||||
else { await token.document.update({ light: { dim:0, bright:0, color:null } }); }
|
||||
await canvas.perception.update({ lighting: { refresh: true } });
|
||||
};
|
||||
if (wasDisabled) { await setGlowOn(); ChatMessage.create({ content: `<b>Aegis:</b> Warding Runes <span style="color:#66ccff">ENGAGED</span>. (Akcja)` }); }
|
||||
else { await setGlowOff(); ChatMessage.create({ content: `<b>Aegis:</b> Warding Runes DISENGAGED.` }); }
|
||||
})();
|
||||
@@ -0,0 +1,40 @@
|
||||
// GK – Import Items From Module into Items Directory
|
||||
(async () => {
|
||||
const FILES = [
|
||||
"fvtt-Item-archetype-grey-knight_v5.json",
|
||||
"fvtt-Item-ability-aegis-of-titan_v5.json",
|
||||
"fvtt-Item-nemesis-force-halberd_v4.json",
|
||||
"fvtt-Item-gk-armour-integrated-storm-bolter_v2.json",
|
||||
"fvtt-Item-aegis-power-armour_v2.json",
|
||||
"fvtt-Item-terminator-aegis-gk_v4.json"
|
||||
];
|
||||
const MODULE_ID = "gk-greyknight";
|
||||
const base = `modules/${MODULE_ID}/foundry`;
|
||||
|
||||
const ensureFolder = async (name, color="#4b6eaf") => {
|
||||
let f = game.folders.find(x => x.type === "Item" && x.name === name);
|
||||
if (!f) f = await Folder.create({name, type:"Item", color});
|
||||
return f;
|
||||
};
|
||||
const worldFolder = await ensureFolder("Grey Knight Pack", "#4b6eaf");
|
||||
|
||||
const fetchJSON = async (path) => {
|
||||
const res = await fetch(`/${path}`);
|
||||
if (!res.ok) throw new Error(`Nie mogę pobrać: ${path} (HTTP ${res.status})`);
|
||||
return await res.json();
|
||||
};
|
||||
|
||||
let created = 0, updated = 0;
|
||||
for (const fn of FILES) {
|
||||
const full = `${base}/${fn}`;
|
||||
try {
|
||||
const data = await fetchJSON(full);
|
||||
if (data._id) delete data._id;
|
||||
data.folder = worldFolder.id;
|
||||
const existing = game.items.getName(data.name);
|
||||
if (existing) { await existing.update(data); updated++; }
|
||||
else { await Item.create(data); created++; }
|
||||
} catch (e) { console.error("Import err", full, e); ui.notifications.warn(`Błąd importu: ${fn}`); }
|
||||
}
|
||||
ui.notifications.info(`GK Module Import: utworzono ${created}, zaktualizowano ${updated}.`);
|
||||
})();
|
||||
@@ -0,0 +1,64 @@
|
||||
// GK – Loadout Manager (module)
|
||||
(async () => {
|
||||
const NAMES = {
|
||||
archetype: "Grey Knight (Archetype)",
|
||||
ability: "Aegis of Titan (Ability)",
|
||||
nemesis: "Nemesis Force Halberd",
|
||||
storm: "Grey Knight Armour Integrated Storm Bolter",
|
||||
aegis: "Aegis Power Armour",
|
||||
term: "Terminator Aegis (Grey Knights)"
|
||||
};
|
||||
const FOLDER = "Grey Knight Pack";
|
||||
|
||||
const actor = canvas.tokens.controlled[0]?.actor ?? game.user.character;
|
||||
if (!actor) return ui.notifications.warn("Zaznacz token albo przypisz postać.");
|
||||
|
||||
const mode = await Dialog.prompt({
|
||||
title: "Grey Knight – Loadout Manager",
|
||||
content: `<p>Wybierz lub zmień loadout:</p>
|
||||
<label><input type="radio" name="m" value="incognito"> Incognito (bez Aegis)</label><br/>
|
||||
<label><input type="radio" name="m" value="war" checked> War-Plate (Aegis Power Armour)</label><br/>
|
||||
<label><input type="radio" name="m" value="term"> Terminator (Terminator Aegis)</label>`,
|
||||
label: "OK",
|
||||
callback: html => html.find('input[name="m"]:checked').val()
|
||||
});
|
||||
if (!mode) return;
|
||||
|
||||
const findWorldItem = (name) => {
|
||||
const inFolder = game.items.filter(i => i.name === name && i.folder?.name === FOLDER);
|
||||
if (inFolder.length) return inFolder[0];
|
||||
return game.items.getName(name) ?? null;
|
||||
};
|
||||
const ensureOnActor = async (name) => {
|
||||
const have = actor.items.getName(name);
|
||||
if (have) return have;
|
||||
const worldIt = findWorldItem(name);
|
||||
if (!worldIt) { ui.notifications.warn(`Brak w Items Directory: ${name} — użyj importera modułu.`); return null; }
|
||||
const created = await actor.createEmbeddedDocuments("Item", [worldIt.toObject()]);
|
||||
return created[0];
|
||||
};
|
||||
|
||||
for (const key of Object.keys(NAMES)) await ensureOnActor(NAMES[key]);
|
||||
|
||||
const setEquipped = async (name, on) => { const it = actor.items.getName(name); if (it) await it.update({"system.equipped": !!on}); };
|
||||
await setEquipped(NAMES.aegis, false);
|
||||
await setEquipped(NAMES.term, false);
|
||||
await setEquipped(NAMES.storm, false);
|
||||
await setEquipped(NAMES.nemesis, false);
|
||||
|
||||
if (mode === "war") {
|
||||
await setEquipped(NAMES.aegis, true);
|
||||
await setEquipped(NAMES.storm, true);
|
||||
await setEquipped(NAMES.nemesis, true);
|
||||
} else if (mode === "term") {
|
||||
await setEquipped(NAMES.term, true);
|
||||
await setEquipped(NAMES.storm, true);
|
||||
await setEquipped(NAMES.nemesis, true);
|
||||
}
|
||||
|
||||
const anyAegisEquipped = !!actor.items.find(i => ["armour","armor"].includes(i.type) && /Aegis/.test(i.name) && i.system?.equipped);
|
||||
const abilItem = actor.items.getName(NAMES.ability);
|
||||
if (abilItem) for (const ef of abilItem.effects ?? []) if (ef.name?.includes("Aegis Synergy")) await ef.update({ disabled: !anyAegisEquipped });
|
||||
|
||||
ui.notifications.info(`Loadout ustawiony: ${mode.toUpperCase()}.`);
|
||||
})();
|
||||
Reference in New Issue
Block a user