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

Function ChaffFlareControl

TombEngine/Objects/TR5/Entity/tr5_submarine.cpp:351–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349 }
350
351 void ChaffFlareControl(short itemNumber)
352 {
353 auto* item = &g_Level.Items[itemNumber];
354
355 if (item->Animation.Velocity.y)
356 {
357 item->Pose.Orientation.x += ANGLE(3.0f);
358 item->Pose.Orientation.z += ANGLE(5.0f);
359 }
360
361 int dx = item->Animation.Velocity.z * phd_sin(item->Pose.Orientation.y);
362 int dz = item->Animation.Velocity.z * phd_cos(item->Pose.Orientation.y);
363
364 item->Pose.Position.x += dx;
365 item->Pose.Position.z += dz;
366
367 if (TestEnvironment(ENV_FLAG_WATER, item->RoomNumber))
368 {
369 item->Animation.Velocity.y += (5.0f - item->Animation.Velocity.y) / 2.0f;
370 item->Animation.Velocity.z += (5.0f - item->Animation.Velocity.z) / 2.0f;
371 }
372 else
373 {
374 item->Animation.Velocity.y += g_GameFlow->GetSettings()->Physics.Gravity;
375 }
376
377 item->Pose.Position.y += item->Animation.Velocity.y;
378
379 DoProjectileDynamics(itemNumber, item->Pose.Position.x, item->Pose.Position.y, item->Pose.Position.z, dx, item->Animation.Velocity.y, dz);
380
381 auto pos1 = GetJointPosition(item, 0, Vector3i(0, 0, (GlobalCounter & 1) != 0 ? 48 : -48));
382 auto pos2 = GetJointPosition(item, 0, Vector3i(0, 0, 8 * ((GlobalCounter & 1) != 0 ? 48 : -48)));
383 TriggerTorpedoBubbles(&pos1, &pos2, 1);
384
385 if (item->ItemFlags[0] >= 300)
386 {
387 if (!item->Animation.Velocity.y && !item->Animation.Velocity.z)
388 {
389 if (item->ItemFlags[1] <= 90)
390 item->ItemFlags[1]++;
391 else
392 KillItem(itemNumber);
393 }
394 }
395 else
396 item->ItemFlags[0]++;
397 }
398
399 void TorpedoControl(short itemNumber)
400 {

Callers

nothing calls this directly

Calls 10

ANGLEFunction · 0.85
phd_sinFunction · 0.85
phd_cosFunction · 0.85
TestEnvironmentFunction · 0.85
DoProjectileDynamicsFunction · 0.85
GetJointPositionFunction · 0.85
TriggerTorpedoBubblesFunction · 0.85
KillItemFunction · 0.85
GetSettingsMethod · 0.80
Vector3iClass · 0.70

Tested by

no test coverage detected