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

Function ControlCorpse

TombEngine/Objects/TR3/Object/corpse.cpp:81–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79 }
80
81 void ControlCorpse(short itemNumber)
82 {
83 auto& item = g_Level.Items[itemNumber];
84 const auto& object = Objects[item.ObjectNumber];
85
86 if (item.ItemFlags[7] == (int)CorpseFlag::Fall)
87 {
88 bool isWater = TestEnvironment(RoomEnvFlags::ENV_FLAG_WATER, item.RoomNumber);
89 bool isSwamp = TestEnvironment(RoomEnvFlags::ENV_FLAG_SWAMP, item.RoomNumber);
90
91 float verticalVelCoeff = isWater ? 81.0f : 1.0f;
92
93 auto pointColl = GetPointCollision(item);
94 if (item.RoomNumber != pointColl.GetRoomNumber())
95 {
96 if (TestEnvironment(RoomEnvFlags::ENV_FLAG_WATER, pointColl.GetRoomNumber()) &&
97 !TestEnvironment(RoomEnvFlags::ENV_FLAG_WATER, item.RoomNumber))
98 {
99 int waterHeight = pointColl.GetWaterTopHeight();
100 SplashSetup.Position = Vector3(item.Pose.Position.x, waterHeight - 1, item.Pose.Position.z);
101 SplashSetup.SplashPower = item.Animation.Velocity.y * 4;
102 SplashSetup.InnerRadius = 160.0f;
103
104 SetupSplash(&SplashSetup, pointColl.GetRoomNumber());
105 item.Animation.Velocity.y = 0.0f;
106 }
107
108 ItemNewRoom(itemNumber, pointColl.GetRoomNumber());
109 }
110
111 // Remove fly effect when in water.
112 if (isWater || isSwamp)
113 {
114 item.ItemFlags[FirefliesItemFlags::RemoveFliesEffect] = 1;
115 }
116
117 auto bounds = GameBoundingBox(&item);
118
119 item.Animation.IsAirborne = true;
120
121 if (pointColl.GetFloorHeight() <= item.Pose.Position.y - bounds.Y2)
122 {
123 if (!isWater)
124 {
125 item.Pose.Position.y = pointColl.GetFloorHeight();
126 SoundEffect(SFX_TR4_CROCGOD_LAND, &item.Pose);
127 }
128 else
129 {
130 item.Pose.Position.y = pointColl.GetFloorHeight();
131 }
132
133 item.Animation.IsAirborne = false;
134 item.Animation.Velocity = Vector3::Zero;
135 item.Animation.TargetState = CORPSE_STATE_LAND;
136 item.Animation.AnimNumber = CORPSE_ANIM_LAND;
137
138 item.ItemFlags[7] = (int)CorpseFlag::Grounded;

Callers

nothing calls this directly

Calls 15

TestEnvironmentFunction · 0.85
GetPointCollisionFunction · 0.85
SetupSplashFunction · 0.85
ItemNewRoomFunction · 0.85
SoundEffectFunction · 0.85
AnimateItemFunction · 0.85
TriggerActiveFunction · 0.85
RemoveFirefliesFunction · 0.85
AddActiveItemFunction · 0.85
SpawnFireflySwarmFunction · 0.85
GetWaterTopHeightMethod · 0.80
GetSettingsMethod · 0.80

Tested by

no test coverage detected