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.` }); }
|
||||
})();
|
||||
Reference in New Issue
Block a user