Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Temporary Stat Adjuster

1397474382

Edited 1400365909
Hi All, One of my players requested an API that will adjust his constitution, constitution modifier and health every time he uses his ability. So I have quickly whipped this up and would like to share it with you all. This API will also allow you to quickly determine any Ability Score damage or gain and will calculate the modifier decrease or increase and reflect this in temporary adjustment to HP (if CON damage). Just make sure your character sheet attributes for Hit points = HP Hit dice = HD Constitution score = constitution Constitution modifier = con You can change these in the script under tagHP, tagHD etc. but just make sure they are the same in the script and in your character sheet on roll20. How it works: There are four functions to this API 1. Straight stat modifier - !stat HP 10 This will either add or subtract a specific value, or dice roll, to or from the characters attribute. eg. Add 15 or 3d5 temporary hitpoints or 1 temporary AC. 2. Ability Score + ability score modifier calculator and editor - !ability constitution 4 This will change an ability score eg. Dexterity and calculate the change in modifier using (Ability Score - 10)/2 rounding down. This function can also store the modifier to the character if you choose (see example macros). 3. Temporary hit point calculator and editor - !ability constitution 4 con If you specify the character Hit Dice (total level) and Hit Points (health) as attributes AND edit the code in the "Edit Here" section to match these attributes. The code will calculate the total temporary current and max hitpoints gained or lost due to constitution damage. (This is only called if "con" is present in your attribute). 4. Stat Resetter - !resetStats This function will reset the characters stat to their original thus removing the temporary modifiers. This is done by taking the Max attribute value and equating it to the current. Usage: 1. Select token that to have their stats or ability scores modified. 2. Either type in chat or add the following to a macro: "!stat [name of stat] [number or roll]" or "!ability [name of ability] [number or roll] [name of modifier(OPTIONAL)]" (without quotation marks and square brackets). 3. The name of the stat/ability must be in the tokens character sheet attribute. 4. To reset stats type !resetStats to reset all OR !resetStats [name of stat 1] [name of stat 2] .... etc (current value attributes will be reset to max value). eg. macros /em gains temporary hitpoints! !stat hp 1d5 *** This will roll 1d5 in the API and add the result to your hp attribute*** /em takes 4 damage to constitution! !ability constitution -4 *** This will decrease the constitution attribute by 4 and tell you what the new modifier is in chat*** *** If attributes for Hit Points and Hit Dice exists and they correspond to the tagHP and tagHD in the code, temporary health will be calculated too** /em gains ?{roll?|1d4} temporary constitution! !ability constitution ?{roll?|1d4} CON *** This will increase your constitution ability score (constitution) by 1d4 and calculate the modifier (CON) outputting to chat AND store the new modifier to the CON attribute*** *** If attributes for Hit Points and Hit Dice exists and they correspond to the tagHP and tagHD in the code, temporary health will be calculated too** This one is my favourite: /emas @{selected|character_name} takes ?{how much?} damage to ?{What ability?}! !ability ?{What ability?} ?{how much?} ?{modifier?} ***This allows you to specify any type of stat damage as a GM and as long as you're selecting the player's token it will take it from their character. You can type 1d4 in the ?{how much?} prompt or specify a flat damage.*** /emas rests and recovers !resetStats effects of rage wears off. !resetStats constitution strength AC nb. This code does not take inline roles (omit the [[ ]] around your roll eg. [[1d4]] becomes 1d4). Good Luck, GM-King Preview seems to be old code. For updated code click here.
Code updated to reset stats to original.
Great script King. I really like all the scripts you've put together!
So this had been working great for me...but as of last night at least, now any time i try to call a variable through a macro or even just @{CharName|Attr}; I've begun gettting this error: TypeError: undefined is not a function I had also tried using the DCC Helper script to see if that made it better...which it does not - it receives the same error; but if its merely setting an ability to something, it does work just fine. I don't know if this is related to latest dev serve update, but hopefully anyone who has a clue can help sort it! Thanks
1400275657

Edited 1400375295
Thank you Jeremy, I'm having a lot of fun with it! Bennet, I cannot replicate your error. If you would like to send me a personal message with the exact conditions in which you've been getting this error I can try to troubleshoot with you. EDIT: Issue resolved Problem: Incompatibility with HoneyBadger's 4e Powercard script. Current attribute value set by tempStat is of the form int. Powercard requires string. To fix: replacing line 280 of current code: statInitial.set("current", statFinal); to statInitial.set("current", statFinal.toString());
Added selectable reset functionality. eg. type "!resetStats constitution" to reset constitution con mod and HP or type "!resetStats strength str intelligence" to reset strength str and intelligence attributes. Also, added "hiddenOutput" tag that will change all chat output to a gm whisper if desired. Simply change the "var hiddenOutput = false;" to "var hiddenOutput = true;" without the quotation marks. Please go to gist link for updated code. Good luck, King
Is there any way to have the script change the values on a character sheet? For example, the default 3.5 sheets have a column for temporary stats. Also, how do I set up the script for stats besides constituation? Do I just makes copies of the section of the commented block that has constitution, with appropriate replacements for the other stat names?
1402264070

Edited 1402268918
Hi Yoonie, The character sheets are not exactly compatible with this API yet. When the sheet creates a new attribute it does not edit the max value which causes problems. Nevertheless, I would advise using the !stat function with the character sheets: !stat [temporary modifier] [number] eg. !stat tag-str-mod 1 As a side note: to use the !ability function you can interchange constitution with any attribute. eg. !ability strength 1 str or !ability dexterity 1 To do this, strength, str, and dexterity must all be character attributes.