We use Cookies to help personalize and improve Roll20. For more information on our use of non-essential Cookies, visit our Privacy Policy here.
Accept
Advertisement Create a free account

Bloodied and Dead script gone?

None of the links here work: <a href="https://wiki.roll20.net/Script:Bloodied_and_Dead_Status_Markers" rel="nofollow">https://wiki.roll20.net/Script:Bloodied_and_Dead_Status_Markers</a> Anyone willing to share a copy?
1581187468
feid
Pro
Here you go: <a href="https://github.com/Roll20/roll20-api-scripts/tree/44c583189173bd5cfb68031f6b1a6a869c0b24a4/Bloodied%20and%20Dead%20Status%20Markers" rel="nofollow">https://github.com/Roll20/roll20-api-scripts/tree/44c583189173bd5cfb68031f6b1a6a869c0b24a4/Bloodied%20and%20Dead%20Status%20Markers</a>
Thank you! Tested and confirmed working.&nbsp;
I know this thread&nbsp; is necro but it doesn't work.
1586282956

Edited 1586448171
The Aaron
Forum Champion
API Scripter
The status_* properties were broken with the Custom Token Marker update.&nbsp; I rewrote this real quick so it should work (but I didn't get a chance to test it...): /* See Below */ Let me know if it doesn't work and I'll fix it...
1586288884

Edited 1586288980
Chris M.
Pro
API Scripter
FYI I just started using DeathTracker&nbsp; by Robin &nbsp;which is available via 1-click install, can do the same thing, and has some additional effects if you would like them.
1586395596
The Aaron said: The status_* properties were broken with the Custom Token Marker update.&nbsp; I rewrote this real quick so it should work (but I didn't get a chance to test it...): on('ready',()=&gt;{ // CONFIGURE const bar = 1; const bloodied = "red"; const dead = "dead"; // no edit below here // const unpackSM = (stats) =&gt; stats.split(/,/).reduce((m,v) =&gt; { let p = v.split(/@/); let n = parseInt(p[1] || '0', 10); if(p[0].length) { m[p[0]] = Math.max(n, m[p[0]] || 0); } return m; },{}); const packSM = (o) =&gt; Object.keys(o) .map(k =&gt; ('dead' === k || o[k]&lt;1 || o[k]&gt;9) ? k : `${k}@${parseInt(o[k])}` ).join(','); on("change:graphic:bar1_value", function(obj) { const bv = `bar${bar}_value`; const bm = `bar${bar}_max`; if(obj.get(bm) === "") return; let sm = unpackSM(obj.get('statusmarkers')); if(obj.get(bv) &lt;= obj.get(bm) / 2) { sm[bloodied] = true; } else{ sm[bloodied] = false; } if(obj.get(bv) &lt;= 0) { sm[dead] = true; } else { sm[dead] = false; } obj.set({ statusmarkers: packSM(sm) }); }); }); Let me know if it doesn't work and I'll fix it... If I am using custom status markers, how would I change the default bloodied and dead markers in your script?
1586400821
The Aaron
Forum Champion
API Scripter
Change where it says "red" and "dead" to the tag names of your custom markers. They'll look something like "some_name::12345".&nbsp;
1586445430
The Aaron said: Change where it says "red" and "dead" to the tag names of your custom markers. They'll look something like "some_name::12345".&nbsp; Arg, I was inverting the name and ID! Thanks, Aaron. Will try this. -Jay
1586445734
The Aaron
Forum Champion
API Scripter
No problem, that's easy to do.&nbsp; Let me know if you have any issues.&nbsp;
1586446763
The Aaron said: No problem, that's easy to do.&nbsp; Let me know if you have any issues.&nbsp; Just tried it. The bloodied part works, but it also appends the dead status to the token even though it's not at 0 HP. Also, when you heal the token, the bloodied status doesn't go away.
1586448156

Edited 1586583174
The Aaron
Forum Champion
API Scripter
Whoops.. couple bugs in there...&nbsp; This works: /* global TokenMod */ on('ready',()=&gt;{ // CONFIGURE const bar = 1; const bloodied = "red"; const dead = "dead"; // no edit below here // const unpackSM = (stats) =&gt; stats.split(/,/).reduce((m,v) =&gt; { let p = v.split(/@/); p[0]=p[0].toLowerCase(); let n = parseInt(p[1] || '0', 10); if(p[0].length) { m[p[0]] = Math.max(n, m[p[0]] || 0); } return m; },{}); const packSM = (o) =&gt; Object.keys(o) .map(k =&gt; ('dead' === k || true === o[k] || o[k]&lt;1 || o[k]&gt;9) ? k : `${k}@${parseInt(o[k])}` ).join(','); const handleBarChange = (obj) =&gt; { const bv = parseFloat(obj.get(`bar${bar}_value`)); const bm = parseFloat(obj.get(`bar${bar}_max`)); if(Number.isNaN(bm)){ return; } let sm = unpackSM(obj.get('statusmarkers')); if(bv &lt;= (bm / 2) &amp;&amp; bv &gt; 0) { sm[bloodied] = true; } else{ delete sm[bloodied]; } if(bv &lt;= 0) { sm[dead] = true; } else { delete sm[dead]; } obj.set({ statusmarkers: packSM(sm) }); }; on(`change:graphic:bar${bar}_value`, handleBarChange); if('undefined' !== typeof TokenMod &amp;&amp; TokenMod.ObserveTokenChange){ TokenMod.ObserveTokenChange(handleBarChange); } });
1586450552
Just tested and it works great. Thanks, Aaron!
1586450811
The Aaron
Forum Champion
API Scripter
No problem!
1586577590
Hi Aaron. Running into an issue when using a damage macro that you basically gave me. The macro doesn't trigger the bloodied or dead status markers. Any idea what I'm doing wrong? Here's my hacking of your code: !token-mod --set bar1_value|[[{@{selected|bar1|max},[[@{selected|bar1}-[[?{Damage&amp;#125;|0}]]]]}kl1]] --report all|"/em {name} takes {bar1_value:change} points of damage!"
1586579523
The Aaron
Forum Champion
API Scripter
Nothing at all.&nbsp; API Scripts don't trigger events, so they have to be handled a little differently.&nbsp; I've adjusted the above script so that it will take action when you use TokenMod to adjust a token bar.&nbsp; Cheers!
1586580805
I'm running into an issue where when I use this it sometimes gives the bloody status twice.&nbsp; This occurs when I go from bloody to still bloody but not dead.&nbsp; When the token goes to dead, it removes 1 of the bloody markers but not both of them.&nbsp; If I then heal the token above bloody it does not remove the marker.
1586581039
The Aaron
Forum Champion
API Scripter
That sounds like another script is also marking the token.&nbsp; What scripts do you have installed?
1586581515

Edited 1586581861
Only the one. I did make 2 changes to the script.&nbsp; I have a custom token and I'm using bar3 instead of bar1.
1586582039
The Aaron
Forum Champion
API Scripter
Hmm.&nbsp; I'm having trouble duplicating that behavior.&nbsp; I honestly can't see how it could ever produce duplicates with just this script because of the way it splits out and stores the statuses in an object.&nbsp; Any duplicates should be removed at that point as there could only ever be one property by a given name.
1586582072
The Aaron
Forum Champion
API Scripter
Is the custom token the one getting duplicated?
1586582118
yes the custom token is the one that gets duplicated.
1586583215
The Aaron
Forum Champion
API Scripter
Ok, I figured it out.&nbsp; Use the version I put above (just edited it) and make sure your custom token marker name is all lower case.&nbsp; That should fix it.
1586583373
The Aaron said: Nothing at all.&nbsp; API Scripts don't trigger events, so they have to be handled a little differently.&nbsp; I've adjusted the above script so that it will take action when you use TokenMod to adjust a token bar.&nbsp; Cheers! Thank you. Your fix has solved the issue!
1586583469
I decided to change the dead token to a custom token as well and it appears to add the same strange occurrence.&nbsp; If I ever drop the token a second time below death, it adds a second instance of the custom token.&nbsp; However if I use the default red and dead markers, the problem doesn't occur.
1586583724
The Aaron
Forum Champion
API Scripter
It has to do with case insensitivity.&nbsp; If you grab the version I just edited above, and make sure you have then names of the Custom Tokens lower case (as in "moon::1234" not "Moon::1234"), it should fix the duplication.
1586583740
The Aaron
Forum Champion
API Scripter
Jay R. said: Thank you. Your fix has solved the issue! No problem!
1586584322
YEA! It appears to be working now.&nbsp; Weird that case insensitivity would cause such an issue.&nbsp; Thanks so much.
1586588216
The Aaron
Forum Champion
API Scripter
No problem!
1588551688
JRJR
Pro
Hi The Aaron , Is there a way to get your version of the Bloodied and Dead script to work with the Apply Damage addon to GroupCheck?&nbsp; I've been messing with it some, but I'm not good enough to figure it out. Thanks!
1588778433

Edited 1588778746
Thank you! I have been using your rewrite but I also find that when I change bloodied to use a custom token marker, it adds a second bloodied icon if additional damage is done at less than half health. I have tried with all lower case but I think I'm having trouble with the marker tag.&nbsp; How do I find it?&nbsp; If I use the Roll20 mini script to output the marker names, they don't have the double colon like your examples do.&nbsp; Here's what the name looks like (compared to the default archery token).&nbsp; Any way I can find the "real" marker tag? const bloodied = "243574: bloodied"; &nbsp; edit:&nbsp; Figured it out.&nbsp; The correct way to define the tag in my case is: const bloodied = "bloodied::243574"; Thank you again for updating this script for our use!
1588778592
The Aaron
Forum Champion
API Scripter
JRJR, I can look at doing that.&nbsp; Holt K., I'll see if I can track that down.
1588905399
JRJR
Pro
I do appreciate it, The Aaron.
1589465089
JRJR
Pro
I made it work by just adding the following to the end of the .forEach iterator in ApplyDamage's finalApply function. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let tokenMax = parseInt(token.get(barMax)) if(newValue &lt;= tokenMax / 2) { token.set({ status_redmarker: true }); } else { token.set({ status_redmarker: false }) } if(newValue &lt;= 0) { token.set({ status_dead: true }); token.set({ status_redmarker: false }) } else { token.set({ status_dead: false }); } :) J
1590415462
Question from a "knows nearly nothing about scripts" point of view: Is there a possible way to implement the use of this script for games like Shadowrun? You don't have Hitpoints but a number of wounds =&nbsp; "0" is total healthy......if the number (the bar in roll20) goes up, you are more hurt and will die at 10 wounds. Is there a way to implement this in a config menu?
1590653124

Edited 1590653176
Steve T. said: Question from a "knows nearly nothing about scripts" point of view: Is there a possible way to implement the use of this script for games like Shadowrun? You don't have Hitpoints but a number of wounds =&nbsp; "0" is total healthy......if the number (the bar in roll20) goes up, you are more hurt and will die at 10 wounds. Is there a way to implement this in a config menu? Looking at the code you would probably have to reverse the math so that value of 0 reflects full health, anything above 5 for bloodied.&nbsp; and 10 would be dead.&nbsp; I am not an the scriptomancer scale but changing this might work for you. if(bv &gt; (bm/2) &amp;&amp; bv &lt;=9) { sm[bloodied] = true; } else{ delete sm[bloodied]; } if(bv &gt; 9) { sm[dead] = true; } else { delete sm[dead]; }