• The VOIDRUNNER'S CODEX is coming! Explore new worlds, fight oppressive empires, fend off fearsome aliens, and wield deadly psionics with this comprehensive boxed set expansion for 5E and A5E!

D&D 5E MPMB's D&D 5e Character Tools

Ok, What("Extra.Magic Item 1") returns the text. I would like to implement a list, like MagicItemList, with different properties. How would I hook that in to be calculated? I haven't reviewed all of your code yet, so I'm not sure how I would get it to trigger.

If I can make a simple structure work, then I'll share my magic items, and over time other people can share as well until we have a complete list.
You will need to add something to the field "Extra.Magic Item 1" so that it triggers a function. Normally I put this trigger in the validation. Adding something like this is possible through JavaScript, so you don't need Acrobat Pro with my new custom code feature. For the Background field, for example, this code is:
Code:
ApplyBackground(event.value);
.

To add a validation to the magic item field, the code would be:
Code:
this.getField("Extra.Magic Item 1").setAction("Validate", "ApplyMagicitem(event.value);");
For more info about the setAction function, see the Acrobat API I linked to above. This does imply that you write your own function called "ApplyMagicitem" and that takes the input of the name of the magic item. You can model it after my code I use to recognize feats, weapons, races, etc. Good luck!
 

log in or register to remove this ad

andargor

Rule Lawyer Groupie
Supporter
Hmm, I tired this as a test, and it doesn't trigger on the field change:

Code:
function ApplyMagicItem(input) {
	var oCk = {
		bInitialValue : true,
		bAfterValue : false
	};	
	app.alert({
		cMsg : input,
		nIcon : 3,
		cTitle : "ApplyMagicitem",
		oCheckbox : oCk
	});
}

this.getField("Extra.Magic Item 1").setAction("Validate", "ApplyMagicItem(event.value);");


EDIT: Got something working, will post when done.
 
Last edited:

andargor

Rule Lawyer Groupie
Supporter
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.

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? 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;
}

EDIT: Tweaked Ring of Protection, added powerful homebrew artifact that gives class features
 
Last edited:

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.

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? I figured it out.

Here's the code, not extensively tested, and not all items, just a few rings, the chimes of opening, etc.
Looks really good, nice work! Are you planning on making all the magic items? If so, I wouldn't mind writing a function for magic items and adding your MagicItemList variable to the sheet :) But that's only if you want to of course.

As for your code, sorry but I didn't know you couldn't define a function using eval. Because the 'user custom code' is loaded at startup using eval, no function you define there can be used globally (only during the eval at startup). Adding the functions to the fields is a smart move!

Is there a reason you want the "All ST Bonus" to be a calculated value? You don't want to give people the ability to change the 1 to anything else? If you are just trying to set the value of the field to a "1", try using the "Value()" formula I defined. It would look like:
Code:
Value("All ST Bonus", 1);
The way you are doing it, is adding a calculation to the field, which is not always necessary (but might be).
 

andargor

Rule Lawyer Groupie
Supporter
Looks really good, nice work! Are you planning on making all the magic items? If so, I wouldn't mind writing a function for magic items and adding your MagicItemList variable to the sheet :) But that's only if you want to of course.

I don't have that kind of time :) But I wanted to show others so that the community could in time do them all, as people develop the ones for their group. Adding the variable is a good idea in any case :)

As for your code, sorry but I didn't know you couldn't define a function using eval. Because the 'user custom code' is loaded at startup using eval, no function you define there can be used globally (only during the eval at startup). Adding the functions to the fields is a smart move!

Yeah, it's a security feature in Adobe.

Is there a reason you want the "All ST Bonus" to be a calculated value? You don't want to give people the ability to change the 1 to anything else? If you are just trying to set the value of the field to a "1", try using the "Value()" formula I defined. It would look like:
Code:
Value("All ST Bonus", 1);
The way you are doing it, is adding a calculation to the field, which is not always necessary (but might be).

To be honest that's the only place that I could figure out, I'll change it. If you have any other suggestions that are more optimal, I'll implement them.
 

It has been a little while since my last post, so let me give you a preview of what I've been working on. The next version, v10, will have some new features that I'm very enthusiastic about!

This next version is not done yet, but:
PREVIEW IS NO LONGER AVAILABLE

The Changelog for v10 (so far) is:
  • Added the option to change the colour of every attack field separately on the first page (use the menu buttons to the side)
  • Added checkmarks to every clickable menu, where appropriate (i.e. a checkmark now appears next to what is already selected, be it the colour, personal trait, fighting style, or whatever)
  • Changed how the ability scores are calculated, making it possible to have nothing filled out and have all calculated fields also be empty. As a result of this, the default value for all ability score fields is no longer 10, but an empty field
  • Changed the default values of many fields so that they are no longer filled when you press reset (or when you download a fresh sheet)
  • Changed the HD area to incorporate the “d” into the field instead of into the graphic (as suggested by SpoCk0nd0pe)
  • Reworked how the calculation of attacks are done, making them somewhat faster
  • Reworked how the manual feature of attacks are done, making it easier to use as it now will mirror the automatically filled stuff when switching to manual (instead of remembering its own values)
  • Fixed a bug where some class abilities didn’t show up in the proper order when added, or weren’t properly altered upon switching subclasses
  • Redesign of the companion page:
    • Changed all cell names and formulas to make calculations faster
    • Added skills
    • Added proficiency bonus
    • Added alignment and type
    • Added automatically calculated attacks, identical in functionality to the attacks on the first page
    • Added automatically addition of racial abilities, with the option to add either a player race or a Beast
  • Added a page for Wild Shapes:
    • Auto-calculate the wild shape stats, proficiencies, bonuses, attacks, etc. etc. upon entering the beast’s name
    • Option to choose from different ways of calculating the wild shape
    • All calculations are added upon selection, but aren’t updated automatically. This is done so that you can change anything about the wild shape that you want
    • Choosing a wild shape can be done from a drop-down list of all the option, as well as via a menu that has them sorted by CR, and mentions if the beast has a fly and/or swim speed

I haven't had time to add all the creature's yet, but more are coming. Until now there are only 13 Beasts to choose from, and only the Air Elemental from the elementals (even though all elementals appear in the menu).
Please take the Wild Shape section for a spin and tell me about any errors, stuff that you think is missing, or other things of interest that you might find. Thank you!

Note that you will need to first define a character on page 1 (at least level 1 and all ability scores filled out), or the wild shapes will not commit (because there is not enough data to work with.
 
Last edited:

I have finished version 10 and it is online now!

MPMB's Character Sheet v10 (9-2-2016) has the following changelog:
  • Added the option to change the colour of every attack field separately on the first page (use the menu buttons to the side)
  • Added checkmarks to every clickable menu, where appropriate (i.e. a checkmark now appears next to what is already selected, be it the colour, personal trait, fighting style, or whatever)
  • Changed how the ability scores are calculated, making it possible to have nothing filled out and have all calculated fields also be empty. As a result of this, the default value for all ability score fields is no longer 10, but an empty field
  • Changed the default values of many fields so that they are no longer filled when you press reset (or when you download a fresh sheet)
  • Changed the HD area to incorporate the “d” into the field instead of into the graphic (as suggested by SpoCk0nd0pe)
  • Reworked how the calculation of attacks are done, making them somewhat faster
  • Reworked how the manual feature of attacks are done, making it easier to use as it now will mirror the automatically filled stuff when switching to manual (instead of remembering its own values)
  • Fixed a bug where some class abilities didn’t show up in the proper order when added, or weren’t properly altered upon switching subclasses
  • Made a change in the startup-code so that the sheet will no longer ask you to save changes if you don’t make any changes
  • Redesign of the companion page:
    • Changed all cell names and formulas to make calculations faster
    • Added skills
    • Added proficiency bonus
    • Added alignment and type
    • Added automatically calculated attacks, identical in functionality to the attacks on the first page
    • Added automatically addition of racial abilities, with the option to add either a player race or a Beast
  • Added a page for Wild Shapes:
    • Auto-calculate the wild shape stats, proficiencies, bonuses, attacks, etc. etc. upon entering the wild shape’s name
    • Option to choose from different ways of calculating the wild shape
    • All calculations are added upon selection, but aren’t updated automatically. This is done so that you can change anything about the wild shape that you want
    • Choosing a wild shape can be done from a drop-down list of all the option, as well as via a menu that has them sorted by CR, and mentions if the beast has a fly and/or swim speed
  • Updated the FAQ with explanation of how the Wild Shape calculations work
  • Updated the JavaScript files you can download with an example of a creature so that anybody can add their own creatures for the companion page and/or as a Wild Shape option

For those with a link to the bonus version, you can use that link to get the bonus version of v10!
 


timmy2383

Villager
YAASSS

Awesomesauce!

I must say, I continue to be impressed. I've been using this for a while now in the campaigns I've been playing in and other smaller adventures.

We've been doing a actual play podcast (low-tech, nothing professional) starting with Princes of the Apocalypse, with the intent of going into it blind and reviewing it as we progressed. We now just started Out of the Abyss. The spell generator and character generator have been such great help for me (especially when I keep having to roll up new ones)! We've had the link to this in our Resources page for a while now, hoping to get more people to use it.

If anyone's interested, feel free to head over to our blog (http://ggnorecast.blogspot.com/?m=0) to see each episode's related post, and some early character build explanations. Or if interested you could subscribe to the podcast or on Soundcloud (https://soundcloud.com/ggnorecast).

I have an old pic of our graveyard, but the first death of the first campaign/season is using the sheet.

The graveyard is probably 3 times that now, most of them using MPMB's character generator sheet.

Anywho, keep up the great work!
 

Attachments

  • blogger-image-1322804077.jpg
    blogger-image-1322804077.jpg
    29.3 KB · Views: 272

andargor

Rule Lawyer Groupie
Supporter
I have finished version 10 and it is online now!

MPMB's Character Sheet v10 (9-2-2016) has the following changelog:
  • Added the option to change the colour of every attack field separately on the first page (use the menu buttons to the side)
  • Added checkmarks to every clickable menu, where appropriate (i.e. a checkmark now appears next to what is already selected, be it the colour, personal trait, fighting style, or whatever)
  • Changed how the ability scores are calculated, making it possible to have nothing filled out and have all calculated fields also be empty. As a result of this, the default value for all ability score fields is no longer 10, but an empty field
  • Changed the default values of many fields so that they are no longer filled when you press reset (or when you download a fresh sheet)
  • Changed the HD area to incorporate the “d” into the field instead of into the graphic (as suggested by SpoCk0nd0pe)
  • Reworked how the calculation of attacks are done, making them somewhat faster
  • Reworked how the manual feature of attacks are done, making it easier to use as it now will mirror the automatically filled stuff when switching to manual (instead of remembering its own values)
  • Fixed a bug where some class abilities didn’t show up in the proper order when added, or weren’t properly altered upon switching subclasses
  • Made a change in the startup-code so that the sheet will no longer ask you to save changes if you don’t make any changes
  • Redesign of the companion page:
    • Changed all cell names and formulas to make calculations faster
    • Added skills
    • Added proficiency bonus
    • Added alignment and type
    • Added automatically calculated attacks, identical in functionality to the attacks on the first page
    • Added automatically addition of racial abilities, with the option to add either a player race or a Beast
  • Added a page for Wild Shapes:
    • Auto-calculate the wild shape stats, proficiencies, bonuses, attacks, etc. etc. upon entering the wild shape’s name
    • Option to choose from different ways of calculating the wild shape
    • All calculations are added upon selection, but aren’t updated automatically. This is done so that you can change anything about the wild shape that you want
    • Choosing a wild shape can be done from a drop-down list of all the option, as well as via a menu that has them sorted by CR, and mentions if the beast has a fly and/or swim speed
  • Updated the FAQ with explanation of how the Wild Shape calculations work
  • Updated the JavaScript files you can download with an example of a creature so that anybody can add their own creatures for the companion page and/or as a Wild Shape option

For those with a link to the bonus version, you can use that link to get the bonus version of v10!

Awesome work! Have you managed to include the MagicItemList variable? It can be empty, but would avoid the initialization I'm doing at every item.
 

Remove ads

Top