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

[Script] Aura/Tint HealthColor

1486942367

Edited 1491414354
DXWarlock
Sheet Author
API Scripter
[Script] Aura/Tint HealthColor GIT Link:&nbsp; <a href="https://github.com/dxwarlock/Roll20/tree/master/HealthColors" rel="nofollow">https://github.com/dxwarlock/Roll20/tree/master/HealthColors</a> Updated 4/5/2017 to 1.5.0 ----------------- Script to show health status of Mobs and Players along with a few other features. It will "Just work" out of the box, no setup needed other than one click to set the bar you use for health. Only if you want to get into the more complex options do you need to set anything else. Description: This script sets the aura or tint of mobs and players to a gradient between green/yellow/orange/red based on how hurt they are. You can toggle it off for specific tokens, have it only on tokens tied to a sheet, or any tokens with a current/max set on the bar you pick. For example in my campaign, players cannot see enemy health bars, OR other players only their own. This lets them tell how badly hurt someone/something is without the age old tabletop "how badly hurt does it look" 20 times during an encounter. NON-PCs : It sets any mob/creature not assigned to any player, and has a min/max on a bar to have an aura based on its damage taken vs total health as the larger outside aura, and the smaller inside to white (to help see it on some backgrounds and give it a sort of 'token base' effect). PCs: Same as above but inside ring set to their roll20/dice color. Here is an example image of various Kobolds in different states of damage. Along with the players all at full health. What Player (Aaron) sees: What GM sees: Basic sample gif of FX: Player Sees: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GM Sees: Commands: !aura Menu with toggle buttons: Menu Options: Is On: Global on and off setting. Bar: Set which bar is the one to track. Use Tint: Use tint instead of aura for color of health . Percentage: Set a percentage that this kicks in at values are for PC / NPC. Show Dead: Show red 'X' on dead of PC/NPC. GM sees names: Set if GM can see PC/NPC names. Players sees names: Set if players can see PC/NPC names. Aura Size:&nbsp; Set aura size. One Offs: If tokens not linked to a character use HealthColors if it's bar has values. (Be careful as ANYTHING with a [bar] current&max will trigger it.) FX: Set if Hurt/Heal FX is used. Heal FX Color: Set spurt color for Heal FX. Hurt FX Color: Set spurt color for Hurt FX. DeathSFX: Comma delimited list of&nbsp;sounds to play on death of NPC/PC. Thanks goes to The Aaron for help on a LOT of areas of this.
1486952571
The Aaron
Pro
API Scripter
Welcome back! &nbsp;I think I left a pull request on your repo with a minor state bug.&nbsp;
1486990163
Kirsty
Pro
Sheet Author
This script is in every single one of my games. My players absolutely love it! Thank you so much for the update, I'm looking forward to testing out the new "one offs" functionality!
1487007277

Edited 1487007457
DXWarlock
Sheet Author
API Scripter
Well crap, didn't see that Aaron (actually USING github in any competent way is still something I know nothing about) that would have saved me doing it, I did the same thing you did to fix it. Trying to figure out how to get it on the script repo, looking into that now.
1487028483
DXWarlock
Sheet Author
API Scripter
I'm flattered Kirsty :) Glad I could make something useful! Let me know if you have any issues with the new version.
I love this script, thank you for making it! I do have a question. In version 0.9.2 I believe, I was able to set it up so that the tint doesn't go into effect at all (or is transparent maybe) until the token is down to 50% hp for 4E games.&nbsp;I don't recall how I did it though... How would I go about doing the same thing in this newest version?
1487034332
DXWarlock
Sheet Author
API Scripter
Its the same as it was in previous versions. Just set the "Percentage" one to the % you want it to kick in at.
I'm excited to give this a try but I'm hitting a snag. The Percentage field always says "undefined" no matter what I enter. And if Use Tint is set to "No", my API crashes when I move a token. Any ideas?
1487047084

Edited 1487047219
DXWarlock
Sheet Author
API Scripter
That was my fault, sorry you didn't do anything wrong. I missed one of the namestate update/changes. Try the git link now and let me know.
Now I can get the percentage to stick. But it still crashes when I move a token with tint off AND when I change the value in the selected bar.
1487047875

Edited 1487048017
DXWarlock
Sheet Author
API Scripter
Hmm strange. You willing to PM me an invite as GM to your game and I can take a look? Fundamentally its the same as the code that was on the last thread, other than the state changes.
1487051163
DXWarlock
Sheet Author
API Scripter
Found the issue: Issue of it finding a 'controlledby' that wasnt actually in the controlledby list, causing a crash onlooking up the non-existent player color
I'm delighted to see you continue working on this DXWarlock. It's one of my favorite scripts. :)
Installed straight from github and am getting an error when I attempt to change any settings. TypeError: Cannot read property 'get' of undefined TypeError: Cannot read property 'get' of undefined
1487109053

Edited 1487109543
DXWarlock
Sheet Author
API Scripter
Not sure what that issue was, a reload got it working he said. If anyone else runs into it be sure to let me know.
1487124051
DXWarlock
Sheet Author
API Scripter
1.0.0 finally out with more mostly useless features! (and hopefully less bugs...) Now with hurt/healed FX!
1487125635
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
First: This is a brilliant script. I can't wait to use it (next game is in 11 days). Second: Feature creep requests! 1) Can there be an option to turn the aura off for dead creatures? The "X" is a good indicator, but having both it and the aura tends to put a lot of visual emphasis on the least threatening creatures on the board (i.e., the dead ones) 2) Can some creatures be excluded from this script based upon an arbitrary criterion? I think it's great to let players see the goblins' status, but might want to be more cagey with the vampire lord. If this would cause the script to run more slowly, it's probably not worth it, but it would be nice, otherwise.
1487126958

Edited 1487127373
DXWarlock
Sheet Author
API Scripter
Sure! The first should be fairly simple. Don't know why I didn't think of that. Cant see anyone needing a red aura AND dead X. I'll just clear aura/tint if dead. (Unless someone else wants both then I'll make a toggle?). Done: Change in 1.0.1 to if dead, remove tint/aura if "show dead" status is on. For the second, what criteria do you think would be good for exclusion? An [attribute] = 1, or something in the name of the token maybe, or a GM note? I personally think the attribute would be the easiest and most universal perhaps, that wont mess with other scripts (like TokenNumber that uses the name, or one that uses GM notes for itself).&nbsp;but open to ideas!
Hey DXWarlock! Awesome script! I do seem to be having 2 small issues however: 1. FX don't seem to work when the health bar is set to something other than bar1. Is it hard-coded to that? 2. The "PC Sees NPC Names" setting doesn't seem to work. I have it set to "No" but my player permissions still have the Name section checked with "See". I might be missing something here, though.
1487144157

Edited 1487148800
DXWarlock
Sheet Author
API Scripter
I found the PC/GM see names issue and fixed it and updated git. Was me cleaning up TOO much code. Fixed the bar issue. Problem was I was registering what bar to watch at startup for the trigger, so it wasn't changing until you saved again and restarted the sandbox. Both should work now. Let me know if you have any more issues.
Yep, both fixed! Thanks :)
1487172796
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thanks DXWarlock! Criterion possibilities: 1. An attribute would certainly be ideal, but hopefully it could be invisibly set and created in its default state by the script? I can't see the average user wanting to create and fill in an attribute for every creature? 2. A name prefix, like "NT-", for "no tint"? That could be easily set. As for the "see names" option, I have many of mine set manually. Would the script override these? For example, I don't mind the PCs seeing the goblins, or the big bad, but enemies that are hard to see or identify (shadows, gelatinous cubes, animated statues and armor), I leave the name off until the players are aware of their position and/or nature. Perhaps a third option besides "see/not see" would be "do not use this feature"?
1487181217

Edited 1487181693
DXWarlock
Sheet Author
API Scripter
I can do the create and set attribute to default. Think that would be 'cleaner' than the name prefix. Some people might not like some of the tokens showing 'NT-GoblinBoss' as a name. And for names, right now it would override your settings. Its a global on/off for if the name is affected at all. You wanting it so: Its a universal 'do not use this feature' as in turn it off totally and let you decide all the names,&nbsp; Or a token by token basis. For example it auto shows name to players for all NPC's, but this particular one let me choose if they see it. The first way will be easy I think, I can just change the options from a Boolean for can see name to "Yes/No/GM" for the toggle options to do it or not.&nbsp;(Yes always show name, No dont show name, GM decides dont change any of them). The second way might take some head scratching to make it so its not overly cumbersome to use.
1487186996

Edited 1487187055
I think the&nbsp;"PC Sees NPC Names" setting should be Yes, No, Disable. Disable being don't touch this. The setting being Global.
1487187720
DXWarlock
Sheet Author
API Scripter
Let me see what I can do. I got the attribute being created and working called "USECOLOR". if its set to YES, use colors. Just need to clean it up and put in some error checking. I will work on adding what you have above. Might as well make it on all 4 'can see name' options. Someone else might want it.
1487194704
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
BP said: I think the&nbsp;"PC Sees NPC Names" setting should be Yes, No, Disable. Disable being don't touch this. The setting being Global. That's it exactly. It's a nice add-on but doesn't really fit well with the main functionality. At least not for me. :)
1487196415
DXWarlock
Sheet Author
API Scripter
Im working on it. Trickier than I though. Dont want to be messy and make 4 separate set object functions depending on whats yes/no/off. Would work but seems the bad way to do it. And I cant use if(somethng) inside a&nbsp;obj.set({...}); I'll keep hammering at it.
1487201644

Edited 1487202148
DXWarlock
Sheet Author
API Scripter
Ok I got them both done!&nbsp; had to rewrite how the name display was done, hopefully it works correctly. Had to call it "Off" so it fit in the button text. But also changed the description so it fits better with the 'Off' option. These changes change to core of how it saved the info for them, so you will need to reset your options. (I hate making people do that). Let me know if these changes are along the lines of how you wanted it to act. 1.0.4: Toggle for setting see names: Added "Off" toggle so it doesn't try to adjust who can see names. Added Attribute to ignore certain characters: &nbsp;Creates a USECOLOR attribute sets "YES/NO" on if to use on that specific character.&nbsp;Defaults to yes on creation. Changed Bar to be dropdown vs Text field: Bar selection is now a dropdown, to prevent errors.
1487210862
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
You are a gem among warlocks. To mix a metaphor.
1487295794
Alicia
Sheet Author
OO Updates! Now to remember how to get it to work with the Alter Bar script again!
Gold might be a better color for healing. The green could be poison or acid damage.
1487868174
DXWarlock
Sheet Author
API Scripter
Hmm, maybe ability to set the hex color you want it to be for each? Just don't want to make the menu too long.
DX Warlock I've seen much longer menus, if you add a few more things I think it would be ok. It's a Trap 5e-Shaped is huge, constantly scrolling up and down.
1487869398
DXWarlock
Sheet Author
API Scripter
True, and I could make the buttons a bit smaller they are a bit tall. Now just need to figure out how to turn: 00FF00 Into: [0, 255, 0, 1.0] I have a RGBtoHEX function, but not the other way around. Don't believe the FX will take hex for colors.
1487873278

Edited 1487873364
The Aaron
Pro
API Scripter
Well... &nbsp; &nbsp; let HEXtoRGB = function(hex){ &nbsp; &nbsp; &nbsp; &nbsp; let parts=hex.match(/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/); &nbsp; &nbsp; &nbsp; &nbsp; if(parts){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; let rgb= _.chain(parts) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .rest() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .map((d)=&gt;parseInt(d,16)) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .value(); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rgb.push(1.0); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return rgb; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; return [0,0,0,1.0]; &nbsp; &nbsp; }; Returns black if what you pass in isn't in hex format, otherwise it returns the rgba color represented by the hex. &nbsp;Optionally supports a # on the front of the color in case you've got HTML notation going on. =D
1487874094
DXWarlock
Sheet Author
API Scripter
Is there ANYTHING you cant just whip up in JS on demand Aaron?
1487874640
The Aaron
Pro
API Scripter
A 7 figure salary? &nbsp;=D &nbsp; Some things are easier than others, I've done plenty with string parsing, which makes it easier to just throw it together.&nbsp;
1487877004

Edited 1487877431
DXWarlock
Sheet Author
API Scripter
Updated with user settings to set spurt colors. Button color shows color currently set. 1.1.0: Added Settings for FX colors: Now can set colors for the spurt FX on heal/hurt. Changed Menu to make it more compact. To do (maybe...): Working to see if I can figure out how to hide the color options totally if FX is off. That might be a little beyond my HTML-fu.
HOT STUFF!!!
1487899562

Edited 1487899700
DXWarlock
Sheet Author
API Scripter
Was thinking of making the 'spurt' proportional to damage done of total. Say it had 100 HP, they hit it for 1, barely any spurt, hit it for 75, large Kill Bill type spurt. A bit of visual feedback and gratification for players on scoring major hits (and heals). Sound like something people would use or care about? (On a side note, did my thread get bugged? I cannot see it on the Forum main page after a reply, I have to go into the API forum to see it at the top and that it has a reply.)
If you do vary the FX that way, I'd add a slight bit of randomness to it.
DXWarlock said: (On a side note, did my thread get bugged? I cannot see it on the Forum main page after a reply, I have to go into the API forum to see it at the top and that it has a reply.) The main Forum page only shows threads started within the last week, regardless of new posts. See here: <a href="https://app.roll20.net/forum/post/2909968/forum-sorting-changes/" rel="nofollow">https://app.roll20.net/forum/post/2909968/forum-sorting-changes/</a>
I think that would be really cool and adding randomness to it sounds like a good idea as well. Have to keep them PCs guessing.
1487949748

Edited 1487949962
DXWarlock
Sheet Author
API Scripter
Something like this? The gif is hitting it for 1/2 its health, then healing for 1/2. Then for a 10th on both. I added some randomness. between 60% and 100% of what it would be, so they dont always look the exact same, but cant see it in the gif.
That's really awesome.
I love it !!! &nbsp;I'm nor sure if it is supposed to behave this way, but during our last game session we had a mage that turned invisible so the DM pulled the mage token to the GM layer. &nbsp;The mage then healed while invisible and the players could see the green spurts on the token level, thus revealing the location of the "invisible" mage.
1487954741
DXWarlock
Sheet Author
API Scripter
Oh..nope it shouldn't. I forgot FX are layer independent, my mistake. I will make small update so it checks to make sure its token layer before applying FX.
1487955217
DXWarlock
Sheet Author
API Scripter
Ok updated from: if (state.HealthColors.FX == true) to if (state.HealthColors.FX == true && obj.get("layer") == "objects") So now only tokens on Token Layer will show FX on change.
1487976572

Edited 1487976595
DXWarlock
Sheet Author
API Scripter
1.1.1: Added variation to FX amount: Now FX are based on damage percentage of bar_max, with a bit of randomness on 'actual' amount. Found a shorter way to calculate health color. Fixed copy/paste typo in menu Replaced blue background image with actual web gradient. Fixed FX showing on any layer other than Token Layer.
Hi DXWarlock. Love those updates but I can't make "Show Dead" work. I try to turn the big red cross off but it appears even when told not to.
1488104658
DXWarlock
Sheet Author
API Scripter
Hmm, does it act that way with my script disabled, or only when its enabled? I cant seem to simulate that on my game or my test game.&nbsp;