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 .
×

[Script] DmgFxSound - Unified Damage FX & Jukebox Audio Manager

1774194443

Edited 1774278130
Code DmgFxSound v2.22 - Automated Damage FX & Audio Manager (System Agnostic) DmgFxSound is a unified combat manager that intercepts HP changes on a token and instantly triggers synchronized WebGL visual FX and Jukebox audio tracks. Whether you are running 5e, a generic ruleset, or a heavily homebrewed sci-fi game, this script handles the visuals and sound effects so you can focus on running the game. Key Features & Highlights Fully GUI-Driven:  The entire script is managed via an in-chat visual dashboard ( !DmgFxSound-menu ). Universal HP Tracking: Triggers automatically whether you edit a token's HP bubble manually, use TokenMod , or use the ApplyDamage script. Heal & Death Integration: Automatically detects when HP goes up (triggering healing FX/sounds) or drops to 0 (triggering customizable death FX/sounds). Granular Toggles: Turn specific visual or audio categories ON or OFF independently directly from the chat menu. The Three System Modes You can swap between three modes on the fly depending on what system you are playing: 5e Mode: The script passively watches the chat log for standard 5e damage types (fire, slashing, radiant, etc.) cast by players or monsters. When an HP drop occurs, it plays the specific FX and sound associated with that damage type. Generic Mode:  It ignores chat entirely and simply plays a generic hit visual and sound whenever HP drops. Custom Mode: Completely system-agnostic. You can add your own custom trigger words (e.g., "plasma", "laser", "pew pew") via the dashboard. The script will watch chat for your specific words and trigger the FX/sounds you assign to them. (It fully supports multi-word triggers!). Smart Jukebox Integration When you copy scripts between games, audio tracks often break if they aren't in the new game's Jukebox. DmgFxSound has built-in validation. It checks your config against the active Jukebox before attempting to play a sound, preventing silent API crashes. It also features a 1-click Reload & Cleanup button to safely purge missing "ghost tracks" from your database. How to Use It Install the script in your API Sandbox. Type !DmgFxSound-menu in chat to open the main dashboard. Add your Jukebox tracks, assign your visual FX shapes/colors, and set your HP bar. Reduce a token's HP and enjoy the show! Link to Code
1774208106
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Scripts are coming out of the woodwork this weekend. Have you considered posting the code in a linked gist? It might make it look less imposing to the casual Pro user considering trying out Mod scripts.
keithcurtis said: Scripts are coming out of the woodwork this weekend. Have you considered posting the code in a linked gist? It might make it look less imposing to the casual Pro user considering trying out Mod scripts. Done! Let me know if I did it wrong.
1774210965
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Surok said: keithcurtis said: Scripts are coming out of the woodwork this weekend. Have you considered posting the code in a linked gist? It might make it look less imposing to the casual Pro user considering trying out Mod scripts. Done! Let me know if I did it wrong. Perfect!
I really like these scripts you've been doing Surok, thank you for your time and work! (I haven't had a chance to add/test any in my games yet :( ) Preliminary Question on this one:  Can we change the *Damage Types* here to catch Types in a non-D&D game: ```const DAMAGE_TYPES = [ 'acid','bludgeoning','cold','fire','force', 'lightning','poison','thunder','radiant','necrotic', 'psychic','piercing','slashing' ];``` For example. in my *Fabula Ultima* game, the damage output in chat (through Script Cards) will report *physical, fire, cold* damage, etc. Would changing those constants work or break things? Or could the script it be tooled to have a "Add Damage Types" field/input in the config to create an array of Damage Types to watch the chat for?
Jukite said: I really like these scripts you've been doing Surok, thank you for your time and work! (I haven't had a chance to add/test any in my games yet :( ) Preliminary Question on this one:  Can we change the *Damage Types* here to catch Types in a non-D&D game: ```const DAMAGE_TYPES = [ 'acid','bludgeoning','cold','fire','force', 'lightning','poison','thunder','radiant','necrotic', 'psychic','piercing','slashing' ];``` For example. in my *Fabula Ultima* game, the damage output in chat (through Script Cards) will report *physical, fire, cold* damage, etc. Would changing those constants work or break things? Or could the script it be tooled to have a "Add Damage Types" field/input in the config to create an array of Damage Types to watch the chat for? It shouldn't. Those are the words the API scans in chat to trigger which FX and sounds. Here's how to do it in the code. 1. Update the DAMAGE_TYPES Array (Around Line 96) This list tells the script which words should appear as buttons in your visual FX configuration menu. Find this block: const DAMAGE_TYPES = [ 'acid' , 'bludgeoning' , 'cold' , 'fire' , 'force' , 'lightning' , 'poison' , 'thunder' , 'radiant' , 'necrotic' , 'psychic' , 'piercing' , 'slashing' ]; Add or replace the words here. Make sure they stay in lowercase and inside quotes. For example, if you wanted to add plasma and laser : const DAMAGE_TYPES = [ 'acid' , 'bludgeoning' , 'cold' , 'fire' , 'force' , 'lightning' , 'poison' , 'thunder' , 'radiant' , 'necrotic' , 'psychic' , 'piercing' , 'slashing' , 'plasma' , 'laser' ]; 2. Update the Chat Parser Regex (Around Line 324) This is the actual "ear" of the script. This Regular Expression (Regex) tells the API exactly which words to listen for in the Roll20 chat log. Find this line: const damageTypeRegex = /\b(acid|bludgeoning|cold|fire|force|lightning|poison|thunder|radiant|necrotic|psychic|piercing|slashing)\b/gi ; Add your new words to this list, separated by the pipe | character: const damageTypeRegex = /\b(acid|bludgeoning|cold|fire|force|lightning|poison|thunder |radiant|necrotic|psychic|piercing|slashing|plasma|laser)\b/gi ;
Thanks Surok, that was kinda the process I was thinking it might be (Appreciate the breakdown/explanation!)
1774257399

Edited 1774258657
Really nice work Surok, can't wait to implement it in my Traveller & Fantasy Trip games. Quick question, my Traveller game outputs combat to the chat looking like the attached image.  If I put, say, 'autopistol' in your damage types would it trigger? (I'm thinking to use it to play an autopistol shooting sound.  
1774264058

Edited 1774264177
Norman said: Really nice work Surok, can't wait to implement it in my Traveller & Fantasy Trip games. Quick question, my Traveller game outputs combat to the chat looking like the attached image.  If I put, say, 'autopistol' in your damage types would it trigger? (I'm thinking to use it to play an autopistol shooting sound.   If you follow the above to change the word triggers in 5e mode you can. You might change the one of the words like "force" to "autopistol". Load up your audio file maybe called "pew pew" and assign it the category "force" if the doesn't change, if it did change "autopistol". Now whenever the chat spits out the word "autopistol" and you change a token's hp it will fire off the "pew pew" audio file and the associated FX. Seems folks want more customization for their particular games. I should work on that.  
Updated with Custom mode with UI improvements!
Hi Surok. I haven't had a chance to play with this new script. Just curious, are the config settings exportable? I would like to set this up on one of my campaigns and "copy/paste" settings across my other campaigns. Is there a way to export settings and import settings? Or is there a handout that contains the config settings that I could transmogrify to other campaigns?
Pak said: Hi Surok. I haven't had a chance to play with this new script. Just curious, are the config settings exportable? I would like to set this up on one of my campaigns and "copy/paste" settings across my other campaigns. Is there a way to export settings and import settings? Or is there a handout that contains the config settings that I could transmogrify to other campaigns? Yes there is a handout called "DmgFxSoundConfig" in the journal with all the settings and you should be able to transmog it over. Just remember you still have to have the audio files loaded in each game.