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 .
×

Request (with Tokenmod?) for calculating MAX diceroll

1602489858

Edited 1602489869
I want to create a macro for maxing out the HP of any monster (I have selected) For example: Instead of 3d8 HP for Aarakocra, I want it to be 3*8. !token-mod --set bar1|[[@{selected|npc_hpformula}]] >> This works by rolling the 3d8, but I need some sort of npc_formula|max. If possible, I'd be great if I can use it on multiple tokens at once, but if not then not. I think this must work on npc_hpformula, because I want to use it on multiple monsters. Maybe there is some way to change the d into a *, and then executing the formula? If this is not possible at all, I will have to roll the npc_hpformula 10 times, and keep highest 1. Will probably be close enough, but still.. :)
1602506668
Pat
Pro
API Scripter
Monsters have an "HP" on their character sheets that is a calculation of the median of the dice plus the bonus for compendium creatures (so 3d6 + 3 is calculated at 4+4+4+3 or 15, the 3.5 of each 1d6 being rounded up) If you edit the "hp" entry property and then set the bar to that, that would give you what you want, no calculation, as it seems you want a flat number each time. You'd have to modify the property once, ever, for each monster when you pull in from the compendium to your handouts/characters entry. 
1602515026
The Aaron
Roll20 Production Team
API Scripter
That's a bit too specific to add to TokenMod directly.  Here's a script that will do that for all selected tokens: Command: !max-hp Script: on('ready',()=>{ const HP_BAR = 1; const HP_FORMULA_ATTRIBUTE = "npc_hpformula"; on('chat:message',msg=>{ if('api'===msg.type && /^!max-hp(\b\s|$)/i.test(msg.content) && playerIsGM(msg.playerid)){ (msg.selected || []) .map(o=>getObj('graphic',o._id)) .filter(g=>undefined !== g) .map(o=>({t:o,c:getObj('character',o.get('represents'))})) .filter(o=>undefined !== o.c) .map(o=>({...o,a:findObjs({type:'attribute',characterid:o.c.id,name:HP_FORMULA_ATTRIBUTE})[0]})) .filter(o=>undefined !== o.a) .forEach(o=>{ sendChat('',`[[${o.a.get('current').replace(/d/g,'*')}]]`,(r)=>{ o.t.set({ [`bar${HP_BAR}_value`]: r[0].inlinerolls[0].results.total, [`bar${HP_BAR}_max`]: r[0].inlinerolls[0].results.total }); }); }) ; } }); });
1602533814
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The Aaron likely wrote this while waiting in line at Starbucks, or possibly during a commercial break.
1602549311
The Aaron
Roll20 Production Team
API Scripter
Hahaha. Pretty close. It was between anime episodes while waiting on a friend. =D
It works like a charm! Great! Maybe this is a feature you could add to the monsterhitdice script as well? Just as an extra option? Not sure if a lot of people want this though... Anyway, it works. Thank you so much!
1602683051
The Aaron
Roll20 Production Team
API Scripter
Great!   You're right that there is probably a good place for it in a larger script. I'll have to see what else I have that's similar.  Regardless, I'm glad it works for you!