let applyChanges = false; let clearDamage = false let template = `
`; new Dialog({ title: "Persistent Damage", content: `` + template, buttons: { ok: { icon: "", label: "Apply", callback: () => applyChanges = true }, cancel: { icon: "", label: "Cancel", }, clear: { icon: "", label: "Clear", callback: () => clearDamage = true }, }, default: "yes", close: html => { if (applyChanges) { if (damage_type.value == "bleeding"){ addAlerts(document.getElementById("damage").value, "bleeding"); token.toggleEffect("content/StatusIcons/Persistent Bleeding.png"); } if (damage_type.value == "fire"){ token.toggleEffect("content/StatusIcons/Persistent Fire.png"); addAlerts(document.getElementById("damage").value, "fire"); } if (damage_type.value == "acid"){ token.toggleEffect("content/StatusIcons/Persistent Acid.png"); addAlerts(document.getElementById("damage").value, "acid"); } if (damage_type.value == "cold"){ token.toggleEffect("content/StatusIcons/Persistent Cold.png"); addAlerts(document.getElementById("damage").value, "cold"); } if (damage_type.value == "electricity"){ token.toggleEffect("content/StatusIcons/Persistent Electricity.png"); addAlerts(document.getElementById("damage").value, "electricity"); } if (damage_type.value == "mental"){ token.toggleEffect("content/StatusIcons/Persistent Mental.png"); addAlerts(document.getElementById("damage").value, "mental"); } if (damage_type.value == "poison"){ token.toggleEffect("content/StatusIcons/Persistent Poison.png"); addAlerts(document.getElementById("damage").value, "poison"); } if (damage_type.value == "piercing"){ addAlerts(document.getElementById("damage").value, "piercing"); token.toggleEffect("content/StatusIcons/Persistent Piercing.png"); } if (damage_type.value == "slashing"){ addAlerts(document.getElementById("damage").value, "slashing"); token.toggleEffect("content/StatusIcons/Persistent Slashing.png"); } if (damage_type.value == "bludgeoning"){ addAlerts(document.getElementById("damage").value, "bludgeoning"); token.toggleEffect("content/StatusIcons/Persistent Bludgeoning.png"); } if (damage_type.value == "good"){ addAlerts(document.getElementById("damage").value, "good"); token.toggleEffect("content/StatusIcons/Persistent Good.png"); } if (damage_type.value == "evil"){ addAlerts(document.getElementById("damage").value, "evil"); token.toggleEffect("content/StatusIcons/Persistent Evil.png"); } if (damage_type.value == "negative"){ addAlerts(document.getElementById("damage").value, "negative"); token.toggleEffect("content/StatusIcons/Persistent Negative.png"); } if (damage_type.value == "positive"){ addAlerts(document.getElementById("damage").value, "positive"); token.toggleEffect("content/StatusIcons/Persistent Positive.png"); } } if (clearDamage) { if (damage_type.value == "bleeding"){ if (token.data.effects.includes("content/StatusIcons/Persistent Bleeding.png")) { token.toggleEffect("content/StatusIcons/Persistent Bleeding.png"); deleteAlert("bleeding",`${token.name}`) } } if (damage_type.value == "fire"){ if (token.data.effects.includes("content/StatusIcons/Persistent Fire.png")) { token.toggleEffect("content/StatusIcons/Persistent Fire.png"); deleteAlert("fire",`${token.name}`) } } if (damage_type.value == "acid"){ if (token.data.effects.includes("content/StatusIcons/Persistent Acid.png")) { token.toggleEffect("content/StatusIcons/Persistent Acid.png"); deleteAlert("acid",`${token.name}`) } } if (damage_type.value == "cold"){ if (token.data.effects.includes("content/StatusIcons/Persistent Cold.png")) { token.toggleEffect("content/StatusIcons/Persistent Cold.png"); deleteAlert("cold",`${token.name}`) } } if (damage_type.value == "electricity"){ if (token.data.effects.includes("content/StatusIcons/Persistent Electricity.png")) { token.toggleEffect("content/StatusIcons/Persistent Electricity.png"); deleteAlert("electricity",`${token.name}`) } } if (damage_type.value == "mental"){ if (token.data.effects.includes("content/StatusIcons/Persistent Mental.png")) { token.toggleEffect("content/StatusIcons/Persistent Mental.png"); deleteAlert("mental",`${token.name}`) } } if (damage_type.value == "poison"){ if (token.data.effects.includes("content/StatusIcons/Persistent Poison.png")) { token.toggleEffect("content/StatusIcons/Persistent Poison.png"); deleteAlert("poison",`${token.name}`) } } if (damage_type.value == "piercing"){ if (token.data.effects.includes("content/StatusIcons/Persistent Piercing.png")) { token.toggleEffect("content/StatusIcons/Persistent Piercing.png"); deleteAlert("piercing",`${token.name}`) } } if (damage_type.value == "slashing"){ if (token.data.effects.includes("content/StatusIcons/Persistent Slashing.png")) { token.toggleEffect("content/StatusIcons/Persistent Slashing.png"); deleteAlert("slashing",`${token.name}`) } } if (damage_type.value == "bludgeoning"){ if (token.data.effects.includes("content/StatusIcons/Persistent Bludgeoning.png")) { token.toggleEffect("content/StatusIcons/Persistent Bludgeoning.png"); deleteAlert("bludgeoning",`${token.name}`) } } if (damage_type.value == "good"){ if (token.data.effects.includes("content/StatusIcons/Persistent Good.png")) { token.toggleEffect("content/StatusIcons/Persistent Good.png"); deleteAlert("good",`${token.name}`) } } if (damage_type.value == "evil"){ if (token.data.effects.includes("content/StatusIcons/Persistent Evil.png")) { token.toggleEffect("content/StatusIcons/Persistent Evil.png"); deleteAlert("evil",`${token.name}`) } } if (damage_type.value == "negative"){ if (token.data.effects.includes("content/StatusIcons/Persistent Negative.png")) { token.toggleEffect("content/StatusIcons/Persistent Negative.png"); deleteAlert("negative",`${token.name}`) } } if (damage_type.value == "positive"){ if (token.data.effects.includes("content/StatusIcons/Persistent Positive.png")) { token.toggleEffect("content/StatusIcons/Persistent Positive.png"); deleteAlert("positive",`${token.name}`) } } } } },{ id: 'pf2-template-creator' }).render(true); function addAlerts(damage, type) { if (!game.combat) { ui.notifications.warn("No combat currently active.") return } canvas.tokens.controlled.forEach(t => { addAlert(damage, type, t); }); } function addAlert(damage, type, t) { const text = t.data.name + " takes [[/r " + damage + "#"+type+" damage]] persistent " + type + " damage.