mirror of
https://github.com/migatu/vtt_work.git
synced 2026-07-14 13:34:42 +00:00
Import wng-daemonhunters-0.6.4.1.zip do wg-greyknights (2025-08-22T17:07:40Z)
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
// WNG-Daemonhunters 0.6.4.1 — single dialog GK autoload (no clashes)
|
||||
Hooks.once('ready', () => console.log("WNG-Daemonhunters | Auto-loadout ready"));
|
||||
|
||||
async function addFromPackByName(actor, packKey, name, equip=false) {
|
||||
const pack = game.packs.get(packKey);
|
||||
if (!pack) return ui.notifications?.warn(`Pack not found: ${packKey}`);
|
||||
const index = await pack.getIndex();
|
||||
const entry = index.find(e => e.name === name);
|
||||
if (!entry) return ui.notifications?.warn(`Item not in pack: ${name}`);
|
||||
const doc = await pack.getDocument(entry._id);
|
||||
const data = doc.toObject(); delete data._id;
|
||||
if (equip && data.system && ('equipped' in data.system)) data.system.equipped = true;
|
||||
const [created] = await actor.createEmbeddedDocuments('Item', [data]);
|
||||
return created;
|
||||
}
|
||||
async function addFromUuid(actor, uuid, equip=false) {
|
||||
const doc = await fromUuid(uuid);
|
||||
if (!doc) return ui.notifications?.warn(`Missing UUID: ${uuid}`);
|
||||
const data = doc.toObject(); delete data._id;
|
||||
if (equip && data.system && ('equipped' in data.system)) data.system.equipped = true;
|
||||
const [created] = await actor.createEmbeddedDocuments('Item', [data]);
|
||||
return created;
|
||||
}
|
||||
|
||||
Hooks.on('createItem', async (item, options, userId) => {
|
||||
try {
|
||||
const actor = item.parent;
|
||||
if (!actor || item.type !== 'archetype' || item.name !== 'Grey Knight') return;
|
||||
if (game.userId !== userId) return;
|
||||
if (actor.getFlag('wng-daemonhunters','gkLoaded')) return; // prevent double-run
|
||||
|
||||
const content = `<p>Select initial loadout for <strong>Grey Knight</strong>:</p>
|
||||
<div class="form-group"><label>Loadout</label>
|
||||
<select id="gk-loadout">
|
||||
<option value="incog">Incognito — Pilgrim Astartes Plate + Astartes Combat Knife + Bolt Pistol</option>
|
||||
<option value="power" selected>War‑Plate — Aegis Power Armour + Nemesis Force Halberd + Integrated Storm Bolter</option>
|
||||
<option value="termi">Terminator — Terminator Aegis + Nemesis Force Halberd + Integrated Storm Bolter</option>
|
||||
</select>
|
||||
</div>`;
|
||||
|
||||
new Dialog({
|
||||
title: "Grey Knight — Choose Loadout",
|
||||
content,
|
||||
buttons: {
|
||||
ok: { label: "Apply", callback: async (html) => {
|
||||
const choice = html.find('#gk-loadout').val();
|
||||
const PACK = "wng-daemonhunters.daemonhunters";
|
||||
|
||||
// Base abilities always
|
||||
await addFromPackByName(actor, PACK, "Aegis of Titan");
|
||||
await addFromPackByName(actor, PACK, "Brotherhood of Psykers");
|
||||
await addFromPackByName(actor, PACK, "Might of Heroes");
|
||||
|
||||
if (choice === 'incog') {
|
||||
await addFromPackByName(actor, PACK, "Pilgrim Astartes Power Armour", true);
|
||||
await addFromUuid(actor, "Compendium.wng-core.items.Item.4QVBQYWXXLyvFWkj", true); // Knife
|
||||
await addFromUuid(actor, "Compendium.wng-core.items.Item.7b2xcPWBB7up65PM", true); // Bolt Pistol
|
||||
} else if (choice === 'power') {
|
||||
await addFromPackByName(actor, PACK, "Aegis Power Armour", true);
|
||||
await addFromPackByName(actor, PACK, "Grey Knight Armour Integrated Storm Bolter", true);
|
||||
await addFromPackByName(actor, PACK, "Nemesis Force Halberd", true);
|
||||
} else if (choice === 'termi') {
|
||||
await addFromPackByName(actor, PACK, "Terminator Aegis (Grey Knights)", true);
|
||||
await addFromPackByName(actor, PACK, "Grey Knight Armour Integrated Storm Bolter", true);
|
||||
await addFromPackByName(actor, PACK, "Nemesis Force Halberd", true);
|
||||
}
|
||||
|
||||
await actor.setFlag('wng-daemonhunters','gkLoaded', true);
|
||||
ui.notifications?.info("Grey Knight loadout applied.");
|
||||
}}
|
||||
},
|
||||
default: "ok"
|
||||
}).render(true);
|
||||
} catch (e) { console.error("GK autoload error", e); }
|
||||
});
|
||||
Reference in New Issue
Block a user