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

Roll for HP using Advantage with either TokenMod or OGL Companion

1507041385

Edited 1507041968
I am hoping either SteveK or The Aaron may be able to provide insight to their respective API's (5th Edition OGL Companion and Token Mod). I see that both APIs have a method for rolling NPC health. In both cases they use a call to roll the die for the HP. I was wondering if it's possible to do this using advantage? In our current game this is what we're doing to make things a little more challenging as my players are mowing through npcs. Today, I do this with a macro that rolls advantage on a rollable template from the OGL character sheet, then manually input the current and max values for health. Having just upgraded to pro, I'd like to potentially automate this task. Edit: !npchp doesn't seem to be working for the 5th Edition OGL Campanion at the moment
For reference, this is how I'm doing the roll today. /w gm &{template:npc} {{rname=Health}} {{type=Hit Points}} {{name=@{selected|token_name}}} {{mod=[[@{selected|npc_hpformula}]]}} {{r1=[[@{selected|npc_hpformula}]]}} {{advantage=1}} {{r2=[[@{selected|npc_hpformula}]]}}
1507041751

Edited 1507042289
The Aaron
Pro
API Scripter
TokenMod is pretty general purpose, so it isn't purpose built for any one system.  That said, if you can express it as an inline roll, you can set it with TokenMod. Something like this ought to work: !token-mod --set bar1|[[ {[[@{selected|npc_hpformula}]],[[@{selected|npc_hpformula}]]}kh1 ]] (Assuming the attribute for your hitdice expression is named hitdice). Advantage on hitdice rolls is not something that is likely to make it into the OGL companion (I might be wrong, just speculating).  I've got a MonsterHitDice script that sets hitpoints when you drop a token in.  It could likely be modded to apply advantage to the roll if the above doesn't work for you. Edit: Used npc_hpformula
Sick, thanks so much! I'll actually most likely do everything with a single macro using TokenMod anyway, as I'd like to make sure AC and passive_wisdom are set on the bars anyway. This isn't the case with the latter for stuff from STK.
1507042268
The Aaron
Pro
API Scripter
Cool!  Let me know if you need anything else. =D
Do you know anyway to get the values set "immediately" after tokenmod sets them? I'm trying to do the following. The problem is, I'm getting the previous values, so HP is the average, and Passive Perception is always giving me nothing when done on a fresh token !token-mod --set bar1_link| bar2_link| bar3_link| bar1| bar2| bar3| !token-mod {{ --set bar1|[[ {[[@{selected|npc_hpformula}]],[[@{selected|npc_hpformula}]]}kh1 ]] --set bar2_value|@{selected|npcd_ac} --set bar3_value|[[10 + [[@{selected|npc_perception}]]]]} --on showname }} /w gm &{template:default} {{name=@{selected|token_name} Configured}} {{Hit Points=@{selected|bar1}}} {{Armor Class=@{selected|bar2}}} {{Passive Perception=@{selected|bar3}}}
1507063043

Edited 1507063101
The Aaron
Pro
API Scripter
All of the @{} references and [[ ]] calls are resolved before any of the API calls occur.  The /w GM will happen before the API call, as it gets dispatched earlier, conceptually:: /w gm ... ::= Client -> Chat Server -> Client !api ...  ::= Client -> Cht Server -> API Server -> Client The only way to get things lined up is to have the fetching of the information occur on the API server, which means having a script that is doing it.... Like this! on('ready',() => {     on('chat:message',(msg) => {         if('api'===msg.type && /^!token-summary/i.test(msg.content) && playerIsGM(msg.playerid)){             _.chain(msg.selected)                 .map((o)=>getObj('graphic',o._id))                 .reject(_.isUndefined)                 .each((t)=>{                     sendChat('',`/w gm &{template:default}`+                         `{{name=${t.get('name')}}}`+                         `{{Hit Points=${t.get('bar1_value')}}}`+                         `{{Armor Class=${t.get('bar2_value')}}}`+                         `{{Passive Perception=${t.get('bar3_value')}}}`                     );                 });         }     }); }); Then you can use !token-summary to get that output. BTW, you can keep chaining things to set with --set, and you can set the same property more than once and it will go in order, so I'd rewrite that as: !token-mod {{   --set     bar1_link| bar2_link| bar3_link| bar1| bar2| bar3|     bar1|[[ {[[@{selected|npc_hpformula}]],[[@{selected|npc_hpformula}]]}kh1 ]]     bar2_value|@{selected|npcd_ac}     bar3_value|[[10 + [[@{selected|npc_perception}]]]]   --on showname }} !token-summary It will be more efficient as it only needs to look up the token once, rather than twice
Works like a charm. Just change the sender and added Configured to it.
1507065307
The Aaron
Pro
API Scripter
Cheers!
1508718847

Edited 1508718874
Any chance there's a way to do a foreach (sorry, I only know c#) with token mod, so that I can perform a set of actions on multiple selected tokens at once? Likewise, can I provide a roll query to submit to that command and have it roll for each one of them? Basically, right now I want to do the following to ever NPC on the maps that come with Storm Kings Thunder !token-mod {{ --set bar1_link| bar2_link| bar3_link| bar1| bar2| bar3| --set light_radius|light_dimradius| --set bar1|[[ {[[@{selected|npc_hpformula}]],[[@{selected|npc_hpformula}]]}kh1 ]] --set bar2_value|@{selected|npcd_ac} --set bar3_value|[[10 + [[@{selected|npc_perception}]]]]} --off light_hassight --on showname }} But I specifically want the set bar1 to be unique, or rolled seperately for each npc.
1508721826
The Aaron
Pro
API Scripter
Unfortunately, there isn't a way to do that with TokenMod.  I've thought about introducing a syntax for per Token calculations, but haven't had the chance to get it done yet.  I could probably turn you out a one-off that does something of the sort though, particularly if you only need to do it once.
it's not the end of the world, just a saves a little prep time is all.