MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DestroyObject

Function DestroyObject

Descent3/fireball.cpp:1350–1431  ·  view source on GitHub ↗

Destroy an object immediately

Source from the content-addressed store, hash-verified

1348#define FADE_TIME 2.0
1349// Destroy an object immediately
1350void DestroyObject(object *objp, float explosion_mag, int death_flags) {
1351 ASSERT(IS_GENERIC(objp->type) || (objp->type == OBJ_DOOR));
1352 // Say this this object is dying (if not already set)
1353 objp->flags |= OF_DYING;
1354 // Create blast ring if enabled for this object
1355 if (death_flags & DF_BLAST_RING)
1356 CreateObjectBlastRing(objp);
1357 // Do a shake & shockwave only if the object either breaks apart or has fireballs
1358 if ((death_flags & DF_FIREBALL) || (death_flags & DF_BREAKS_APART)) {
1359 // Shake the player. The odd magnitude is from Jason's old code.
1360 // maybe it would make more sense to base the shake on the explosion size
1361 float dist = vm_VectorDistanceQuick(&Player_object->pos, &objp->pos);
1362 if (dist / objp->size < 30.0)
1363 AddToShakeMagnitude(objp->size * 5.0 - dist / 6.0);
1364 // Do a shockwave
1365 MakeShockwave(objp, objp->handle);
1366 }
1367 // Play sound if not flagged to play at start of delay
1368 if (!(death_flags & DF_DELAY_SOUND))
1369 PlayObjectExplosionSound(objp);
1370 // Do death spew if generic object
1371 if (IS_GENERIC(objp->type)) {
1372 if (!((Game_mode & GM_MULTI) && (Netgame.local_role != LR_SERVER)))
1373 if (Demo_flags != DF_PLAYBACK)
1374 DoDeathSpew(objp);
1375 }
1376 ASSERT(objp->flags & OF_POLYGON_OBJECT);
1377 ASSERT(objp->rtype.pobj_info.subobj_flags == 0xFFFFFFFF);
1378 // Create fireballs
1379 int fireball_visnum = -1;
1380 if (death_flags & DF_FIREBALL) {
1381 // Determine size of explosion
1382 float size_scale;
1383 switch (DEATH_EXPL_SIZE(death_flags)) {
1384 case DF_EXPL_SMALL:
1385 size_scale = 0.5f;
1386 break;
1387 case DF_EXPL_MEDIUM:
1388 size_scale = 1.0f;
1389 break;
1390 case DF_EXPL_LARGE:
1391 size_scale = 1.6f;
1392 break;
1393 default:
1394 Int3();
1395 }
1396 // Create big fireball
1397 fireball_visnum = CreateObjectFireball(objp, size_scale);
1398 // Create extra fireballs
1399 CreateExtraFireballs(objp, size_scale);
1400 }
1401 // Switch to dying model
1402 if (objp->rtype.pobj_info.dying_model_num != -1)
1403 objp->rtype.pobj_info.model_num = objp->rtype.pobj_info.dying_model_num;
1404 // Create debris pieces
1405 if (death_flags & DF_BREAKS_APART)
1406 BreakApartModel(objp, explosion_mag, death_flags);
1407 // Create splinters. Base life of the life of the fireball created earlier

Callers 4

do_physics_simFunction · 0.85
bump_two_objectsFunction · 0.85
DoDyingFrameFunction · 0.85
KillObjectFunction · 0.85

Calls 13

CreateObjectBlastRingFunction · 0.85
AddToShakeMagnitudeFunction · 0.85
MakeShockwaveFunction · 0.85
PlayObjectExplosionSoundFunction · 0.85
DoDeathSpewFunction · 0.85
CreateObjectFireballFunction · 0.85
CreateExtraFireballsFunction · 0.85
BreakApartModelFunction · 0.85
CreateSplintersFromBodyFunction · 0.85
SetObjectControlTypeFunction · 0.85
CreateDeadObjectFunction · 0.85
SetObjectDeadFlagFunction · 0.85

Tested by

no test coverage detected