Destructible Lights Mutator (Online/Multiplayer Update)
Posted: 06 Mar 2014, 01:54
Ever wanted to break and destroy every light in a level before? Cause who doesn't love darkness!
[227 ONLY] Destructible Lights v2.4
v2.4 changelog:
-Fixed bug where trigger would trigger other trigger and repeat causing a massive duplication of effects spawning and killing your framerate/sometimes crashing servers and clients. Performance is INCREDIBLY increased now.
-Now works online 100%
-Fixed damage threshold so dealing at least 5 damage to a light will cause it to flicker and spark
DOWNLOAD >>> https://www.dropbox.com/s/6nqayop1peddr ... .zip?raw=1
MEDIA >>> http://www.twitch.tv/shivaxi/b/508581972 - short video showing off the mutator
How To:
INT file included as to show up in your Mutators list, titled "Destructible Lights" or by command line, Mutator = DestructibleLights.DestructibleLights
It's highly recommended you turn permanent decals on by going to Options, Advanced Options, Decals, Config, and set DecalLifeSpan to 0. This will ensure the burn mark does not disappear, which is actually spawned to darken unlit textures =P Yes, kinda hacky I know. I'd also recommend turning off UseAA and setting NumAASamples to FALSE in your rendering options, as this seems to have a performance impact on the particle emitters, and Destructible Lights may lag at times when blowing up lights.
Again, this is for Single Player only! Will not work correctly online!
Works online now!
Features:
-Every light totally destructible! (Disclaimer: Some lights, especially those in custom maps, may not fully be breakable)
-Flicker and spark effects when light is damaged
-Shatter and electric sounds when light destroyed
-Sparks, glass, and electric effects when light destroyed
-Exploding lights cause damage in a small nearby radius
-Burn mark decal when lights explode
Right, some of you may have already seen this, as originally this is a part of RLCoop. Releasing this now as a standalone mutator for those who want to enjoy this silly little mod. Yes, every light is now breakable, shatterable, destructible, and so forth. "But shiv! what about lights that aren't supposed to be destructible? Like ambient lighting or lava, etc" So glad you (didnt) asked! For anyone who cares how the mod works, read the following. If not, tldr.
================================
The Science!
(and mostly backstory)
Alright so, this is really simple actually, and honestly I'm surprised that nobody has thought of this before, as this literally took me maybe 10 to 20 minutes to fully script (at least the initial part in order to make lights destroyable). If somebody has thought of this before and there's another mod out that does the same thing, then apologies. Also, I must give some credit to Cheese for inspiring the idea. Several years ago, we made a halloween mutator for my server, which essentially killed all the lights in levels, making it pitch black, and lighting up the skybox orange. And in order for that to work, Cheese made the mutator call the "flush" command to every client who joined the server so that the lighting would update. And only now did that get me thinking, and actually to realize that destructible lights could be possible with that very "flush" command.
This is a simple mutator which spawns a special custom trigger on top of every single light actor. Mutator checks "is this a light?" if yes, spawn this trigger, and set the trigger's Event to the lights name (ex., light23), and set the light's Tag to the light's name (ex. light23). So now the trigger is where the light is, and it triggers the light when triggered...which is triggered by damage of course. What the custom trigger does, is set the light's brightness to 0 when triggered, to whatever light it's attached to. It also sets the light's DrawScale to 0, which makes Corona effects disappear. Now as I mentioned earlier, in order to see that the light's brightness has changed, the "flush" command must be called every time a light trigger is triggered. This way everyone can see the updated lighting. Pretty simple. And since I'm changing light's tags and such, obviously I can't make this work for TriggeredLights, as I'd break some scripted scene stuff.
That was the initial stage and everything worked hunky dory. The hard part comes when differentiating between ambient lighting that isn't supposed to be killed, and light's that should shatter. This is where Bleeder came in and helped me write a tracer code, in which every trigger that spawns on a light, sends out a tracer in every direction, and looks for the nearest light texture. It does this by basically searching for "light" in the texture name. Surprisingly, this works extremely effectively, and most maps (and all stock as far as I've tested) work perfectly. Of course the tracer has a limited range and such as to not attach to some light 50 miles away, and if the tracer finds nothing, the trigger kills itself.
================================
So yeah, that's the core of it essentially. Later on I was thinking about making a customizable mutator to go along with this, where you could specify trigger locations and their attachments to lights for custom levels that don't work 100% with this mutator. But that will be in the future.
I also want to eventually get a multiplayer version working. Right now, the "flush" command does not work online for players...god knows why. I welcome anyone to try and figure that part out, as both Bleeder and I have tried everything, and we're stumped. The only reason it works online in RLCoop, is because we implemented the "flush" command to be called directly from our RLPlayer class. Obviously that's not an acceptable solution for the standalone version here.
Works online now!
[227 ONLY] Destructible Lights v2.4
v2.4 changelog:
-Fixed bug where trigger would trigger other trigger and repeat causing a massive duplication of effects spawning and killing your framerate/sometimes crashing servers and clients. Performance is INCREDIBLY increased now.
-Now works online 100%
-Fixed damage threshold so dealing at least 5 damage to a light will cause it to flicker and spark
DOWNLOAD >>> https://www.dropbox.com/s/6nqayop1peddr ... .zip?raw=1
MEDIA >>> http://www.twitch.tv/shivaxi/b/508581972 - short video showing off the mutator
How To:
INT file included as to show up in your Mutators list, titled "Destructible Lights" or by command line, Mutator = DestructibleLights.DestructibleLights
It's highly recommended you turn permanent decals on by going to Options, Advanced Options, Decals, Config, and set DecalLifeSpan to 0. This will ensure the burn mark does not disappear, which is actually spawned to darken unlit textures =P Yes, kinda hacky I know. I'd also recommend turning off UseAA and setting NumAASamples to FALSE in your rendering options, as this seems to have a performance impact on the particle emitters, and Destructible Lights may lag at times when blowing up lights.
Again, this is for Single Player only! Will not work correctly online!
Works online now!
Features:
-Every light totally destructible! (Disclaimer: Some lights, especially those in custom maps, may not fully be breakable)
-Flicker and spark effects when light is damaged
-Shatter and electric sounds when light destroyed
-Sparks, glass, and electric effects when light destroyed
-Exploding lights cause damage in a small nearby radius
-Burn mark decal when lights explode
Right, some of you may have already seen this, as originally this is a part of RLCoop. Releasing this now as a standalone mutator for those who want to enjoy this silly little mod. Yes, every light is now breakable, shatterable, destructible, and so forth. "But shiv! what about lights that aren't supposed to be destructible? Like ambient lighting or lava, etc" So glad you (didnt) asked! For anyone who cares how the mod works, read the following. If not, tldr.
================================
The Science!
(and mostly backstory)
Alright so, this is really simple actually, and honestly I'm surprised that nobody has thought of this before, as this literally took me maybe 10 to 20 minutes to fully script (at least the initial part in order to make lights destroyable). If somebody has thought of this before and there's another mod out that does the same thing, then apologies. Also, I must give some credit to Cheese for inspiring the idea. Several years ago, we made a halloween mutator for my server, which essentially killed all the lights in levels, making it pitch black, and lighting up the skybox orange. And in order for that to work, Cheese made the mutator call the "flush" command to every client who joined the server so that the lighting would update. And only now did that get me thinking, and actually to realize that destructible lights could be possible with that very "flush" command.
This is a simple mutator which spawns a special custom trigger on top of every single light actor. Mutator checks "is this a light?" if yes, spawn this trigger, and set the trigger's Event to the lights name (ex., light23), and set the light's Tag to the light's name (ex. light23). So now the trigger is where the light is, and it triggers the light when triggered...which is triggered by damage of course. What the custom trigger does, is set the light's brightness to 0 when triggered, to whatever light it's attached to. It also sets the light's DrawScale to 0, which makes Corona effects disappear. Now as I mentioned earlier, in order to see that the light's brightness has changed, the "flush" command must be called every time a light trigger is triggered. This way everyone can see the updated lighting. Pretty simple. And since I'm changing light's tags and such, obviously I can't make this work for TriggeredLights, as I'd break some scripted scene stuff.
That was the initial stage and everything worked hunky dory. The hard part comes when differentiating between ambient lighting that isn't supposed to be killed, and light's that should shatter. This is where Bleeder came in and helped me write a tracer code, in which every trigger that spawns on a light, sends out a tracer in every direction, and looks for the nearest light texture. It does this by basically searching for "light" in the texture name. Surprisingly, this works extremely effectively, and most maps (and all stock as far as I've tested) work perfectly. Of course the tracer has a limited range and such as to not attach to some light 50 miles away, and if the tracer finds nothing, the trigger kills itself.
================================
So yeah, that's the core of it essentially. Later on I was thinking about making a customizable mutator to go along with this, where you could specify trigger locations and their attachments to lights for custom levels that don't work 100% with this mutator. But that will be in the future.
I also want to eventually get a multiplayer version working. Right now, the "flush" command does not work online for players...god knows why. I welcome anyone to try and figure that part out, as both Bleeder and I have tried everything, and we're stumped. The only reason it works online in RLCoop, is because we implemented the "flush" command to be called directly from our RLPlayer class. Obviously that's not an acceptable solution for the standalone version here.
Works online now!