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] Darkness - Darkness and Fog effects for Roll20

1792528746
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Darkness is a new script for modeling the Darkness and Fog Cloud spells, and similar magical darkness or obscuring clouds, with dynamic lighting. The usual approaches each have a drawback. Dynamic lighting walls block movement. Turning vision on and off means tracking which tokens had vision to begin with. This script places an opaque image on the foreground layer and changes only the settings it needs to, saving and restoring each one. [ Demo video ] [ Code - until One-Click ] What a field does Tokens inside a field cannot see. Their field of vision and night vision are set to 0 degrees, so darkvision does not help. Inside darkness, light sources on any layer are put out. Fog does not affect light. Where the two overlap, darkness wins. Nameplates, bars and auras of tokens inside a field are hidden from players. Everything is restored when the token leaves, or when the field is turned off or deleted. Tokens move in and out freely, and so does the field. Moving or resizing the field rechecks every token on the page. How to use it Type !darkness in chat to open the menu. Select a token (or a group, or nothing) and click Place Darkness Token. It is placed beside the token, at the center of the group, or in the middle of the page with your view pulled there. Click Darkness (15 ft), Fog Cloud (20 ft), Custom (any effect and radius) or Emanation. Each effect gets its own panel in the menu with buttons to switch type, manage immunity, locate it, turn it off or delete it. Effects are labeled (Darkness A, Fog B) with a nameplate only the GM sees, so several at once stay easy to tell apart. The bottom of the menu has All Off, Delete All and Refresh. Emanation Emanation centers the field on a creature and measures the radius from the edge of its space. The field follows the creature as it moves and is deleted when the creature is deleted. This covers Darkness cast on an object a creature carries, or a creature with a darkness aura. Immunity Creatures with Devil's Sight, blindsight or truesight can be added to a darkness list or a fog list. Click + Immune in the menu, then click the creature. Immune creatures keep their sight in that type of field. Their lights and nameplates are still affected. Setup There is none beyond installing. The first placement creates a GM-only character named Darkness Effect. Its token actions repeat the menu's controls, and its GM Notes hold the immunity lists. !darkness --setup repairs it if needed. Works with Token changes made through TokenMod, ScriptCards and SmartAoE are detected. If anything else moves a token without notice, the Refresh button corrects it. Questions, bug reports and suggestions are welcome in this thread. Type !darkness --help in game, or click the ? on any menu, for the in-game help. An earlier version of this appeared on my Patreon .
1792528759
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Reserved
Keith, Looks amazing as always. I recently ran a drow campaign and used Nick Olivo's darkness script but your version works better in my opinion and also has the fog function. Have you though about blindsight with specific ranges ?. One of my players has the blind fighting feat which gives blindsight for 10ft and based on the video I'm not sure if there's a way to set this up. Was waiting for the script to appear in 1 clock before installing
1792678039
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The biggest drawback to using the Foreground Layer for a darkness field is that it's all or nothing. I could add in player-specific visible auras and nameplates, but that gets very complicated very quickly. I'll have to give it some thought.
If the Roll20 devs ever figure out how to assign specific visibility tokens it will make a lot of things possible. I'm referring to allowing certain tokens to be visible to only certain players, similar to how the visibility of specific handouts and character sheets can be designated.
1792682985
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Rick A. said: If the Roll20 devs ever figure out how to assign specific visibility tokens it will make a lot of things possible. I'm referring to allowing certain tokens to be visible to only certain players, similar to how the visibility of specific handouts and character sheets can be designated. That would be handy. There's a lot of cool things you could do with that. It also could make some instances of troubleshooting very difficult.
Increasing the number of things that can be done always increases the number of things that can be done incorrectly :D keithcurtis said: That would be handy. There's a lot of cool things you could do with that. It also could make some instances of troubleshooting very difficult.
1792697356
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Rick A. said: Increasing the number of things that can be done always increases the number of things that can be done incorrectly. I am dubbing this "Rick's Law".
1792828517

Edited 1792830532
Hiya Keith, I have just finished my own API for this that automates the immunity for truesight, devil's sight and the shadow magic sorc subclass (on cast they can spend points to see in their own spell) .  I like your use of the foreground layer since it sidesteps the dynamic lighting requirement, is there any way to customise the effect (I have one I particularly like -see pics)? Never mind - that wouldn't work (I've just loaded your API).  I am having some trouble - I can spawn in the initial generic token, move it to desired place and then click darkness, with Sae previously selected as immune, but Sae still can't see within the area?  GM view to left, Player View to Right (ie NOT CTRL+L).  Tested with a full dummy account login too
1792854711
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I mention that either above or in the video. This technique is not perfect when using Truesight, Devil's Sight, etc. Roll20 does not allow for that level of granularity for the foreground Layer, unfortunately.
Thanks Keith.  I hadn't thought of the foreground layer and really like the option to tag a token as being able to see.  Love your structure for APIs, always so clean as a UI
1792872078
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thank you!
Keith, Using this script has got me thinking about automatically controlling vision on a token based on if that token is in a light source. So for example if the token doesn't have dark vision it will lose the ability to see around itself if it moves into an area of darkness and then reset vision when it re enters a lit area. Wondered if this could be something added to this script or a spin off script be easily developed although not wanting to create unnecessary work. I've used check light level before but that requires selecting a token and running a macro. I've also used a Scriptlet you produced called Light Meter which added a full. half or eclipsed sun symbol after the token name but this requires displaying token names which we've recently moved away from. Thought it worth asking the question.
1794088318
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hmm. How would that act differently than regular Dynamic Lighting? The only difference I can see is that if a token lost sight while in darkness, it would also lose the ability to see distant light sources. What's the use case you envision? I.e. what are you trying to model?
Hi Keith, You're right as I may not have fully thought that through and we definitely don't want to lose the ability to see distant light. We're a small group so normally have a player or 2 have 2 characters and so benefit from seeing what both characters can see. I was thinking of controlling the vision of a selected token and losing the benefit gained from controlling multiple tokens. A similar situation can occur with summoned creatures/companions That said we're starting a new campaign in January with players limited to 1 character each so dynamic lighting will act as intended.  
"... controlling the vision of a selected token and losing the benefit gained from controlling multiple tokens. A similar situation can occur with summoned creatures/companions" This is also a big pain point for myself and my group, for similar reasons. What I wish for is vision to work like follows (with Dynamic Lighting enabled): In combat: On their turn, a player should see only what that specific controlled token whose turn it is can see, unless  they have another token like a familiar whose senses they can borrow. This would hold true regardless of how many tokens they control. On someone else's turn, a player should only see what the token they've selected can see. Never the whole map, or the sum of what all their controlled tokens can see. For this to work, they would need to be able to see all their controlled tokens, which might work if they all have Vision Range=0 unless selected? Outside combat: If no controlled tokens are selected, they should see the sum total of the vision of all their  controlled tokens. If a controlled token is selected, they should see only what that token sees, unless they have another token like a familiar whose senses they can borrow.  If Dynamic Lighting is not enabled, then I would expect all characters to be able to see everything, just like they do now.
Love it. Just wondering if there are any plans to give it settings so that the players can have some minimal control? Like when they cast the spell Darkness themselves
1794439221
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Ed W. said: Love it. Just wondering if there are any plans to give it settings so that the players can have some minimal control? Like when they cast the spell Darkness themselves I'll look into that on the next update.
Keith, Thank you VERY much for this script!   Something like this was at the top of my wish list. I would like to know, is there a way to use this via commands?   I would like to have a scriptcard that allows me to create the darkness via a spell script.  Maybe have it prompt for a token to cast on, or when I run the scriptcard to have it bring up the target reticule for the player to move around and place the spell?         Thank you again!
1796340746
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi Tilt! Here's a pro tip for working with Roll20 scripts that use button interfaces. The only way those buttons can send commands to the Mod Script Server is via chat commands. That's all buttons do. So after you press a command, click into the chat input area and press the up arrow key. That will give you the command the button sent by any script. By doing this for each command, you can copy the codes that were sent. That should allow you to cover most cases. But here is a table, listing the commands: Darkness: Command Reference Commands act on the selected darkness token. !darkness                                                 Open the menu for the current page !darkness --help                                          Show help !darkness --place                                         Place a targeting token beside the selection, at the center of a group, or mid-page !darkness --set dark [radius]                             Turn on darkness (default 15 ft) !darkness --set fog [radius]                          Turn on fog (default 20 ft) !darkness --set dark|fog [radius] --link token_id Emanation centered on and following a token !darkness --off                                          Turn the effect off (back to targeting) !darkness --unlink                                  Stop an emanation following its token !darkness --locate                                 Ping the effect for the GM !darkness --delete                                  Delete the effect !darkness --immune dark|fog token_id                  Add a creature to an immunity list !darkness --unimmune dark|fog token_id                  Remove a creature from an immunity list !darkness --clearimmune Yes                          Empty both immunity lists, campaign-wide !darkness --alloff                                  Turn off every effect on the page !darkness --deleteall Yes                          Delete every effect on the page !darkness --refresh Recheck every token !darkness --setup Create or repair the Darkness Effect character !darkness --ids List character IDs of selected tokens Use @{target|token_id} in place of token_id to click a token, and ?{...} queries for any value.