Light Break

If you liked this item, please rate it up on Steam Workshop page.

Author: SubwayJared

Last revision: 10 Jan, 2022 at 04:48 UTC

File size: 569.75 KB

On Steam Workshop

Description:
The closest approximation to breakable lights in this dinosaur of an engine

Either no one did this before or did it better but it never saw the light of day, but here’s an attempt at making lights breakable. Not exactly breakable per se, but only an illusion by using entities (shootable_light especifically) and firing TurnOn/TurnOff inputs.

To make lights breakable, just type shootlight_setup in console and it’ll set it up for you

Features
  • Hammer lights (light, light_dynamic and light_spot) can now be made breakable!
  • Gmod lights and lamps are also breakable!
  • Like… 8 convars
  • A lightweight map for testing the addon (light_break_testmap.bsp)
  • Future : Developer config file to add support for custom light entities

Problems (Developer Gobbledigook)

I didn’t do this with some kind of super deep academic research mindset for other developers to solve these problems, but here are some (not necessarily bugs) that I encountered during the making of this :

  • If a map’s light entity isn’t dynamic and it isn’t named, it won’t register in the server’s entity list, which means you can’t fetch it through ents.GetAll(). Here’s the doozy : Every. Single. ♥♥♥♥♥♥♥. Map. has 1 or 2 named lights at best and the rest is unnamed. Of course this is for peformance reasons, but it makes the addon nearly pointless unless a dark map with manually spawned lights or a custom suited map is used.
  • There is almost no way to circumvent these unregistered lights through scripts. I tried engine.LightStyle() but that messes up the whole map and most of the time doesn’t work.

    I can only imagine being able to make a fully fledged breakable light system by abusing the absolute hell out of the render library or just straight up building a new engine

ConVars

If you forget what a convar does or was, just type its name and it will show you its helptext/default value

  • shootlight_mapents : Defines if light entities from the map (light, light_dynamic, etc) should be breakable
  • shootlight_ent_alpha : Defines shootable_light’s visibility
  • shootlight_removeonbreak : Removes the shootable_light entity when the light breaks, not recommended unless peformance is bad (Make sure to refresh the map’s lights with a cleanup/save if it was off and you turned it on again)
  • shootlight_ent_scale : Defines shootable_light’s scale
  • shootlight_ent_model : Defines shootable_light’s model
  • shootlight_ent_material : Defines shootable_light’s material
  • shootlight_ent_hp : Defines shootable_light’s minimum and maximum health, format : <min>,<max>
  • shootlight_debughalo : (DEBUG) Creates a blue halo around a shootable_light, admin-only (REQUIRES RESTART!)
Console Commands
  • shootlight_setup <arg1> : (Used in the video at the start) Creates shootable_light entities and connects them to compatible light entities, aka, makes them breakable. The optional first argument (arg1) can be either
    • clean : Only cleans up every shootable_light entity on the map
    • noclean : Creates shootable_light entities without cleaning existing ones first (Not recommended)

    Leaving arg1 blank will clean the map of shootable_lights and fill it up again with new ones

How long did this take you to do…?

One whole sunday 🙁

Credits

Code -Me
Map -Me