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

Function JeepDynamics

TombEngine/Objects/TR4/Vehicles/jeep.cpp:494–726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

492 }
493
494 int JeepDynamics(ItemInfo* jeepItem, ItemInfo* laraItem)
495 {
496 auto* jeep = GetJeepInfo(jeepItem);
497 auto* lara = GetLaraInfo(laraItem);
498
499 Vector3i f_old, b_old, mm_old, mt_old, mb_old;
500
501 int hf_old = GetVehicleHeight(jeepItem, JEEP_FRONT, -JEEP_SIDE, true, &f_old);
502 int hb_old = GetVehicleHeight(jeepItem, JEEP_FRONT, JEEP_SIDE, true, &b_old);
503 int hmm_old = GetVehicleHeight(jeepItem, -(JEEP_FRONT + 50), -JEEP_SIDE, true, &mm_old);
504 int hmt_old = GetVehicleHeight(jeepItem, -(JEEP_FRONT + 50), JEEP_SIDE, true, &mt_old);
505 int hmb_old = GetVehicleHeight(jeepItem, -(JEEP_FRONT + 50), 0, true, &mb_old);
506
507 auto oldPos = jeepItem->Pose.Position;
508
509 if (f_old.y > hf_old)
510 f_old.y = hf_old;
511
512 if (b_old.y > hb_old)
513 b_old.y = hb_old;
514
515 if (mm_old.y > hmm_old)
516 mm_old.y = hmm_old;
517
518 if (mt_old.y > hmt_old)
519 mt_old.y = hmt_old;
520
521 if (mb_old.y > hmb_old)
522 mb_old.y = hmb_old;
523
524 short rot = 0;
525 JeepNoGetOff = 0;
526
527 if (oldPos.y <= jeepItem->Floor - 8)
528 {
529 if (jeep->TurnRate < -JEEP_TURN_RATE_DECEL)
530 jeep->TurnRate += JEEP_TURN_RATE_DECEL;
531 else if (jeep->TurnRate > JEEP_TURN_RATE_DECEL)
532 jeep->TurnRate -= JEEP_TURN_RATE_DECEL;
533 else
534 jeep->TurnRate = 0;
535
536 jeepItem->Pose.Orientation.y += (short)(jeep->TurnRate + jeep->ExtraRotation);
537 jeep->MomentumAngle += ((short)(jeepItem->Pose.Orientation.y - jeep->MomentumAngle) / 32);
538 }
539 else
540 {
541 if (jeep->TurnRate < -ANGLE(1))
542 jeep->TurnRate += ANGLE(1);
543 else if (jeep->TurnRate > ANGLE(1))
544 jeep->TurnRate -= ANGLE(1);
545 else
546 jeep->TurnRate = 0;
547
548 jeepItem->Pose.Orientation.y += jeep->TurnRate + jeep->ExtraRotation;
549
550 rot = jeepItem->Pose.Orientation.y - jeep->MomentumAngle;
551 short momentum = (short)(728 - ((3 * jeep->Velocity) / 2048));

Callers 1

JeepControlFunction · 0.85

Calls 13

GetJeepInfoFunction · 0.85
GetVehicleHeightFunction · 0.85
ANGLEFunction · 0.85
IsHeldFunction · 0.85
GetRandomControlFunction · 0.85
GetFloorFunction · 0.85
GetFloorHeightFunction · 0.85
phd_cosFunction · 0.85
phd_sinFunction · 0.85
DoVehicleCollisionFunction · 0.85
DoJeepShiftFunction · 0.85

Tested by

no test coverage detected