MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / ElectricalLightControl

Function ElectricalLightControl

TombEngine/Objects/TR5/Light/tr5_light.cpp:114–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114void ElectricalLightControl(short itemNumber)
115{
116 auto* item = &g_Level.Items[itemNumber];
117 auto* lightPtr = &GetElectricalLightInfo(*item);
118
119 if (!TriggerActive(item))
120 {
121 item->ItemFlags[0] = 0;
122 item->MeshBits.Clear(abs(item->TriggerFlags));
123 return;
124 }
125
126 int intensity = 0;
127
128 // NOTE: Positive TriggerFlags allows light to behave like a neon light. Negative OCB makes the light flicker.
129 if (item->TriggerFlags > 0)
130 {
131 item->MeshBits.Set(item->TriggerFlags);
132
133 if (item->ItemFlags[0] < 16)
134 {
135 intensity = (GetRandomControl() & 0x3F) * 4;
136 item->ItemFlags[0]++;
137 }
138 else if (item->ItemFlags[0] >= 96)
139 {
140 if (item->ItemFlags[0] >= 160)
141 {
142 intensity = 255 - (GetRandomControl() & 0x1F);
143 }
144 else
145 {
146 intensity = 96 - (GetRandomControl() & 0x1F);
147 if (!(GetRandomControl() & 0x1F) && item->ItemFlags[0] > 128)
148 item->ItemFlags[0] = 160;
149 else
150 item->ItemFlags[0]++;
151 }
152 }
153 else
154 {
155 if (Wibble & 0x3F && GetRandomControl() & 7)
156 {
157 intensity = GetRandomControl() & 0x3F;
158 item->ItemFlags[0]++;
159 }
160 else
161 {
162 intensity = 192 - (GetRandomControl() & 0x3F);
163 item->ItemFlags[0]++;
164 }
165 }
166 }
167 else
168 {
169 item->MeshBits.Set(abs(item->TriggerFlags));
170
171 if (item->ItemFlags[0] <= 0)

Callers

nothing calls this directly

Calls 8

TriggerActiveFunction · 0.85
GetRandomControlFunction · 0.85
GenerateIntFunction · 0.85
SoundEffectFunction · 0.85
SpawnDynamicLightFunction · 0.85
Vector4Function · 0.50
ClearMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected