Garry's Mod

Garry's Mod

84 ratings
Light Break
   
Award
Favorite
Favorited
Unfavorite
Content Type: Addon
Addon Type: Tool
Addon Tags: Scenic, Realism
File Size
Posted
Updated
569.752 KB
9 Jan, 2022 @ 8:13pm
9 Jan, 2022 @ 9:48pm
2 Change Notes ( view )

Subscribe to download
Light Break

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
Popular Discussions View All (1)
2
24 Jan, 2022 @ 4:21pm
PINNED: Bugs and Suggestions
SubwayJared
11 Comments
dommygutman 2 May, 2023 @ 7:21am 
What are the supported maps?
wizard with a gun 22 Dec, 2022 @ 6:20pm 
aha, now i can make (almost) accurate rush
36R49 13 Dec, 2022 @ 1:59am 
its okey, but steel thank you
SubwayJared  [author] 12 Dec, 2022 @ 6:16pm 
@36R49 The problem is the Source Engine doesn't support the disabling of lights, especially static lights which are commonplace in 99% of maps. Sorry!
36R49 6 Dec, 2022 @ 4:45am 
can you made tool what will be desable light on map or somthing close for that???
Marcus 23 Aug, 2022 @ 1:49pm 
Smooth gameplay
Kiralex 1 Mar, 2022 @ 11:25am 
Niiiice
ඞ amogus ඞ 22 Jan, 2022 @ 3:31am 
weird how N64 games had breakable lights.
hawky_ 15 Jan, 2022 @ 10:59pm 
showcase goes 1 fps
Yavuzhan 15 Jan, 2022 @ 10:45am 
Not bad. Good job mate!