From 05ba9a4afbea3513d862cbb0c15e2e8fd8a7c835 Mon Sep 17 00:00:00 2001 From: kandashi Date: Thu, 4 Mar 2021 13:30:49 +0000 Subject: [PATCH] once per turn and only hostile turns --- lang/en.json | 3 +++ lang/es.json | 3 +++ lang/ja.json | 3 +++ lang/ko.json | 5 +++- module.json | 2 +- src/aura.js | 69 ++++++++++++++++++++++++++++++++++++++++++++++------ 6 files changed, 76 insertions(+), 9 deletions(-) diff --git a/lang/en.json b/lang/en.json index da6357c..4167b01 100644 --- a/lang/en.json +++ b/lang/en.json @@ -31,6 +31,9 @@ "ACTIVEAURAS.FORM_TypePrompt": "humanoid/beast etc", "ACTIVEAURAS.FORM_RadiusPrompt": "Measured by your grid scale", "ACTIVEAURAS.FORM_SavePrompt": "str/dex/con/wis/int/cha", + "ACTIVEAURAS.FORM_TimePrompt": "Special Expiry for the Applied Effect", + "ACTIVEAURAS.FORM_HostileTurn": "Only apply during the current combatants turn", + "ACTIVEAURAS.FORM_ActivateOnce": "Only trigger the aura once per turn", "ACTIVEAURAS.ApplyLog":"ActiveAuras | Applied '{effectDataLabel}' to {tokenName}", "ACTIVEAURAS.RemoveLog":"ActiveAuras | Removed '{effectDataLabel}' from {tokenName}", diff --git a/lang/es.json b/lang/es.json index c85f565..b8b38fa 100644 --- a/lang/es.json +++ b/lang/es.json @@ -31,6 +31,9 @@ "ACTIVEAURAS.FORM_TypePrompt": "humanoide/bestia, etc", "ACTIVEAURAS.FORM_RadiusPrompt": "Medido con tu escala de cuadrícula", "ACTIVEAURAS.FORM_SavePrompt": "fue/des/con/sab/int/car", + "ACTIVEAURAS.FORM_TimePrompt": "[EN] Special Expiry for the Applied Effect", + "ACTIVEAURAS.FORM_HostileTurn": "[EN] Only apply during the current combatants turn", + "ACTIVEAURAS.FORM_ActivateOnce": "[EN] Only trigger the aura once per turn", "ACTIVEAURAS.ApplyLog":"ActiveAuras | '{effectDataLabel}' aplicado a {tokenName}", "ACTIVEAURAS.RemoveLog":"ActiveAuras | '{effectDataLabel}' quitado de {tokenName}", diff --git a/lang/ja.json b/lang/ja.json index 4112fda..f7fb627 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -31,6 +31,9 @@ "ACTIVEAURAS.FORM_TypePrompt": "humanoid/beast など", "ACTIVEAURAS.FORM_RadiusPrompt": "グリッドスケールで測定する", "ACTIVEAURAS.FORM_SavePrompt": "str/dex/con/wis/int/cha", + "ACTIVEAURAS.FORM_TimePrompt": "[EN] Special Expiry for the Applied Effect", + "ACTIVEAURAS.FORM_HostileTurn": "[EN] Only apply during the current combatants turn", + "ACTIVEAURAS.FORM_ActivateOnce": "[EN] Only trigger the aura once per turn", "ACTIVEAURAS.ApplyLog":"Active Auras | {effectDataLabel}が{tokenName}に適用されました。", "ACTIVEAURAS.RemoveLog":"Active Auras | {effectDataLabel}が{tokenName}から取り除かれました。", diff --git a/lang/ko.json b/lang/ko.json index e76ec52..57f8d46 100644 --- a/lang/ko.json +++ b/lang/ko.json @@ -30,7 +30,10 @@ "ACTIVEAURAS.FORM_SaveDC": "내성 굴림 난이도", "ACTIVEAURAS.FORM_TypePrompt": "인간형/야수 기타", "ACTIVEAURAS.FORM_RadiusPrompt": "격자 척도로 측정", - "ACTIVEAURAS.FORM_SavePrompt": "str/dex/con/wis/int/cha", + "ACTIVEAURAS.FORM_SavePrompt": "str/dex/con/wis/int/cha", + "ACTIVEAURAS.FORM_TimePrompt": "[EN] Special Expiry for the Applied Effect", + "ACTIVEAURAS.FORM_HostileTurn": "[EN] Only apply during the current combatants turn", + "ACTIVEAURAS.FORM_ActivateOnce": "[EN] Only trigger the aura once per turn", "ACTIVEAURAS.ApplyLog":"ActiveAuras | '{effectDataLabel}' 효과가 {tokenName} 캐릭터에게 적용되었습니다", "ACTIVEAURAS.RemoveLog":"ActiveAuras | '{effectDataLabel}' 효과가 {tokenName} 캐릭터에게 제거되었습니다.", diff --git a/module.json b/module.json index f7e1c94..689e510 100644 --- a/module.json +++ b/module.json @@ -3,7 +3,7 @@ "title": "Active-Auras", "description": "Active-Auras", "author": "Kandashi", - "version": "0.1.51", + "version": "0.1.52", "minimumCoreVersion": "0.7.5", "compatibleCoreVersion": "0.7.9", "packs": [ diff --git a/src/aura.js b/src/aura.js index 8a45fae..7791944 100644 --- a/src/aura.js +++ b/src/aura.js @@ -78,6 +78,18 @@ Hooks.on("ready", () => { const FormTypePrompt = game.i18n.format("ACTIVEAURAS.FORM_TypePrompt") const FormRadiusPrompt = game.i18n.format("ACTIVEAURAS.FORM_RadiusPrompt") const FormSavePrompt = game.i18n.format("ACTIVEAURAS.FORM_SavePrompt") + const FormTimePrompt = game.i18n.format("ACTIVEAURAS.FORM_TimePrompt") + const HostileTurn = game.i18n.format("ACTIVEAURAS.FORM_HostileTurn") + const ActivateOnce = game.i18n.format("ACTIVEAURAS.FORM_ActivateOnce") + if (game.modules.get("dae").active && game.modules.get("times-up").active) { + var isAttacked = game.i18n.format("dae.isAttacked") + var isDamaged = game.i18n.format("dae.isDamaged") + var action = game.i18n.format("dae.1Action") + var attack = game.i18n.format("dae.1Attack") + var hit = game.i18n.format("dae.1Hit") + var turnStart = game.i18n.format("dae.turnStart") + var turnEnd = game.i18n.format("dae.turnEnd") + } const tab = ` ${AuraTab}`; @@ -85,7 +97,7 @@ Hooks.on("ready", () => { let alignment = flags[MODULE_NAME]?.alignment ? flags[MODULE_NAME]?.alignment : ""; let save = flags[MODULE_NAME]?.save ? flags[MODULE_NAME]?.save : ""; - const contents = ` + let contents = `
@@ -136,9 +148,36 @@ Hooks.on("ready", () => {
+
+
+
+ + +
+
+ + +
` + ; + + if (game.modules.get("times-up").active) { + contents += ` +
+ +
- -
`; + ` + } + else contents += `` const appliedAuraContent = `
@@ -180,10 +219,17 @@ Hooks.on("ready", () => { } }); - /** - * @todo - * Filter for aura effects on deleted token and remove from canvas tokens - */ + Hooks.on("updateCombat", async (combat, changed, options, userId) => { + if (!("turn" in changed)) return; + if (!gm) return; + let combatant = canvas.tokens.get(combat.combatant.tokenId); + let previousTurn = combat.turns[changed.turn - 1 > -1 ? changed.turn - 1 : combat.turns.length - 1] + let previousCombatant = canvas.tokens.get(previousTurn.tokenId) + previousCombatant.update({"flags.ActiveAuras" : false }) + if (debug) console.log("updateCombat, main aura") + await MainAura(combatant.data, "combat update") + }); + Hooks.on("preDeleteToken", async (_scene, token) => { if (!gm) return; if (IsAuraToken(token, canvas)) { @@ -576,6 +622,7 @@ Hooks.on("ready", () => { let auraHeight = auraEffect.data.flags?.ActiveAuras?.height; let auraType = auraEffect.data.flags?.ActiveAuras?.type !== undefined ? auraEffect.data.flags?.ActiveAuras?.type.toLowerCase() : ""; let auraAlignment = auraEffect.data.flags?.ActiveAuras?.alignment !== undefined ? auraEffect.data.flags?.ActiveAuras?.alignment.toLowerCase() : ""; + let hostileTurn = auraEffect.data.flags?.ActiveAuras?.hostile //{data: testEffect.data, parentActorLink :testEffect.parent.data.token.actorLink, parentActorId : testEffect.parent._id, tokenId: testToken.id} if (auraEffect.parentActorLink) { @@ -598,6 +645,7 @@ Hooks.on("ready", () => { if (auraTargets === "Enemy" && (auraToken.data.disposition === canvasToken.data.disposition)) continue; if (auraAlignment !== "" && !tokenAlignment.includes(auraAlignment) && !tokenAlignment.includes("any")) continue; if (auraType !== "" && !tokenType.includes(auraType) && !tokenType.includes("any")) continue; + if (hostileTurn && canvasToken.data._id !== game.combats.active.current.tokenId) return; let distance = getDistance(canvasToken, auraToken, game.settings.get("ActiveAuras", "wall-block"), auraHeight) if ((distance !== false) && (distance <= auraRadius)) { if (MapObject) { @@ -746,6 +794,13 @@ Hooks.on("ready", () => { } } ['ignoreSelf', 'hidden', 'height', 'alignment', 'type', 'aura', 'radius', 'save', 'isAura', 'savedc', 'height'].forEach(e => delete effectData.flags.ActiveAuras[e]) + if (effectData.flags.ActiveAuras.time) { + effectData.flags.dae.specialDuration.push(effectData.flags.ActiveAuras.time) + } + if (effectData.flags.ActiveAuras.onlyOnce) { + if (await token.getFlag("ActiveAuras", `${oldEffectData.origin}`)) return; + else await token.setFlag("ActiveAuras", `${oldEffectData.origin}`, true) + } await token.actor.createEmbeddedEntity("ActiveEffect", effectData); console.log(game.i18n.format("ACTIVEAURAS.ApplyLog", { effectDataLabel: effectData.label, tokenName: token.name })) }