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

Function ShakePlayer

Descent3/damage.cpp:1437–1464  ·  view source on GitHub ↗

Shakes player by some random amount

Source from the content-addressed store, hash-verified

1435
1436// Shakes player by some random amount
1437void ShakePlayer() {
1438 if (Shake_magnitude > MAX_SHAKE_MAGNITUDE)
1439 Shake_magnitude = MAX_SHAKE_MAGNITUDE;
1440
1441 float mag = Shake_magnitude;
1442
1443 uint16_t pitch_adjust = ((ps_rand() % 5) - 2) * mag;
1444 uint16_t bank_adjust = ((ps_rand() % 5) - 2) * mag;
1445 uint16_t heading_adjust = ((ps_rand() % 5) - 2) * mag;
1446 matrix m, tempm;
1447
1448 Old_player_orient = Player_object->orient;
1449
1450 if (Shake_magnitude < .00001)
1451 return;
1452
1453 vm_AnglesToMatrix(&m, pitch_adjust, heading_adjust, bank_adjust);
1454
1455 DoForceForShake(Shake_magnitude);
1456 Shake_magnitude -= (Frametime * (MAX_SHAKE_MAGNITUDE / 3));
1457
1458 if (Shake_magnitude < 0)
1459 Shake_magnitude = 0.0;
1460
1461 tempm = m * Player_object->orient;
1462
1463 ObjSetOrient(Player_object, &tempm);
1464}
1465
1466// Restores the player orientation matrix after shaking
1467void UnshakePlayer() { ObjSetOrient(Player_object, &Old_player_orient); }

Callers 1

GameRenderFrameFunction · 0.85

Calls 4

ps_randFunction · 0.85
DoForceForShakeFunction · 0.85
ObjSetOrientFunction · 0.85
vm_AnglesToMatrixFunction · 0.50

Tested by

no test coverage detected