Skip to content
This repository was archived by the owner on May 3, 2026. It is now read-only.

Commit 7e12cea

Browse files
authored
Merge pull request #15 from Project-Collapse-Studios/psc-dev
changer: Re-enable dynamic priority (requires hijackcompiler)
2 parents 82b0a67 + 078aede commit 7e12cea

1 file changed

Lines changed: 32 additions & 10 deletions

File tree

transforms/dynamic_priority.py

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
@trans("Dynamic Priority")
1010
def dynamic_priority(ctx: Context):
11-
return # Will re-enable once p2ce fixes the crucial bugs with lights
1211
vmf = ctx.vmf
1312

1413
light: Entity
@@ -39,6 +38,8 @@ def dynamic_priority(ctx: Context):
3938

4039
lg0_static_style = available_styles[0]
4140
lg1_static_style = available_styles[1]
41+
lg0_dynamic_style = available_styles[2]
42+
lg1_dynamic_style = available_styles[3]
4243

4344
for light in lights:
4445

@@ -95,27 +96,48 @@ def dynamic_priority(ctx: Context):
9596

9697
if dynpr == 0:
9798
light_copy["style"] = lg0_static_style
99+
light["style"] = lg0_dynamic_style
98100
elif dynpr == 1:
99101
light_copy["style"] = lg1_static_style
102+
light["style"] = lg1_dynamic_style
100103

101104
# Create a static copy
102105
light_copy["_lightmode"] = 0 # Fully static
103106

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+
104114
# 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
114124

115125
vmf.add_ents([light_copy])
116126
vmf.add_ents([light_bounce])
117127

118128

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+
119141

120142
def AddLogic(vmf: VMF, pos: Vec):
121143
"""Add the necessary logic to load the saved state on every map load."""

0 commit comments

Comments
 (0)