|
8 | 8 |
|
9 | 9 | @trans("Dynamic Priority") |
10 | 10 | def dynamic_priority(ctx: Context): |
11 | | - return # Will re-enable once p2ce fixes the crucial bugs with lights |
12 | 11 | vmf = ctx.vmf |
13 | 12 |
|
14 | 13 | light: Entity |
@@ -39,6 +38,8 @@ def dynamic_priority(ctx: Context): |
39 | 38 |
|
40 | 39 | lg0_static_style = available_styles[0] |
41 | 40 | lg1_static_style = available_styles[1] |
| 41 | + lg0_dynamic_style = available_styles[2] |
| 42 | + lg1_dynamic_style = available_styles[3] |
42 | 43 |
|
43 | 44 | for light in lights: |
44 | 45 |
|
@@ -95,27 +96,48 @@ def dynamic_priority(ctx: Context): |
95 | 96 |
|
96 | 97 | if dynpr == 0: |
97 | 98 | light_copy["style"] = lg0_static_style |
| 99 | + light["style"] = lg0_dynamic_style |
98 | 100 | elif dynpr == 1: |
99 | 101 | light_copy["style"] = lg1_static_style |
| 102 | + light["style"] = lg1_dynamic_style |
100 | 103 |
|
101 | 104 | # Create a static copy |
102 | 105 | light_copy["_lightmode"] = 0 # Fully static |
103 | 106 |
|
| 107 | + # Static lights are brighter than dynamic, so tweak this value |
| 108 | + r, g, b, I = light_copy["_light"].split(" ") |
| 109 | + I = conv_int(I) |
| 110 | + I *= .5 |
| 111 | + I = int(I) |
| 112 | + light_copy["_light"] = f"{r} {g} {b} {I}" |
| 113 | + |
104 | 114 | # We expect the mode to be medium by default, it also limits the amount of lights being switched at once when changing from this mode on map load |
105 | | - #if dynpr == 1: # Medium, set the static light to dark |
106 | | - # spawnflags = conv_int(light_copy["spawnflags", 0]) |
107 | | - # spawnflags |= 1 # Sets Initially Dark to True |
108 | | - # light_copy["spawnflags"] = spawnflags |
109 | | - # |
110 | | - #elif dynpr == 0: # Low, set the dynamic light to dark |
111 | | - spawnflags = conv_int(light["spawnflags", 0]) |
112 | | - spawnflags |= 1 # Sets Initially Dark to True |
113 | | - light["spawnflags"] = spawnflags |
| 115 | + if dynpr == 1: # Medium, set the static light to dark |
| 116 | + spawnflags = conv_int(light_copy["spawnflags", 0]) |
| 117 | + spawnflags |= 1 # Sets Initially Dark to True |
| 118 | + light_copy["spawnflags"] = spawnflags |
| 119 | + |
| 120 | + elif dynpr == 0: # Low, set the dynamic light to dark |
| 121 | + spawnflags = conv_int(light["spawnflags", 0]) |
| 122 | + spawnflags |= 1 # Sets Initially Dark to True |
| 123 | + light["spawnflags"] = spawnflags |
114 | 124 |
|
115 | 125 | vmf.add_ents([light_copy]) |
116 | 126 | vmf.add_ents([light_bounce]) |
117 | 127 |
|
118 | 128 |
|
| 129 | + # HACK: Make VRAD skip processing dynamic lights |
| 130 | + match light["classname"]: |
| 131 | + case "light_rt_spot": |
| 132 | + light["classname"] = "_dynpr_rt_spot" |
| 133 | + |
| 134 | + case "light_rt": |
| 135 | + light["classname"] = "_dynpr_rt" |
| 136 | + |
| 137 | + case _: |
| 138 | + pass |
| 139 | + |
| 140 | + |
119 | 141 |
|
120 | 142 | def AddLogic(vmf: VMF, pos: Vec): |
121 | 143 | """Add the necessary logic to load the saved state on every map load.""" |
|
0 commit comments