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

5e Durable gift - How to customize hit die roll on the sheet

1619387619

Edited 1619389173
Hi all, Here's my request : I've just gained the gift "durable". The description of this gift is : "When you roll a Hit Die to regain hit points, the minimum number of hit points you regain from the roll equals twice your Constitution modifier (minimum of 2)." On my 5e OGL Character sheet, my DM is using this script automatizing the hitdie roll : on('chat:message', function(msg) { // ROLL LISTENER     if(msg.playerid.toLowerCase() != "api" && msg.rolltemplate) {         var cnamebase = msg.content.split("charname=")[1];         var cname = cnamebase ? cnamebase.replace('}}','').trim() : (msg.content.split("{{name=")[1]||'').split("}}")[0].trim();         var character = cname ? findObjs({name: cname, type: 'character'})[0] : undefined;         if(["simple"].indexOf(msg.rolltemplate) > -1) {             if(_.has(msg,'inlinerolls') && msg.content.indexOf("^{hit-dice-u}") > -1 && character) {                 handlehd(msg,character);             }         }     } }); // CHECK CURRENT HD, DECREMENT HD, THEN APPLY HP var handlehd = function (msg,character) {     var hd = findObjs({type: 'attribute', characterid: character.id, name: "hit_dice"}, {caseInsensitive: true})[0];     var hp = findObjs({type: 'attribute', characterid: character.id, name: "hp"}, {caseInsensitive: true})[0];     if(!hd || hd.get("current")==="" || hd.get("max")==="") {         log("CHARACTER HAS NO HIT_DICE ATTRIBUTE OR HD CURRENT/MAX IS NULL");         sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + "HD attribute on " + character.get("name") + " is missing or current/max values are not filled out, Hit Points were not applied." + "</span></div></div></div>");         return;     }     else if(!hp || hp.get("current")==="" || hp.get("max")==="") {         log("CHARACTER HAS NO HP ATTRIBUTE OR HP CURRENT/MAX IS NULL");         sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + "HP attribute on " + character.get("name") + " is missing or current/max values are not filled out, Hit Points were not applied." + "</span></div></div></div>");         return;     }     else {         var curhd = parseInt(hd.get("current"));         var newhd = curhd - 1;     }     if (curhd === 0) {         sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + character.get("name") + " n'a plus de DV disponible, les PV n'ont pas été ajoutés." + "</span></div></div></div>");     }     else {         hd.set({current:newhd});         var maxhp = parseInt(hp.get("max"));         var curhp = parseInt(hp.get("current"));         var result = msg.inlinerolls[2].results.total ? msg.inlinerolls[2].results.total : false;         var newhp = curhp + result;         if(result === false) {             log("FAILED TO GET HD RESULT");         }         else if (newhp > maxhp) {             hp.set({current:maxhp});         }         else {             hp.set({current:newhp});         }     } }; My Question is : how can I automatize my pressing on "hit die" to use the right rule of the "durable" gift... When I top-arrow the hitdie thing, i get this result : @{Alfarel|wtype}&{template:simple} {{rname=^{hit-dice-u}}} {{mod=D@{Alfarel|hitdieroll}+[[@{Alfarel|constitution_mod}[CON]]]}} {{r1=[[1d@{Alfarel|hitdieroll}+[[@{Alfarel|constitution_mod}]][CON]]]}} {{normal=1}} @{Alfarel|charname_output} Is there a way to correct this so the result of pressing on hit die would be correct according to the durable gift rule ? thanks for your help if you can. EDIT : I'm not very good at all this programming, but is there a way of changing the hitdie type with something like d8r<@constitution_mod*2 in the attributes page ???
Any Idea Anyone ?
1619443520

Edited 1619444797
This should work but I can't test its exact syntax as I don't have your sheet.   @{Alfarel|wtype}&{template:simple} {{rname=^{hit-dice-u}}} {{mod=D@{Alfarel|hitdieroll}+[[@{Alfarel|constitution_mod}[CON]]]}} {{r1=[[{[[1d@{Alfarel|hitdieroll}+[[@{Alfarel|constitution_mod}]][CON]]],[[@{Alfarel|constitution_mod}*2]]}kh1]]}} {{normal=1}} @{Alfarel|charname_output} You need to paste this into a token action button on your third tab of your sheet and set it as a token action.  You should not use your hit die button on your sheet anymore if you want this.   If the first code doesn't work here is a generic code that requires you to have your characters token selected that definitely works: &{template:simple} {{rname=^{hit-dice-u}}} {{mod=D@{selected|hitdieroll}+[[@{selected|constitution_mod}[CON]]]}} {{r1=[[{[[1d@{selected|hitdieroll}+[[@{Jareth 16|constitution_mod}]][CON]]],[[@{selected|constitution_mod}*2]]}kh1]]}} {{normal=1}} @{selected|charname_output}
1619444881
Durable makes the minimum you can roll on a hit die twice your con mod.  You can't do a roll equation in the dice mod apparently so instead I did the drop/keep with your con*2 as the control in the drop/keep.  
Thnak you Eddie, I wish we could simply change a hit_dice formula in the character sheet to prevent some more manipulations. Maybe it is achievable, we'll see if a 5e OGL character sheet develloper can help me on that one....
1619466303
I doubt its possible and the sheet authors have to be careful of the option for multiclass breaking whatever they come up with.  Thats why I did the token action.  I even had to turn off multi hit dice to get the template you are using cause multi doesn't use a template which is odd.  
Hello again Eddie, Actually i tried your script (the one with the @selected part) and it doesn't really work the way it should. First of all there's this jareth 16 part that i've been able to correct myself. But now, when i use this macro, it actuallly doesn't work properly : It keeps the best roll between d8 and con_mod*2, but then it adds twice the con_mod instead of only once. i've been trying to work it around, but i'm afarid i didn't find the solution. Secondly, is your macro supposed to add the result to the character sheet directly ? (5e ogl sheet) I wish it would, but it actually doesn't. And if it did, would it stop at the max hp value or override it ? Thanks for your help.
Hi all, I'm still trying to sort my problem out. Well it's not a real problem, just something that i'd like to achieve. I've been able to correctly do the formula to have the good calculation.  Adding r<6 following the dice formula gives the right result, as such : @{Alfarel|wtype}&{template:simple} {{rname=^{hit-dice-u}}} {{mod=D@{Alfarel|hitdieroll}+[[@{Alfarel|constitution_mod}[CON]]]}} {{r1=[[1d@{Alfarel|hitdieroll}r<6+[[@{Alfarel|constitution_mod}]][CON]]]}} {{normal=1}} @{Alfarel|charname_output} Now 3 problems : -I'd like to replace the value 6 by a formula that gives me 2*my constitution bonus. I've been trying to replace 6 by [[@{Alfarel|constitution_mod}]][CON]*2 but it doesn't work properly... probably a matter of brackets or curly thingies that i'm doing wrong somewhere... -This formula is supposed to add the result to HP, but it doesn't.... i'll be happy to understand why. -Now my main thing is that i'd like to change something in the sheet (or in the console ?) to keep pressing on that "hit dice" line on the sheet and let it proceed directly with this new formula The result of console inspection of that "hit dice" line is : <button type="roll" name="roll_hit_dice" value="@{wtype}&{template:simple} {{rname=^{hit-dice-u}}} {{mod=D@{hitdieroll}+[[@{constitution_mod}[CON]]]}} {{r1=[[1d@{hitdieroll}+[[@{constitution_mod}]][CON]]]}} {{normal=1}} @{charname_output}" data-i18n="hit-dice-u" class="btn ui-draggable">DÉS DE VIE</button> Please can someone let me achieve this. I would so much prefer to have the formula corrected than again a macro to do it.... Thank you !
Strange, the message didn't show up in the list of topics... Is I try to "up" it again...