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 OGL] changing how crits are rollen on npc sheets

Hey guys, so in my games we use the brutal critical rule so crits aren't double dice but dice roll + maximum the damage dice could have rolled. In character sheets this is easily changed in the attacks but i haven't found a way yet to do that in npc sheets.  Is there a way? Maybe with an Api script? I have no idea of coding so i couldn't write this myself if it was possible. 
1603807007
Oosh
Sheet Author
API Scripter
There's no crit field to edit in the NPC sheets - it was requested a while back, but you could try requesting it again in the 5e sheet thread . There's a bunch of problems that have never been looked at with NPC sheets, so I wouldn't hold your breath for a solution. You could handle this with an API script, bearing in mind that it wouldn't stop the original roll from happening, but it could post a second template with the brutal damage roll. I'm currently picking at a very similar problem with API - if you don't find another solution I can probably write you something that will work. I'm an absolute novice coder, though... hopefully someone more competent has a solution :)
1603808321
David M.
Pro
API Scripter
Would it be possible to delete the damage entry and add chat button(s) calling damage ability(s) to the description field? Haven't tried that on npc sheets before. Even if that works, I suppose you might as well just make separate attack abilities as token actions that roll damage the way you want. It would be a lot of setup. 
1603907909
Oosh
Sheet Author
API Scripter
I've got a script that will do what you want - it's a bit hacky but should get the job done. I mostly did it for fun, but let me know if you're interested in using i t. It's a GM script that changes the sheets (can revert changes though), so there's no extra templates or roll listeners going off.
If you've got a script that does roll the brutal crit, even if it's a separate chat thingy, i'd love to try it
1604025796

Edited 1604027282
Oosh
Sheet Author
API Scripter
Sure, here's the link -&nbsp; <a href="https://pastebin.com/D9mDuDq4" rel="nofollow">https://pastebin.com/D9mDuDq4</a> Instructions are at the top, it'll change the NPC sheets to use a '*' instead of 'd' in the critical rolls. This means it doesn't need to do any further work once you've run it, unless you add more NPCs - you can probably disable it unless you're planning on adding new NPC sheets. Once you've added it as an API script, it can be run (by GM only, let me know if you need that changed) in a few ways - on selected tokens, the page the GM is currently on, or globally (entire campaign). I'd definitely advise running it on selected tokens first, or create a new map page and drag a few monsters onto it to test. Then run it with either target=sel or target=page, depending on which option you went for: !brutalbot target=sel,mode=chat,brutal This should apply changes to the currently selected tokens, and output to chat. Check the character sheets &amp; click some attacks to check that the math is what you're expecting. Hopefully I understood correctly. For testing - edit an NPC action, click in their To Hit field for example '7'. Change it to this: 7 + 1d0cs0 That'll give you 100% crits... just remember to change it back after you're done spamming crits. Also, if you're happy with it and are planning on doing bulk changes, you may want to toggle the response logging back to API console, so your chat log isn't getting spammed, with mode=log. It's a toggle, once you change it, it should (hopefully) stay changed until you change it again. You could even go for mode=silent, as the script is very spammy - apologies for that, but I was learning as I went and needed the constant feedback :) Let me know if I got anything wrong, or it doesn't work. If you're comfortable with the results, you should be fine to do a page at a time. The worst damage this script should be able to do is mess up the NPC action description field or crash the API sandbox. It doesn't edit anything on PC sheets, and it has a revert setting to undo the changes it makes. Having said that, I'm an absolute novice at JS - make sure your game is backed up first! If everything works fine and you add new monsters, you should be fine to run it globally to easily modify the new NPC sheets. !brutalbot target=global,brutalise Basically, the script will ignore any NPC sheets where it finds the text "crit1=" in the description field, as it shouldn't be in there unless the script (or someone else) is already using a similar hack to override the roll template's crit field. If you're in game at the time, I'd recommend changing the logging mode back to API console log only with mode=log, your players probably don't need to be seeing brutalBot's excessive chat spam. :) How it works, if you're interested, and why it doesn't just change the {crit} field: The new math is stored in the @{repeating_action_$0_attack_crit|max} repeating Attribute, which is unused by the sheet and only exists because all Attributes are created with a 'max' key, whether or not they need it. Changing the actual @{crit} Attribute is no good - there's a sheetworker which fires every time an attack is rolled and changes it right back to the default. The math is called with an override hack, appended to the @{repeating_npcaction_$0_description} field. This looks a little ugly on the character sheet, but it doesn't affect the actual roll template description output. You may still get the 3d dice rolling for the crits - there's not much I can do about that, due to the sheetworker mentioned above. The script defaults to 10 loops through the repeating_npcaction section. Change that if you have monsters with more actions, with the argument loop=X. From memory, there are some Compendium sheets with bogus entries in the middle, so if I'd made the loop break when it first finds an empty row, it probably would have missed actions on those sheets. I've tested it on a bunch of mobs that have different attacks, like the dragon with twin damage types, and the Lich who loves breaking npcaction macros. But there might be some odd attacks with weird roll expression where the script gets confused or the attack no longer works. Revert the changes on the sheet and let me know if this is the case. Click for GIF:
1604045271

Edited 1604061301
For physical attacks it works almost perfectly. I have a few instances, where it puts out the second damage as "rolling 0", even tho it should be "01*4" and i have found one action where it says this " No attribute was found for @{Chained Ogre Zombie|repeating_npcaction_-MKkfl4WzSTdhTeOJi3t_attack_crit2}"&nbsp; Another thing: It actually didn't change all NPC-sheets but just about half i think when i used the global command. Edit: I think i identified the problem. Somehow it didn't update npc sheets i created myself for homebrewed monsters or stuff that isn't in the SRD. I had to select their all of their tokens and use the " !brutalbot target=sel,mode=chat,brutal"&nbsp; command.&nbsp; Also, is there any way to also make it work for spells?
1604137112

Edited 1604139039
Oosh
Sheet Author
API Scripter
Well, I'm glad it mostly worked and didn't end the universe. I don't have the Chained Ogre Zombie in my Compendium - is there anything unusual about its actions that you can see? And are you able to tell me what value those NPCs have in their crit field that are outputting the 0 for damage? @{selected|repeating_npcaction_$0_attack_crit} in chat is the easiest way. I'm a bit baffled about the homebrew NPC sheets, too. Both methods to grab the sheets, target=sel and target=global, are using the NPC flag, I would've thought they'd both fail if one of them does. I'll keep looking at it. It shouldn't be too hard to do spells as well, I'll let you know when I've updated it. edit - I've updated the pastebin so homebrew sheets should now work. Turns out the Compendium sheets have the NPC flag set to 1, the integer. Any sheets you create have an NPC flag with '1', a string.
1604140577

Edited 1604141197
I tried with&nbsp; @{selected|repeating_npcaction_$0_attack_crit}, but it just gives me an empty chat message. The chained ogre zombie is a homebrew variant of the ogre zombie with some action oriented features like reactions and stuff. So nothing that exceptional tbat the script shouldn't work with it.&nbsp;
1604383548
Oosh
Sheet Author
API Scripter
Just about to head out the door, but there's a new version on PasteBin - It should now handle spells (only spells currently set to Attack template, it won't do anything to the actual spell list) and also cantrip progression math &amp; similar die rolls with scaling. Let me know if it breaks the universe!
I just tried and it just rolls the crit damage regularly.
1604403027

Edited 1604404725
Oosh
Sheet Author
API Scripter
You might need to do a global revert first (you probably don't, but I made some cosmetic improvements which won't be applied to a character sheet if it sees an already-modified version): !brutalbot target=global, revert Then grab a few mixed tokens, including spellcasting NPC's, and try something like this (with the "spells' command in there) !brutalbot target=sel, brutal, spells, debug, mode=chat The debug command should give a heap of extra info in the API console. If the modified crit math isn't being applied for some reason, the console log should narrow down what's happening. Sorry, was halfway through typing something useful when my Uber turned up earlier. The new version has a couple of new commands: spells and debug . Sorry for the confusion, was in a massive hurry and totally forgot to tell you: you'll need to add the spells command for it to do anything at all with the spell list. The amount of garbage thrown in chat has been massively reduced, but there's now a heaps more that can be spammed into the API console with the debug command. It'll show each attempt at grabbing the damage/crit math for each spell and NPC action, then each attempt at converting it to Brutal Math. The spells command simply tells the script whether or not to process spells. It doesn't do anything by itself. So: !brutalbot spells does nothing. !brutalbot spells, brutal, target=global converts all NPC sheets to brutal crits, including spells !brutalbot spells, revert, target=sel reverts changes to the selected tokens, both actions and spells There's currently no way to only do spells, it's just a flag to process spells as well as NPC actions. I can redo it if you need that. Worth mentioning though, there's no harm in running it multiple times on the same sheets. It won't keep overwriting the description field with more spam. The higher level damage part was a bit of a pain (and resulted in me being late to the pub!), I think it works, but the spellcaster NPC's I used had very few upcastable attack roll spells so I didn't do much testing. A note about the spells in general - when an NPC has a spell using "ATTACK" output, rather than "SPELLCARD", the relevant Attributes are copied from the repeating_spells(spell-level) sections to the repeating_attack section - the same one PC sheets use for all their attacks. The difference is that it's not visible at all on the sheet. This has some Pro's and Con's: PRO: no modification of the actual Spells repeating section in necessary (assuming you're running standard 5e crit rules in general i.e. you only reroll dice on a natural 20 - no save rolls count (e.g. Fireball), no static bonuses... only XdX rolls on a d20 attack roll are rolled twice). This cut down the complexity of the script massively - the 5e Character Sheet has already reduced the huge spell list (split into spell levels) to a focused list of attack spells. It also meant I didn't have to look through every spell, in each (separate) repeating section for each spell level. PRO: the script modifies the Higher Level Damage Crit field by using an override (much like the original NPC action mod). I was worried this wouldn't mix well with save-based spells (like Fireball), but since they don't have an attack roll, their relevant macros never pull the critical damage. Again, cut down the work massively. CON: the repeating_attack section is filled out by the sheetworkers at the point where you select "ATTACK" as the output for the spell from the Spells tab. This repeating_attacks is the section I'm adding stuff to. The flipside of the first "Pro" (i.e. not messing with the base Spell stats) is that switching a spell to "ATTACK" after you've run the script will not contain the brutal crit changes. None of the changes are made to the actual spell list. By the same token, this is kind of a "Pro". If a spell becomes broken, you can switch its output from "ATTACK" to "SPELLCARD" to clear it from the repeating_attacks list, then back again. It'll repopulate the fields from the (unmodified) Spell entries. The override to use the new math for spells doesn't go in the {{description}} area like the npcactions did. {{hldmgcrit}} occurs later in the macro, so it doesn't work. I had to grab {{spelllevel}} instead - so if you notice anything bad happening with spell level in a macro, it's probably this script. Let me know!
ok, now it works for individuals do i have to change something on the&nbsp; !brutalbot target=global,brutalise &nbsp;command? Cause if i input that it gives me the following (i made a new game for testing): brutalBot -- 3 NPCs added to Array! brutalBot -- Brutalising NPC actions...10 attempts per section... brutalBot -- Processing Goblin... brutalBot -- Processing Adult Black Dragon... brutalBot -- Processing Priest... brutalBot -- 6 actions processed in 3 sheets! brutalBot -- 0 attack spells processed.
1604404812

Edited 1604407113
Oosh
Sheet Author
API Scripter
Yeah, sorry mate. On reflection I shouldn't have posted that without some instructions. I blame beer! Hopefully you have more luck with the spells command! edit - also the debug command will be super helpful for any more errors that are coming out.... as per the above (edited) post, highly recommend you do a target=global, revert before running the new one. It won't do any harm if you don't, but the new version gets rid of some leading zeroes that looked a bit crummy... I think (fingers crossed) the error handling is good enough to get rid of that safety crutch. It won't overwrite an existing brutalBot field without doing a revert first... doing some kind of versioning magic is beyond my ken. debug will spam the hell out of your API console, be warned. Great for finding an issue with a particular ability though. But even with mode=chat setting, those hundreds of lines won't come through to game chat - all the per-ability attempts at reading the damage math crash the chat log in game, they'll only ever go to the console no matter the setting. edit - There's a limit to what can be accounted for with a regexp search (to find a parseable roll expression in the Attributes), and a very serious limit to what Oosh can achieve with a regexp search. The script currently doesn't account for multiple die types (e.g. 2d10 + 4d6) - it will only grab the 2d10 and turn it into 2*10. If you have homebrew monsters which use some unusual scaling, any roll expression in the damage/spell damage fields which you'd like to be picked up the script need to be in one of the following forms. I don't think anything else actually parses in Roll20, but anyway, using a d10 as an example: Xd10, where X is one or more integers (...)d10, where ... is anything [[...]]d10, where ... is anything Anything else in the damage field will be ignored, or cause the universe to end prematurely. edit 2 - testing spells for criticals is a bit trickier than actions - you'll need to de-select the "NPC" checkbox from the sheet settings, then flick to the "Core" tab of the (now PC) sheet. Then you'll see all the attack spells in the PC Attacks &amp; Spellcasting section. You can then set the Crit Range to 1 to test crits without spamming 500 rolls (at least with my luck)