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

Function RocketControl

TombEngine/Game/Lara/lara_one_gun.cpp:980–1043  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

978}
979
980void RocketControl(short itemNumber)
981{
982 auto& rocketItem = g_Level.Items[itemNumber];
983
984 // Update velocity and orientation.
985 if (TestEnvironment(ENV_FLAG_WATER, rocketItem.RoomNumber))
986 {
987 if (rocketItem.Animation.Velocity.z > (ROCKET_VELOCITY / 4))
988 {
989 rocketItem.Animation.Velocity.z -= rocketItem.Animation.Velocity.z / 4;
990 }
991 else
992 {
993 rocketItem.Animation.Velocity.z += (rocketItem.Animation.Velocity.z / 4) + 4.0f;
994
995 if (rocketItem.Animation.Velocity.z > (ROCKET_VELOCITY / 4))
996 rocketItem.Animation.Velocity.z = ROCKET_VELOCITY / 4;
997 }
998
999 rocketItem.Pose.Orientation.z += short((rocketItem.Animation.Velocity.z / 8) + 3.0f) * ANGLE(1.0f);
1000 }
1001 else
1002 {
1003 if (rocketItem.Animation.Velocity.z < ROCKET_VELOCITY)
1004 rocketItem.Animation.Velocity.z += (rocketItem.Animation.Velocity.z / 4) + 4.0f;
1005
1006 rocketItem.Pose.Orientation.z += short((rocketItem.Animation.Velocity.z / 4) + 7.0f) * ANGLE(1.0f);
1007 }
1008
1009 rocketItem.Model.Color = Vector4(0.5f, 0.5f, 0.5f, 1.0f);
1010
1011 // Calculate offset in rocket direction for fire and smoke sparks.
1012 auto world = Matrix::CreateTranslation(0, 0, -64) *
1013 Matrix::CreateFromYawPitchRoll(
1014 TO_RAD(rocketItem.Pose.Orientation.y - ANGLE(180.0f)),
1015 TO_RAD(rocketItem.Pose.Orientation.x),
1016 TO_RAD(rocketItem.Pose.Orientation.z));
1017
1018 int wx = world.Translation().x;
1019 int wy = world.Translation().y;
1020 int wz = world.Translation().z;
1021
1022 // Trigger fire, smoke, and light.
1023 TriggerRocketSmoke(wx + rocketItem.Pose.Position.x, wy + rocketItem.Pose.Position.y, wz + rocketItem.Pose.Position.z);
1024 TriggerRocketFire(wx + rocketItem.Pose.Position.x, wy + rocketItem.Pose.Position.y, wz + rocketItem.Pose.Position.z);
1025 SpawnDynamicLight(
1026 wx + rocketItem.Pose.Position.x + (GetRandomControl() & 15) - 8,
1027 wy + rocketItem.Pose.Position.y + (GetRandomControl() & 15) - 8,
1028 wz + rocketItem.Pose.Position.z + (GetRandomControl() & 15) - 8,
1029 14, 28 + (GetRandomControl() & 3), 16 + (GetRandomControl() & 7), (GetRandomControl() & 7));
1030
1031 // Spawn bubbles underwater.
1032 if (TestEnvironment(ENV_FLAG_WATER, rocketItem.RoomNumber))
1033 {
1034 auto pos = rocketItem.Pose.Position.ToVector3() + Vector3(wx, wy, wz);
1035 SpawnBubble(pos, rocketItem.RoomNumber);
1036 }
1037

Callers

nothing calls this directly

Calls 13

TestEnvironmentFunction · 0.85
ANGLEFunction · 0.85
TO_RADFunction · 0.85
TriggerRocketSmokeFunction · 0.85
TriggerRocketFireFunction · 0.85
SpawnDynamicLightFunction · 0.85
GetRandomControlFunction · 0.85
SpawnBubbleFunction · 0.85
HandleProjectileFunction · 0.85
Vector4Function · 0.50
Vector3Function · 0.50
ToVector3Method · 0.45

Tested by

no test coverage detected