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

Function ExplodingDeath

TombEngine/Game/effects/tomb4fx.cpp:1231–1300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1229}
1230
1231void ExplodingDeath(short itemNumber, short flags)
1232{
1233 ItemInfo* item = &g_Level.Items[itemNumber];
1234
1235 ObjectInfo* obj;
1236 if (item->IsLara() && Objects[ID_LARA_SKIN].loaded)
1237 obj = &Objects[ID_LARA_SKIN];
1238 else
1239 obj = &Objects[item->ObjectNumber];
1240
1241 auto world = item->Pose.Orientation.ToRotationMatrix();
1242
1243 // If only BODY_PART_EXPLODE flag exists but not BODY_EXPLODE, add it.
1244 if ((flags & BODY_PART_EXPLODE) && !(flags & BODY_DO_EXPLOSION))
1245 flags |= BODY_DO_EXPLOSION;
1246
1247 for (int i = 0; i < obj->nmeshes; i++)
1248 {
1249 if (!item->MeshBits.Test(i))
1250 continue;
1251
1252 item->MeshBits.Clear(i);
1253
1254 if (i == 0 || ((GetRandomControl() & 3) != 0 && (flags & BODY_DO_EXPLOSION)))
1255 {
1256 auto bonePos = GetJointPosition(item, i, Vector3i::Zero);
1257
1258 short fxNumber = CreateNewEffect(item->RoomNumber);
1259 if (fxNumber != NO_VALUE)
1260 {
1261 auto* fx = &EffectList[fxNumber];
1262
1263 fx->pos.Position.x = bonePos.x;
1264 fx->pos.Position.y = bonePos.y - BODY_PART_SPAWN_VERTICAL_OFFSET;
1265 fx->pos.Position.z = bonePos.z;
1266
1267 fx->roomNumber = item->RoomNumber;
1268 fx->pos.Orientation.x = 0;
1269 fx->pos.Orientation.y = Random::GenerateAngle();
1270
1271 if (!(flags & BODY_NO_RAND_VELOCITY))
1272 {
1273 if (flags & BODY_MORE_RAND_VELOCITY)
1274 fx->speed = GetRandomControl() >> 12;
1275 else
1276 fx->speed = GetRandomControl() >> 8;
1277 }
1278
1279 if (flags & BODY_NO_VERTICAL_VELOCITY)
1280 fx->fallspeed = 0;
1281 else
1282 {
1283 if (flags & BODY_LESS_IMPULSE)
1284 fx->fallspeed = -(GetRandomControl() >> 8);
1285 else
1286 fx->fallspeed = -(GetRandomControl() >> 12);
1287 }
1288

Callers 9

SmallSpiderControlFunction · 0.85
ControlTwinAutoGunFunction · 0.85
ControlCentaurFunction · 0.85
GiantMutantControlFunction · 0.85
SmashObjectFunction · 0.85
SkeletonControlFunction · 0.85
ControlSentryGunFunction · 0.85
CreatureDieFunction · 0.85
ExplodeVehicleFunction · 0.85

Calls 9

GetRandomControlFunction · 0.85
GetJointPositionFunction · 0.85
CreateNewEffectFunction · 0.85
GenerateAngleFunction · 0.85
ExplodeItemNodeFunction · 0.85
IsLaraMethod · 0.80
ToRotationMatrixMethod · 0.45
TestMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected