Menu
News
All News
Dungeons & Dragons
Level Up: Advanced 5th Edition
Pathfinder
Starfinder
Warhammer
2d20 System
Year Zero Engine
Industry News
Reviews
Dragon Reflections
White Dwarf Reflections
Columns
Weekly Digests
Weekly News Digest
Freebies, Sales & Bundles
RPG Print News
RPG Crowdfunding News
Game Content
ENterplanetary DimENsions
Mythological Figures
Opinion
Worlds of Design
Peregrine's Nest
RPG Evolution
Other Columns
From the Freelancing Frontline
Monster ENcyclopedia
WotC/TSR Alumni Look Back
4 Hours w/RSD (Ryan Dancey)
The Road to 3E (Jonathan Tweet)
Greenwood's Realms (Ed Greenwood)
Drawmij's TSR (Jim Ward)
Community
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions, OSR, & D&D Variants
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Resources
Wiki
Pages
Latest activity
Media
New media
New comments
Search media
Downloads
Latest reviews
Search resources
EN Publishing
Store
EN5ider
Adventures in ZEITGEIST
Awfully Cheerful Engine
What's OLD is NEW
Judge Dredd & The Worlds Of 2000AD
War of the Burning Sky
Level Up: Advanced 5E
Events & Releases
Upcoming Events
Private Events
Featured Events
Socials!
EN Publishing
Twitter
BlueSky
Facebook
Instagram
EN World
BlueSky
YouTube
Facebook
Twitter
Twitch
Podcast
Features
Top 5 RPGs Compiled Charts 2004-Present
Adventure Game Industry Market Research Summary (RPGs) V1.0
Ryan Dancey: Acquiring TSR
Q&A With Gary Gygax
D&D Rules FAQs
TSR, WotC, & Paizo: A Comparative History
D&D Pronunciation Guide
Million Dollar TTRPG Kickstarters
Tabletop RPG Podcast Hall of Fame
Eric Noah's Unofficial D&D 3rd Edition News
D&D in the Mainstream
D&D & RPG History
About Morrus
Log in
Register
What's new
Search
Search
Search titles only
By:
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions, OSR, & D&D Variants
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Menu
Log in
Register
Install the app
Install
Upgrade your account to a Community Supporter account and remove most of the site ads.
Community
General Tabletop Discussion
*Dungeons & Dragons
MPMB's D&D 5e Character Tools
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="andargor" data-source="post: 6812810" data-attributes="member: 7231"><p>This is working for me, however I find it messy. The problem is that the functions to call in setAction have to be evaluated and in scope at execution. So I made stringified functions assigned to variables and stuffed them in all setAction entries, although they don't get initialized/compiled if they already exist in context.</p><p></p><p><s>There is one thing I can't get to work with the Ring of Protection: the SetCalcMod("All ST Bonus", event.value = 1); entry is not working. What's the best way to add +1 to all saves?</s> I figured it out.</p><p></p><p>Here's the code, not extensively tested, and not all items, just a few rings, the chimes of opening, etc.</p><p></p><p>[code]</p><p>var MagicItemList = {</p><p> "ring of protection" : {</p><p> name : "Ring of Protection",</p><p> attunement: true,</p><p> description : "You gain a +1 bonus to AC and saving throws while wearing this ring.",</p><p> source : ["D", 191],</p><p> eval : 'AddACMisc(1,"Ring of Protection","Added by Ring of Protection");Value("All ST Bonus", 1);',</p><p> removeeval : 'AddACMisc(0,"Ring of Protection","Added by Ring of Protection");Value("All ST Bonus", 0);' </p><p> },</p><p> "ring of acid resistance" : {</p><p> name: "Ring of Acid Resistance",</p><p> attunement: true,</p><p> description: "You have resistance to acid damage while wearing this ring.",</p><p> source : ["D", 192],</p><p> eval : 'AddResistance("Acid", "Ring of Acid Resistance");',</p><p> removeeval : 'RemoveResistance("Acid");'</p><p> },</p><p> "ring of cold resistance" : {</p><p> name: "Ring of Cold Resistance",</p><p> attunement: true,</p><p> description: "You have resistance to cold damage while wearing this ring.",</p><p> source : ["D", 192],</p><p> eval : 'AddResistance("Cold", "Ring of Cold Resistance");',</p><p> removeeval : 'RemoveResistance("Cold");'</p><p> },</p><p> "ring of feather falling" : {</p><p> name: "Ring of Feather Falling",</p><p> attunement: true,</p><p> description: "When you fall while wearing this ring, you descend 60 feet per round and take no damage from falling.",</p><p> source : ["D", 191]</p><p> },</p><p> "ring of fire resistance" : {</p><p> name: "Ring of Fire Resistance",</p><p> attunement: true,</p><p> description: "You have resistance to fire damage while wearing this ring.",</p><p> source : ["D", 192],</p><p> eval : 'AddResistance("Fire", "Ring of Fire Resistance");',</p><p> removeeval : 'RemoveResistance("Fire");'</p><p> },</p><p> "ring of force resistance" : {</p><p> name: "Ring of Force Resistance",</p><p> attunement: true,</p><p> description: "You have resistance to force damage while wearing this ring.",</p><p> source : ["D", 192],</p><p> eval : 'AddResistance("Force", "Ring of Force Resistance");',</p><p> removeeval : 'RemoveResistance("Force");'</p><p> },</p><p> "ring of free action" : {</p><p> name: "Ring of Free Action",</p><p> attunement: true,</p><p> 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.",</p><p> source : ["D", 191]</p><p> },</p><p> "ring of necrotic resistance" : {</p><p> name: "Ring of Necrotic Resistance",</p><p> attunement: true,</p><p> description: "You have resistance to necrotic damage while wearing this ring.",</p><p> source : ["D", 192],</p><p> eval : 'AddResistance("Necrotic", "Ring of Necrotic Resistance");',</p><p> removeeval : 'RemoveResistance("Necrotic");'</p><p> },</p><p> "ring of poison resistance" : {</p><p> name: "Ring of Poison Resistance",</p><p> attunement: true,</p><p> description: "You have resistance to poison damage while wearing this ring.",</p><p> source : ["D", 192],</p><p> eval : 'AddResistance("Poison", "Ring of Poison Resistance");',</p><p> removeeval : 'RemoveResistance("Poison");'</p><p> },</p><p> "ring of psychic resistance" : {</p><p> name: "Ring of Psychic Resistance",</p><p> attunement: true,</p><p> description: "You have resistance to psychic damage while wearing this ring.",</p><p> source : ["D", 192],</p><p> eval : 'AddResistance("Psychic", "Ring of Psychic Resistance");',</p><p> removeeval : 'RemoveResistance("Psychic");'</p><p> },</p><p> "ring of radiant resistance" : {</p><p> name: "Ring of Radiant Resistance",</p><p> attunement: true,</p><p> description: "You have resistance to radiant damage while wearing this ring.",</p><p> source : ["D", 192],</p><p> eval : 'AddResistance("Radiant", "Ring of Radiant Resistance");',</p><p> removeeval : 'RemoveResistance("Radiant");'</p><p> },</p><p> "ring of thunder resistance" : {</p><p> name: "Ring of Thunder Resistance",</p><p> attunement: true,</p><p> description: "You have resistance to thunder damage while wearing this ring.",</p><p> source : ["D", 192],</p><p> eval : 'AddResistance("Thunder", "Ring of Thunder Resistance");',</p><p> removeeval : 'RemoveResistance("Thunder");'</p><p> },</p><p> "chime of opening" : {</p><p> name: "Chime of Opening",</p><p> attunement: false,</p><p> 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.",</p><p> source : ["D", 158]</p><p> },</p><p> "emerald enclave amulet" : {</p><p> name : "Emerald Enclave Amulet",</p><p> attunement: true,</p><p> 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.",</p><p> source : ["P", 84],</p><p> 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);");',</p><p> removeeval : 'RemoveAction("action", "Lay On Hands"); RemoveFeature("Leadership"); RemoveFeature("Divine Sense"); Value("Cha",Number(What("Cha"))-2);'</p><p> }, </p><p>};</p><p>var MagicItemListStr = "var MagicItemList = MagicItemList || " + JSON.stringify(MagicItemList);</p><p></p><p>function ApplyMagicItem(num, input) {</p><p> var fieldName = "Extra.Magic Item " + num;</p><p> var fieldAttunedName = "Extra.Magic Item Attuned " + num;</p><p> var fieldDescName = "Extra.Magic Item Description " + num;</p><p> </p><p> var fieldValue = input ? input : What(fieldName);</p><p> var previousFieldValue = What(fieldName); /*during Validate we have the last value*/</p><p> </p><p> var curItem = fieldValue.toLowerCase();</p><p> var prevItem = previousFieldValue.toLowerCase();</p><p></p><p> Checkbox(fieldAttunedName, false); /* disable previous item and reset the checkbox */</p><p> </p><p> if (prevItem in MagicItemList) {</p><p> if (What(fieldDescName) == MagicItemList[prevItem].description) Value(fieldDescName,"");</p><p> if (!MagicItemList[curItem].attunement) eval(MagicItemList[prevItem].removeeval);</p><p> }</p><p> </p><p> if (curItem in MagicItemList) {</p><p> if ("description" in MagicItemList[curItem]) Value(fieldDescName, MagicItemList[curItem].description);</p><p> if (!MagicItemList[curItem].attunement) eval(MagicItemList[curItem].eval);</p><p> }</p><p>}</p><p>var ApplyMagicItemStr = "var ApplyMagicItem = ApplyMagicItem || " + ApplyMagicItem.toString();</p><p></p><p>function AttuneMagicItem(num, value) {</p><p> var fieldName = "Extra.Magic Item " + num;</p><p> var fieldValue = What(fieldName);</p><p> var curItem = fieldValue.toLowerCase();</p><p></p><p> if (curItem in MagicItemList && MagicItemList[curItem].attunement) {</p><p> if (value == "True") {</p><p> eval(MagicItemList[curItem].eval);</p><p> } else {</p><p> eval(MagicItemList[curItem].removeeval);</p><p> }</p><p> }</p><p>}</p><p>var AttuneMagicItemStr = "var AttuneMagicItem = AttuneMagicItem || " + AttuneMagicItem.toString();</p><p></p><p>for(var i=1;i<50;i++) {</p><p> var f = this.getField("Extra.Magic Item " + i);</p><p> if (f) f.setAction("Validate", "{" + MagicItemListStr + ";" + ApplyMagicItemStr + "; ApplyMagicItem(" + i + ",event.value); }");</p><p> else break;</p><p>}</p><p></p><p>for(var i=1;i<50;i++) {</p><p> var f = this.getField("Extra.Magic Item Attuned " + i);</p><p> if (f) f.setAction("Validate", "{" + MagicItemListStr + ";" + AttuneMagicItemStr + "; AttuneMagicItem(" + i + ",event.value); }");</p><p> else break;</p><p>}</p><p>[/code]</p><p></p><p>EDIT: Tweaked Ring of Protection, added powerful homebrew artifact that gives class features</p></blockquote><p></p>
[QUOTE="andargor, post: 6812810, member: 7231"] This is working for me, however I find it messy. The problem is that the functions to call in setAction have to be evaluated and in scope at execution. So I made stringified functions assigned to variables and stuffed them in all setAction entries, although they don't get initialized/compiled if they already exist in context. [S]There is one thing I can't get to work with the Ring of Protection: the SetCalcMod("All ST Bonus", event.value = 1); entry is not working. What's the best way to add +1 to all saves?[/s] I figured it out. Here's the code, not extensively tested, and not all items, just a few rings, the chimes of opening, etc. [code] 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; } [/code] EDIT: Tweaked Ring of Protection, added powerful homebrew artifact that gives class features [/QUOTE]
Insert quotes…
Verification
Post reply
Community
General Tabletop Discussion
*Dungeons & Dragons
MPMB's D&D 5e Character Tools
Top