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

Function FlameEmitterControl

TombEngine/Objects/Effects/flame_emitters.cpp:141–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139 }
140
141 void FlameEmitterControl(short itemNumber)
142 {
143 auto* item = &g_Level.Items[itemNumber];
144 bool active = (item->TriggerFlags < 0) ? TriggerActive(item) : CalculateActiveState(item);
145
146 if (active)
147 {
148 // Jet flame.
149 if (item->TriggerFlags < 0)
150 {
151 short ocb = -item->TriggerFlags;
152 if ((ocb & 7) == 2 || (ocb & 7) == 7)
153 {
154 // Constant flames.
155 SoundEffect(SFX_TR4_FLAME_EMITTER, &item->Pose);
156 TriggerSuperJetFlame(item, -256 - (3072 * GlobalCounter & 0x1C00), GlobalCounter & 1);
157
158 auto color = GetFlameColor(item->Model.Color);
159 SpawnDynamicLight(item->Pose.Position.x, item->Pose.Position.y, item->Pose.Position.z,
160 (GetRandomControl() & 3) + 20,
161 color.x, color.y, color.z);
162 }
163 else
164 {
165 // Intermittent flames.
166 auto& pauseTimer = item->ItemFlags[0];
167 auto& jetFlameVel = item->ItemFlags[1];
168 auto& smallFlameAlpha = item->ItemFlags[2];
169 auto& flameTimer = item->ItemFlags[3];
170
171 if (pauseTimer)
172 {
173 if (jetFlameVel)
174 jetFlameVel = jetFlameVel - (jetFlameVel >> 2);
175
176 if (smallFlameAlpha > 0)
177 {
178 smallFlameAlpha -= 8;
179 }
180 else
181 {
182 smallFlameAlpha = 0;
183 }
184
185 pauseTimer--;
186 if (pauseTimer == 1)
187 flameTimer = (GetRandomControl() & 0x3F) + 150;
188 }
189 else
190 {
191 if (!--flameTimer)
192 {
193 pauseTimer = ((ocb % 8) != 0) ?
194 Random::GenerateInt(2 * FPS, 4 * FPS) : // Pause of 2 to 4 seconds.
195 Random::GenerateInt((ocb / 8) * FPS, FPS + ((ocb / 8 * FPS))); // Pause of 1 second * (ocb / 8) to 1 second plus 1 second * (ocb / 8).
196 }
197
198 if (smallFlameAlpha < UCHAR_MAX)

Callers

nothing calls this directly

Calls 11

TriggerActiveFunction · 0.85
CalculateActiveStateFunction · 0.85
SoundEffectFunction · 0.85
TriggerSuperJetFlameFunction · 0.85
GetFlameColorFunction · 0.85
SpawnDynamicLightFunction · 0.85
GetRandomControlFunction · 0.85
GenerateIntFunction · 0.85
AddFireFunction · 0.85
TestProbabilityFunction · 0.85
BurnNearbyItemsFunction · 0.85

Tested by

no test coverage detected