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

Dead monsters functionality

Hi all, Is there any way (i.e. script) for a monster, when dropped to 0 hit points, to be automatically removed from the turn tracker and have token on the map replaced by a skeleton, cadaver, or chalk outline (indicating that the area is now difficult terrain)? One of my players set this up when we were in Maptool, and I'd love to have the same functionality in Roll20. Particularly the auto-remove from turn order thing. Very clunky to have to manually delete a monster every time it dies.
1555696249

Edited 1555696341
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Certainly possible. I'm not aware of a script that does all of that at the moment though. Are you using an API script to change the monsters' current health, or to do anything else on a health change/death?
I have the On Bloodied and Dying script running. And yes, of course, it might well have to be scripts plural, not scripts singular, to get these things done!
1555702793

Edited 1555702910
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ok, I think this should work for you as long as you manually enter the changes to the token's hp. You can change which bar to use as the hp bar by changing the value on line 13 (currently set to 1) and the dead image can be changed by entering the URL of the image from your library you want to use on line 14 (make sure to wrap it in quotes like it is now). Script Features Any token representing a character will be set to the dead image when its health reaches 0 or lower. Only NPC tokens, aka tokens of characters that don't have anything in the "controlledby" field, will be removed from the initiative tracker (so your PCs know when to make death saves or whatever If a token's hp bar later becomes positive again, the image will switch back to it's original image and, if it is an NPC, it will be re added to the initiative tracker in properly sorted order; the current order of the initiative tracker will otherwise not be affected. You can move it as needed. Known Issues When a token is "revived" you need to click somewhere else to deselect the token before reselecting the token in order for it to be editable again and for it's bubble/bar to show the correct value. Not sure what's causing this. Here's a gif of it in action (images are not mine and only used for demonstration purposes):
1555703288
GiGs
Pro
Sheet Author
API Scripter
Your gif isnt showing up for me.
1555703673
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Huh, weird, for those that the embedding isn't showing up for, here's the link
Wow, many thanks!! This looks great and I will drop it in tonight and test it out. You are awesome. :)
Just tried the script. Most of it works great, Scott, but the image returning portion of the 'revive' part doesn't seem to work, at least not for NPCs (haven't tried it on PCs yet). The token returns to the initiative count, but still has the dead image instead of its own token image.
1555716807

Edited 1555716951
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ah, I bet I know what's going on. Is your npc token a marketplace image per chance? The API can't use images that are from the marketplace, so that part of the update is probably just failing silently. You should be able to import marketplace purchases to your library, but there's not an easy way to update current token image references.
Makes sense! Yes, it was an image from a Player's Handbook monster, purchased content. That's all right. Not many situations in which I'd need a generic monster to come back to life; as long as the PCs pop back up, I'm good. This is such a useful script; thank you again!
1555717509
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Glad you like it. Happy rolling
1555726674
The Aaron
Roll20 Production Team
API Scripter
Scott, you could modify it to swap the monster the the GM layer and create a duplicate with the cadaver/skeleton image, much the way Bump works.  That would let it operate in both directions on MarketPlace content, provided the dead image isn't from the marketplace.
1555730952
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Good point Aaron, that would be pretty easy to do.
That would be great! Then, if you selected the cadaver/skeleton image (I'm currently using a skull because none of the chalk outline images I searched for online were to my satisfaction, lol) and gave it healing (to bring it back to life), it would swap again with the monster on the GM layer?
1555774623
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
A slight drawback to this is that the GM would still see both images, since they can see the GM layer. If you wanted to make it totally invisible while substituting the cadaver, you could have it swap with the DL layer.
1555776178

Edited 1555776221
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yep, that's what I was thinking Keith. I've got family in town this weekend, but I might be able to get a rewrite done by Monday.
One last request: would it be possible to have the cadaver image be a random shuffle between two or three chalk outline images (in different positions)? Like, each time a monster drops to 0 HP, it randomly picks one of the three images, so that the field of monster corpses doesn't look symmetrical. Aesthetically, this is something I really appreciated in my friend's maptool framework, so I'm wondering if it's possible in Roll20.  
1555786381
GiGs
Pro
Sheet Author
API Scripter
If you set up a rollablet table token (a single token with multiple images), the script could just use that token and randomly select one of the images. The script wouldnt need to know how many ahead of time, you could update the token images later and have a lot of flexibility.
Yeah, I was thinking rollable tables too. That's the setup I had in maptool.
1555811046

Edited 1555812811
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I was able to take a whack at this earlier than I thought. I've updated the gist with a new version that relies on rollable tables and moves the actual token to the dynamic lighting layer to hide it on death. Script Features The script pulls dead images from a rollable table called deadTable (case insensitive). Simply create the table and then add whatever (non marketplace) images you want to it as entries. The script will respect the weights you put on each item. Note that this uses the randomInteger() function as opposed to the quantumRoll system, so the randomness won't be quite as random as actual dice rolls (as far as randomness can truly be measured). To change which bar is the hp bar, simply change line 13 (currently set to bar 3) Any token representing a character will be moved to the dynamic lighting layer, and a new token using a random dead image and a random rotation will be created in its place when its health reaches 0 or lower. Only NPC tokens, aka tokens of characters that don't have anything in the "controlledby" field, will be removed from the initiative tracker (so your PCs know when to make death saves or whatever). PC initiative entries will be changed so that they link to the dead token instead of the live token. If a token's hp bar later becomes positive again, the dead token will be removed and the original token will be placed in the same spot and layer as the dead token was on. This means that if you move the dead body, the live token will reappear in whatever space you moved the dead body to. It will also gain any auras, size changes, statusmarkers, etc. that were applied to the dead token. The initiative tracker will be updated as needed; NPCs will be added back to it and character's initiative entries will be relinked to their live token. Let me know if that works for you, or if there are any bugs. I've tested it, but you never know what someone else will find.
1555812229
GiGs
Pro
Sheet Author
API Scripter
I have a (possibly ridiculous overkill) suggestion: make the deadtable name a parameter to can send to the script in the macro call, so the GM might have different corpse types for different situations. Honestly, i dont think this is absolutely necessary, I just thought of it and mention it in case you felt like it was a worthwhile addition. 
1555812704

Edited 1555812746
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Heh, I thought about making it so it would look for a deadtable based on the character's name first, but decided against it because it was overkill and feature creep, and getting it to handle say Big boss goblin and goblin archer and goblin all looking on the goblindeadtable was a bit much without making the script specific to a certain character sheet/system instead of sheet/system agnostic. Also, there's no macro call involved in this script at all, so that's not an option for handling it.
Thanks, Scott! I'll test it out tonight, once the kid is in bed. :)
Just tested it now. Works great! I get four random chalk outline images in different poses. One quibble, though: every time the image shows up, it's off-center, which looks a bit odd because the four images have borders that should line up with the token grid (the rotation is already built into the chalk outlines themselves, which are at different angles within the image borders). 
1555895671
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ah, my bad, I misunderstood and thought you wanted the images rotated. Simply delete line 149 that reads: creationObj . rotation = randomInteger ( 361 ) - 1 ;
Worked great, thank you! This is so awesome and will make my life substantially easier in future gaming sessions.