var MagicItemList = {
"ring of protection" : {
name : "Ring of Protection",
attunement: true,
description : "You gain a +1 bonus to AC and saving throws while wearing this ring.",
source : ["D", 191],
eval : 'AddACMisc(1,"Ring of Protection","Added by Ring of Protection");Value("All ST Bonus", 1);',
removeeval : 'AddACMisc(0,"Ring of Protection","Added by Ring of Protection");Value("All ST Bonus", 0);'
},
"ring of acid resistance" : {
name: "Ring of Acid Resistance",
attunement: true,
description: "You have resistance to acid damage while wearing this ring.",
source : ["D", 192],
eval : 'AddResistance("Acid", "Ring of Acid Resistance");',
removeeval : 'RemoveResistance("Acid");'
},
"ring of cold resistance" : {
name: "Ring of Cold Resistance",
attunement: true,
description: "You have resistance to cold damage while wearing this ring.",
source : ["D", 192],
eval : 'AddResistance("Cold", "Ring of Cold Resistance");',
removeeval : 'RemoveResistance("Cold");'
},
"ring of feather falling" : {
name: "Ring of Feather Falling",
attunement: true,
description: "When you fall while wearing this ring, you descend 60 feet per round and take no damage from falling.",
source : ["D", 191]
},
"ring of fire resistance" : {
name: "Ring of Fire Resistance",
attunement: true,
description: "You have resistance to fire damage while wearing this ring.",
source : ["D", 192],
eval : 'AddResistance("Fire", "Ring of Fire Resistance");',
removeeval : 'RemoveResistance("Fire");'
},
"ring of force resistance" : {
name: "Ring of Force Resistance",
attunement: true,
description: "You have resistance to force damage while wearing this ring.",
source : ["D", 192],
eval : 'AddResistance("Force", "Ring of Force Resistance");',
removeeval : 'RemoveResistance("Force");'
},
"ring of free action" : {
name: "Ring of Free Action",
attunement: true,
description: "While you wear this ring, difficult terrain doesn't cost you extra movement. In addition, magic can neither reduce your speed nor cause you to be paralyzed or restrained.",
source : ["D", 191]
},
"ring of necrotic resistance" : {
name: "Ring of Necrotic Resistance",
attunement: true,
description: "You have resistance to necrotic damage while wearing this ring.",
source : ["D", 192],
eval : 'AddResistance("Necrotic", "Ring of Necrotic Resistance");',
removeeval : 'RemoveResistance("Necrotic");'
},
"ring of poison resistance" : {
name: "Ring of Poison Resistance",
attunement: true,
description: "You have resistance to poison damage while wearing this ring.",
source : ["D", 192],
eval : 'AddResistance("Poison", "Ring of Poison Resistance");',
removeeval : 'RemoveResistance("Poison");'
},
"ring of psychic resistance" : {
name: "Ring of Psychic Resistance",
attunement: true,
description: "You have resistance to psychic damage while wearing this ring.",
source : ["D", 192],
eval : 'AddResistance("Psychic", "Ring of Psychic Resistance");',
removeeval : 'RemoveResistance("Psychic");'
},
"ring of radiant resistance" : {
name: "Ring of Radiant Resistance",
attunement: true,
description: "You have resistance to radiant damage while wearing this ring.",
source : ["D", 192],
eval : 'AddResistance("Radiant", "Ring of Radiant Resistance");',
removeeval : 'RemoveResistance("Radiant");'
},
"ring of thunder resistance" : {
name: "Ring of Thunder Resistance",
attunement: true,
description: "You have resistance to thunder damage while wearing this ring.",
source : ["D", 192],
eval : 'AddResistance("Thunder", "Ring of Thunder Resistance");',
removeeval : 'RemoveResistance("Thunder");'
},
"chime of opening" : {
name: "Chime of Opening",
attunement: false,
description: "This hollow metal tube measures about 1 foot long and weighs 1 pound. You can strike it as an action, pointing it at an object within 120 feet of you that can be opened, such as a door, lid, or lock. The chime issues a clear tone, and one lock or latch on the object opens unless the sound can't reach the object. If no locks or latches remain, the object itself opens. The chime can be used ten times. After the tenth time it cracks and becomes useless.",
source : ["D", 158]
},
"emerald enclave amulet" : {
name : "Emerald Enclave Amulet",
attunement: true,
description : "Grants Divine Sense and Lay on Hands as a Paladin of the character's level, as well as the Leadership ability from the Knight (MM 347), uttered commands give +d4 to allies on attacks and saves for 1 minute. Increases Charisma by +2.",
source : ["P", 84],
eval : 'Value("Cha",Number(What("Cha"))+2); AddAction("action","Lay On Hands","Emerald Enclave Amulet"); AddFeature("Leadership", 1, "", "SR", "Emerald Enclave Amulet", "update");AddFeature("Divine Sense", 1, "", "LR", "Emerald Enclave Amulet", "update", "event.value = Math.max(1, this.getField(\'Cha Mod\').value);");',
removeeval : 'RemoveAction("action", "Lay On Hands"); RemoveFeature("Leadership"); RemoveFeature("Divine Sense"); Value("Cha",Number(What("Cha"))-2);'
},
};
var MagicItemListStr = "var MagicItemList = MagicItemList || " + JSON.stringify(MagicItemList);
function ApplyMagicItem(num, input) {
var fieldName = "Extra.Magic Item " + num;
var fieldAttunedName = "Extra.Magic Item Attuned " + num;
var fieldDescName = "Extra.Magic Item Description " + num;
var fieldValue = input ? input : What(fieldName);
var previousFieldValue = What(fieldName); /*during Validate we have the last value*/
var curItem = fieldValue.toLowerCase();
var prevItem = previousFieldValue.toLowerCase();
Checkbox(fieldAttunedName, false); /* disable previous item and reset the checkbox */
if (prevItem in MagicItemList) {
if (What(fieldDescName) == MagicItemList[prevItem].description) Value(fieldDescName,"");
if (!MagicItemList[curItem].attunement) eval(MagicItemList[prevItem].removeeval);
}
if (curItem in MagicItemList) {
if ("description" in MagicItemList[curItem]) Value(fieldDescName, MagicItemList[curItem].description);
if (!MagicItemList[curItem].attunement) eval(MagicItemList[curItem].eval);
}
}
var ApplyMagicItemStr = "var ApplyMagicItem = ApplyMagicItem || " + ApplyMagicItem.toString();
function AttuneMagicItem(num, value) {
var fieldName = "Extra.Magic Item " + num;
var fieldValue = What(fieldName);
var curItem = fieldValue.toLowerCase();
if (curItem in MagicItemList && MagicItemList[curItem].attunement) {
if (value == "True") {
eval(MagicItemList[curItem].eval);
} else {
eval(MagicItemList[curItem].removeeval);
}
}
}
var AttuneMagicItemStr = "var AttuneMagicItem = AttuneMagicItem || " + AttuneMagicItem.toString();
for(var i=1;i<50;i++) {
var f = this.getField("Extra.Magic Item " + i);
if (f) f.setAction("Validate", "{" + MagicItemListStr + ";" + ApplyMagicItemStr + "; ApplyMagicItem(" + i + ",event.value); }");
else break;
}
for(var i=1;i<50;i++) {
var f = this.getField("Extra.Magic Item Attuned " + i);
if (f) f.setAction("Validate", "{" + MagicItemListStr + ";" + AttuneMagicItemStr + "; AttuneMagicItem(" + i + ",event.value); }");
else break;
}