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

Does anyone know of a script that allows a sound (or random playlist of sounds) to play when a tokens health bar is reduced at all?

As the title says, that's what I'm looking for. Do any such scripts exist? (Yes I already have the Aura/Token Health script, but it only plays a sound on death)
1680632181

Edited 1680650814
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi Tony, The Mad! Try this: on('ready', () => {     let playSound = function (trackname, action) {         let track = findObjs({ type: 'jukeboxtrack', title: trackname })[0];         if (track) {             track.set('playing', false);             track.set('softstop', false);             if (action == 'play') {                 track.set('playing', true);             }         }         else {             sendChat('Damage Sound', '/w gm No Track Found...');             log("No track found " + trackname);         }     }     on("change:graphic:bar1_value", function (obj, prev) {             if (prev.bar1_value > obj.get("bar1_value")) { const sounds = ["ouch", "bam", "smash", "pow", "thud", "argh", "wilhelm_scream"]; const random = Math.floor(Math.random() * sounds.length); playSound(sounds[random], 'play');             }     }); }); This is just a quick re-write of my door noise script. To use: change "ouch" to the name of your sound as it is called in the Jukebox change "bar1_value" wherever it occurs to the bar you are using for HP. Above code edited to reflect requested changes from below
1680637401

Edited 1680637436
keithcurtis said: Hi Tony, The Mad! Try this: on('ready', () => {     let playSound = function (trackname, action) {         let track = findObjs({ type: 'jukeboxtrack', title: trackname })[0];         if (track) {             track.set('playing', false);             track.set('softstop', false);             if (action == 'play') {                 track.set('playing', true);             }         }         else {             sendChat('Damage Sound', '/w gm No Track Found...');             log("No track found " + trackname);         }     }     on("change:graphic:bar1_value", function (obj, prev) {             if (prev.bar1_value > obj.get("bar1_value")) {                 playSound("ouch", 'play');             }     }); }); This is just a quick re-write of my door noise script. To use: change "ouch" to the name of your sound as it is called in the Jukebox change "bar1_value" wherever it occurs to the bar you are using for HP. Is there a way It can choose a random sound inside of a Folder?
1680637890

Edited 1680637910
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
That would require a bit more programming to poll the jukebox, but you could easily define a list of track names. replace playSound("ouch", 'play'); with const sounds = ["ouch", "bam", "smash", "pow", "thud", "argh", "wilhelm_scream"]; const random = Math.floor(Math.random() * sounds.length); playSound(sounds[random], 'play'); Totally untested, though.
1680637981

Edited 1680637995
keithcurtis said: Totally untested, though. Well it's about to be lmao
keithcurtis said: That would require a bit more programming to poll the jukebox, but you could easily define a list of track names. replace playSound("ouch", 'play'); with const sounds = ["ouch", "bam", "smash", "pow", "thud", "argh", "wilhelm_scream"]; const random = Math.floor(Math.random() * sounds.length); playSound(sounds[random], 'play'); Totally untested, though. Works like a charm! Say, do you take commissions? I'm kind of looking for a bit more in-depth version of this if possible. Perhaps one that has different sets of sounds depending on the severity of the damage taken, and perhaps sounds that register separately from PCs and NPCs? If you're interested that is. Otherwise, thanks anyway, this is great alone.
1680641670

Edited 1680650695
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thanks, but I'm already busier than a bee. :) Besides, I was lucky enough to have written some similar code. I am usually glacially slow for script writing.
Fair enough, gl to you
CombatMaster lets you choose a sound to play when the HP bar is reduced to 0 AND it automatically adds Token Markers to represent it...
TheMarkus1204 said: CombatMaster lets you choose a sound to play when the HP bar is reduced to 0 AND it automatically adds Token Markers to represent it... Scripts arent saved when you edit their settings, and there's too much there for me to know how to edit through the script itself.
Still? This should be fixed by now! Tony, The Mad said: TheMarkus1204 said: CombatMaster lets you choose a sound to play when the HP bar is reduced to 0 AND it automatically adds Token Markers to represent it... Scripts arent saved when you edit their settings, and there's too much there for me to know how to edit through the script itself.
1680797160

Edited 1680797261
TheMarkus1204 said: Still? This should be fixed by now! Last time I checked anyway, which was a day or 2 ago Edit: oh, it's fixed now....welp....yippie
TheMarkus1204 said: CombatMaster lets you choose a sound to play when the HP bar is reduced to 0 AND it automatically adds Token Markers to represent it... How do you enable this?