| 1229 | } |
| 1230 | |
| 1231 | void 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 |
no test coverage detected