diff --git a/5th Edition OGL by Roll20/5th Edition OGL by Roll20.html b/5th Edition OGL by Roll20/5th Edition OGL by Roll20.html index 5ab2588dfe..28438306db 100644 --- a/5th Edition OGL by Roll20/5th Edition OGL by Roll20.html +++ b/5th Edition OGL by Roll20/5th Edition OGL by Roll20.html @@ -6475,80 +6475,78 @@ update_ac(); }); - on("change:repeating_spell-cantrip:spellname change:repeating_spell-1:spellname change:repeating_spell-1:spellprepared change:repeating_spell-2:spellname change:repeating_spell-2:spellprepared change:repeating_spell-3:spellname change:repeating_spell-3:spellprepared change:repeating_spell-4:spellname change:repeating_spell-4:spellprepared change:repeating_spell-5:spellname change:repeating_spell-5:spellprepared change:repeating_spell-6:spellname change:repeating_spell-6:spellprepared change:repeating_spell-7:spellname change:repeating_spell-7:spellprepared change:repeating_spell-8:spellname change:repeating_spell-8:spellprepared change:repeating_spell-9:spellname change:repeating_spell-9:spellprepared change:repeating_spell-cantrip:spellrange change:repeating_spell-1:spellrange change:repeating_spell-2:spellrange change:repeating_spell-3:spellrange change:repeating_spell-4:spellrange change:repeating_spell-5:spellrange change:repeating_spell-6:spellrange change:repeating_spell-7:spellrange change:repeating_spell-8:spellrange change:repeating_spell-9:spellrange change:repeating_spell-cantrip:spelltarget change:repeating_spell-1:spelltarget change:repeating_spell-2:spelltarget change:repeating_spell-3:spelltarget change:repeating_spell-4:spelltarget change:repeating_spell-5:spelltarget change:repeating_spell-6:spelltarget change:repeating_spell-7:spelltarget change:repeating_spell-8:spelltarget change:repeating_spell-9:spelltarget change:repeating_spell-cantrip:spelldamage change:repeating_spell-1:spelldamage change:repeating_spell-2:spelldamage change:repeating_spell-3:spelldamage change:repeating_spell-4:spelldamage change:repeating_spell-5:spelldamage change:repeating_spell-6:spelldamage change:repeating_spell-7:spelldamage change:repeating_spell-8:spelldamage change:repeating_spell-9:spelldamage change:repeating_spell-cantrip:spelldamagetype change:repeating_spell-1:spelldamagetype change:repeating_spell-2:spelldamagetype change:repeating_spell-3:spelldamagetype change:repeating_spell-4:spelldamagetype change:repeating_spell-5:spelldamagetype change:repeating_spell-6:spelldamagetype change:repeating_spell-7:spelldamagetype change:repeating_spell-8:spelldamagetype change:repeating_spell-9:spelldamagetype change:repeating_spell-cantrip:spelldamage2 change:repeating_spell-1:spelldamage2 change:repeating_spell-2:spelldamage2 change:repeating_spell-3:spelldamage2 change:repeating_spell-4:spelldamage2 change:repeating_spell-5:spelldamage2 change:repeating_spell-6:spelldamage2 change:repeating_spell-7:spelldamage2 change:repeating_spell-8:spelldamage2 change:repeating_spell-9:spelldamage2 change:repeating_spell-cantrip:spelldamagetype2 change:repeating_spell-1:spelldamagetype2 change:repeating_spell-2:spelldamagetype2 change:repeating_spell-3:spelldamagetype2 change:repeating_spell-4:spelldamagetype2 change:repeating_spell-5:spelldamagetype2 change:repeating_spell-6:spelldamagetype2 change:repeating_spell-7:spelldamagetype2 change:repeating_spell-8:spelldamagetype2 change:repeating_spell-9:spelldamagetype2 change:repeating_spell-cantrip:spellhealing change:repeating_spell-1:spellhealing change:repeating_spell-2:spellhealing change:repeating_spell-3:spellhealing change:repeating_spell-4:spellhealing change:repeating_spell-5:spellhealing change:repeating_spell-6:spellhealing change:repeating_spell-7:spellhealing change:repeating_spell-8:spellhealing change:repeating_spell-9:spellhealing change:repeating_spell-cantrip:spelldmgmod change:repeating_spell-1:spelldmgmod change:repeating_spell-2:spelldmgmod change:repeating_spell-3:spelldmgmod change:repeating_spell-4:spelldmgmod change:repeating_spell-5:spelldmgmod change:repeating_spell-6:spelldmgmod change:repeating_spell-7:spelldmgmod change:repeating_spell-8:spelldmgmod change:repeating_spell-9:spelldmgmod change:repeating_spell-cantrip:spellsave change:repeating_spell-1:spellsave change:repeating_spell-2:spellsave change:repeating_spell-3:spellsave change:repeating_spell-4:spellsave change:repeating_spell-5:spellsave change:repeating_spell-6:spellsave change:repeating_spell-7:spellsave change:repeating_spell-8:spellsave change:repeating_spell-9:spellsave change:repeating_spell-cantrip:spellsavesuccess change:repeating_spell-1:spellsavesuccess change:repeating_spell-2:spellsavesuccess change:repeating_spell-3:spellsavesuccess change:repeating_spell-4:spellsavesuccess change:repeating_spell-5:spellsavesuccess change:repeating_spell-6:spellsavesuccess change:repeating_spell-7:spellsavesuccess change:repeating_spell-8:spellsavesuccess change:repeating_spell-9:spellsavesuccess change:repeating_spell-cantrip:spellhldie change:repeating_spell-1:spellhldie change:repeating_spell-2:spellhldie change:repeating_spell-3:spellhldie change:repeating_spell-4:spellhldie change:repeating_spell-5:spellhldie change:repeating_spell-6:spellhldie change:repeating_spell-7:spellhldie change:repeating_spell-8:spellhldie change:repeating_spell-9:spellhldie change:repeating_spell-cantrip:spellhldietype change:repeating_spell-1:spellhldietype change:repeating_spell-2:spellhldietype change:repeating_spell-3:spellhldietype change:repeating_spell-4:spellhldietype change:repeating_spell-5:spellhldietype change:repeating_spell-6:spellhldietype change:repeating_spell-7:spellhldietype change:repeating_spell-8:spellhldietype change:repeating_spell-9:spellhldietype change:repeating_spell-cantrip:spell_updateflag change:repeating_spell-1:spell_updateflag change:repeating_spell-2:spell_updateflag change:repeating_spell-3:spell_updateflag change:repeating_spell-4:spell_updateflag change:repeating_spell-5:spell_updateflag change:repeating_spell-6:spell_updateflag change:repeating_spell-7:spell_updateflag change:repeating_spell-8:spell_updateflag change:repeating_spell-9:spell_updateflag change:repeating_spell-cantrip:spellattack change:repeating_spell-1:spellattack change:repeating_spell-2:spellattack change:repeating_spell-3:spellattack change:repeating_spell-4:spellattack change:repeating_spell-5:spellattack change:repeating_spell-6:spellattack change:repeating_spell-7:spellattack change:repeating_spell-8:spellattack change:repeating_spell-9:spellattack change:repeating_spell-cantrip:spellhlbonus change:repeating_spell-1:spellhlbonus change:repeating_spell-2:spellhlbonus change:repeating_spell-3:spellhlbonus change:repeating_spell-4:spellhlbonus change:repeating_spell-5:spellhlbonus change:repeating_spell-6:spellhlbonus change:repeating_spell-7:spellhlbonus change:repeating_spell-8:spellhlbonus change:repeating_spell-9:spellhlbonus change:repeating_spell-cantrip:includedesc change:repeating_spell-1:includedesc change:repeating_spell-2:includedesc change:repeating_spell-3:includedesc change:repeating_spell-4:includedesc change:repeating_spell-5:includedesc change:repeating_spell-6:includedesc change:repeating_spell-7:includedesc change:repeating_spell-8:includedesc change:repeating_spell-9:includedesc change:repeating_spell-cantrip:spellathigherlevels change:repeating_spell-1:spellathigherlevels change:repeating_spell-2:spellathigherlevels change:repeating_spell-3:spellathigherlevels change:repeating_spell-4:spellathigherlevels change:repeating_spell-5:spellathigherlevels change:repeating_spell-6:spellathigherlevels change:repeating_spell-7:spellathigherlevels change:repeating_spell-8:spellathigherlevels change:repeating_spell-9:spellathigherlevels change:repeating_spell-cantrip:spelldescription change:repeating_spell-1:spelldescription change:repeating_spell-2:spelldescription change:repeating_spell-3:spelldescription change:repeating_spell-4:spelldescription change:repeating_spell-5:spelldescription change:repeating_spell-6:spelldescription change:repeating_spell-7:spelldescription change:repeating_spell-8:spelldescription change:repeating_spell-9:spelldescription change:repeating_spell-cantrip:innate change:repeating_spell-1:innate change:repeating_spell-2:innate change:repeating_spell-3:innate change:repeating_spell-4:innate change:repeating_spell-5:innate change:repeating_spell-6:innate change:repeating_spell-7:innate change:repeating_spell-8:innate change:repeating_spell-9:innate change:repeating_spell-cantrip:spell_ability change:repeating_spell-1:spell_ability change:repeating_spell-2:spell_ability change:repeating_spell-3:spell_ability change:repeating_spell-4:spell_ability change:repeating_spell-5:spell_ability change:repeating_spell-6:spell_ability change:repeating_spell-7:spell_ability change:repeating_spell-8:spell_ability change:repeating_spell-9:spell_ability change:repeating_spell-cantrip:spell_damage_progression", function(eventinfo) { - if(eventinfo.sourceType && eventinfo.sourceType === "sheetworker") { - return; - } - var regex_result = /^(repeating_spell-(?:cantrip|\d)_[^_]+)_.+$/.exec(eventinfo.sourceAttribute); - if(regex_result) { - var repeating_source = regex_result[1]; + ['spell-cantrip','spell-1','spell-2','spell-3','spell-4','spell-5','spell-6','spell-7','spell-8','spell-9'].forEach(attr => { + on(`change:repeating_${attr}:includedesc change:repeating_${attr}:innate change:repeating_${attr}:spell_ability change:repeating_${attr}:spell_updateflag change:repeating_${attr}:spellathigherlevels change:repeating_${attr}:spellattack change:repeating_${attr}:spelldamage change:repeating_${attr}:spelldamage2 change:repeating_${attr}:spelldamagetype change:repeating_${attr}:spelldamagetype2 change:repeating_${attr}:spelldescription change:repeating_${attr}:spelldmgmod change:repeating_${attr}:spellhealing change:repeating_${attr}:spellhlbonus change:repeating_${attr}:spellhldie change:repeating_${attr}:spellhldietype change:repeating_${attr}:spellname change:repeating_${attr}:spellprepared change:repeating_${attr}:spellrange change:repeating_${attr}:spellsave change:repeating_${attr}:spellsavesuccess change:repeating_${attr}:spelltarget change:repeating_${attr}:spell_damage_progression`, (eventinfo) => { + if(eventinfo.sourceType && eventinfo.sourceType === "sheetworker") { return; } + + const spellid = eventinfo.sourceAttribute.split("_")[2], repeating_source = `repeating_${attr}_${spellid}`; getAttrs([repeating_source + "_spellattackid", repeating_source + "_spelllevel"], function(v) { - var spellid = repeating_source.slice(-20); var attackid = v[repeating_source + "_spellattackid"]; - var lvl = v[repeating_source + "_spelllevel"]; + var lvl = v[repeating_source + "_spelllevel"]; + + console.log(`%c Spell change: ${spellid}, ${attackid}, ${lvl} `, "color:purple; font-weight:bold;"); + if(attackid && lvl && spellid) { update_attack_from_spell(lvl, spellid, attackid) } }); - } - }); - - on("change:repeating_spell-cantrip:spelloutput change:repeating_spell-1:spelloutput change:repeating_spell-2:spelloutput change:repeating_spell-3:spelloutput change:repeating_spell-4:spelloutput change:repeating_spell-5:spelloutput change:repeating_spell-6:spelloutput change:repeating_spell-7:spelloutput change:repeating_spell-8:spelloutput change:repeating_spell-9:spelloutput", function(eventinfo) { - if(eventinfo.sourceType && eventinfo.sourceType === "sheetworker") { - return; - } - var repeating_source = eventinfo.sourceAttribute.substring(0, eventinfo.sourceAttribute.lastIndexOf('_')); - getAttrs([repeating_source + "_spellattackid", repeating_source + "_spelllevel", repeating_source + "_spelloutput", repeating_source + "_spellattackid", repeating_source + "_spellathigherlevels","character_id"], function(v) { - var update = {}; - var spelloutput = v[repeating_source + "_spelloutput"]; - var spellid = repeating_source.slice(-20); - var attackid = v[repeating_source + "_spellattackid"]; - var lvl = v[repeating_source + "_spelllevel"]; - if(spelloutput && spelloutput === "ATTACK") { - create_attack_from_spell(lvl, spellid, v["character_id"]); - } - else if(spelloutput && spelloutput === "SPELLCARD" && attackid && attackid != "") { - remove_attack(attackid); - var spelllevel = "@{spelllevel}"; - if(v[repeating_source + "_spellathigherlevels"]) { - var lvl = parseInt(v[repeating_source + "_spelllevel"],10); - spelllevel = "?{Cast at what level?"; - for(i = 0; i < 10-lvl; i++) { - spelllevel = spelllevel + "|Level " + (parseInt(i, 10) + parseInt(lvl, 10)) + "," + (parseInt(i, 10) + parseInt(lvl, 10)); - } - spelllevel = spelllevel + "}"; - } - update[repeating_source + "_rollcontent"] = "@{wtype}&{template:spell} {{level=@{spellschool} " + spelllevel + "}} {{name=@{spellname}}} {{castingtime=@{spellcastingtime}}} {{range=@{spellrange}}} {{target=@{spelltarget}}} @{spellcomp_v} @{spellcomp_s} @{spellcomp_m} {{material=@{spellcomp_materials}}} {{duration=@{spellduration}}} {{description=@{spelldescription}}} {{athigherlevels=@{spellathigherlevels}}} @{spellritual} {{innate=@{innate}}} @{spellconcentration} @{charname_output}"; - } - setAttrs(update, {silent: true}); }); }); - on("change:repeating_spell-cantrip:spellathigherlevels change:repeating_spell-1:spellathigherlevels change:repeating_spell-2:spellathigherlevels change:repeating_spell-3:spellathigherlevels change:repeating_spell-4:spellathigherlevels change:repeating_spell-5:spellathigherlevels change:repeating_spell-6:spellathigherlevels change:repeating_spell-7:spellathigherlevels change:repeating_spell-8:spellathigherlevels change:repeating_spell-9:spellathigherlevels", function(eventinfo) { - if(eventinfo.sourceType && eventinfo.sourceType === "sheetworker") { - return; - } - var repeating_source = eventinfo.sourceAttribute.substring(0, eventinfo.sourceAttribute.lastIndexOf('_')); - getAttrs([repeating_source + "_spelllevel", repeating_source + "_spelloutput", repeating_source + "_spellathigherlevels"], function(v) { - var update = {}; - var spelloutput = v[repeating_source + "_spelloutput"]; - var lvl = v[repeating_source + "_spelllevel"]; - if(spelloutput && spelloutput === "SPELLCARD") { - var spelllevel = "@{spelllevel}"; - if(v[repeating_source + "_spellathigherlevels"]) { - var lvl = parseInt(v[repeating_source + "_spelllevel"],10); - spelllevel = "?{Cast at what level?"; - for(i = 0; i < 10-lvl; i++) { - spelllevel = spelllevel + "|Level " + (parseInt(i, 10) + parseInt(lvl, 10)) + "," + (parseInt(i, 10) + parseInt(lvl, 10)); - } - spelllevel = spelllevel + "}"; + ['spell-cantrip','spell-1','spell-2','spell-3','spell-4','spell-5','spell-6','spell-7','spell-8','spell-9'].forEach(attr => { + on(`change:repeating_${attr}:spelloutput`, (eventinfo) => { + if(eventinfo.sourceType && eventinfo.sourceType === "sheetworker") {return;} + + const spellid = eventinfo.sourceAttribute.split("_")[2], repeating_source = `repeating_${attr}_${spellid}`; + getAttrs([`${repeating_source}_spellattackid`, `${repeating_source}_spelllevel`, `${repeating_source}_spellathigherlevels`, "character_id"], function(v) { + const attackid = v[repeating_source + "_spellattackid"]; + const higherlevels = v[repeating_source + "_spellathigherlevels"]; + const lvl = parseInt(v[repeating_source + "_spelllevel"], 10); + const spelloutput = eventinfo.newValue; + + if (spelloutput && spelloutput === "ATTACK") { + create_attack_from_spell(lvl, spellid, v["character_id"]); + } else if (spelloutput && spelloutput === "SPELLCARD" && attackid && attackid != "") { + remove_attack(attackid); + update_spelloutput(higherlevels, lvl, repeating_source, spelloutput); } - update[repeating_source + "_rollcontent"] = "@{wtype}&{template:spell} {{level=@{spellschool} " + spelllevel + "}} {{name=@{spellname}}} {{castingtime=@{spellcastingtime}}} {{range=@{spellrange}}} {{target=@{spelltarget}}} @{spellcomp_v} @{spellcomp_s} @{spellcomp_m} {{material=@{spellcomp_materials}}} {{duration=@{spellduration}}} {{description=@{spelldescription}}} {{athigherlevels=@{spellathigherlevels}}} @{spellritual} {{innate=@{innate}}} @{spellconcentration} @{charname_output}"; - } - setAttrs(update, {silent: true}); + }); }); }); + ['spell-cantrip','spell-1','spell-2','spell-3','spell-4','spell-5','spell-6','spell-7','spell-8','spell-9'].forEach(attr => { + on(`change:repeating_${attr}:spellathigherlevels`, (eventinfo) => { + if(eventinfo.sourceType && eventinfo.sourceType === "sheetworker") {return;} + + const spellid = eventinfo.sourceAttribute.split("_")[2], repeating_source = `repeating_${attr}_${spellid}`; + getAttrs([`${repeating_source}_spelllevel`, `${repeating_source}_spelloutput`], function(v) { + const higherlevels = eventinfo.newValue; + const lvl = parseInt(v[repeating_source + "_spelllevel"], 10); + const spelloutput = v[repeating_source + "_spelloutput"]; + + if (spelloutput && spelloutput === "SPELLCARD") { + update_spelloutput(higherlevels, lvl, repeating_source, spelloutput); + } + }); + }); + }); + + const update_spelloutput = (higherlevels, lvl, repeating_source, spelloutput) => { + let spelllevel = "@{spelllevel}"; + let update = {}; + + if (higherlevels) { + for(i = 0; i < 10-lvl; i++) { + let tot = parseInt(i, 10) + parseInt(lvl, 10); + spelllevel = spelllevel + "|Level " + tot + "," + tot; + } + spelllevel = `?{Cast at what level? ${spelllevel}}`; + } + update[repeating_source + "_rollcontent"] = "@{wtype}&{template:spell} {{level=@{spellschool} " + spelllevel + "}} {{name=@{spellname}}} {{castingtime=@{spellcastingtime}}} {{range=@{spellrange}}} {{target=@{spelltarget}}} @{spellcomp_v} @{spellcomp_s} @{spellcomp_m} {{material=@{spellcomp_materials}}} {{duration=@{spellduration}}} {{description=@{spelldescription}}} {{athigherlevels=@{spellathigherlevels}}} @{spellritual} {{innate=@{innate}}} @{spellconcentration} @{charname_output}"; + + setAttrs(update, {silent: true}); + }; + on("change:class change:custom_class change:cust_classname change:cust_hitdietype change:cust_spellcasting_ability change:cust_spellslots change:cust_strength_save_prof change:cust_dexterity_save_prof change:cust_constitution_save_prof change:cust_intelligence_save_prof change:cust_wisdom_save_prof change:cust_charisma_save_prof change:subclass change:multiclass1 change:multiclass1_subclass change:multiclass2 change:multiclass2_subclass change:multiclass3 change:multiclass3_subclass" , function(eventinfo) { if(eventinfo.sourceType && eventinfo.sourceType === "sheetworker") { return;