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

Function KayakControl

TombEngine/Objects/TR3/Vehicles/kayak.cpp:1066–1154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1064 }
1065
1066 bool KayakControl(ItemInfo* laraItem)
1067 {
1068 auto* lara = GetLaraInfo(laraItem);
1069 auto* kayakItem = &g_Level.Items[lara->Context.Vehicle];
1070 auto* kayak = GetKayakInfo(kayakItem);
1071
1072 lara->Control.Look.Mode = LookMode::Free;
1073
1074 int ofs = kayakItem->Animation.Velocity.y;
1075
1076 KayakUserInput(kayakItem, laraItem);
1077 KayakToBackground(kayakItem, laraItem);
1078 TestTriggers(kayakItem, false);
1079
1080 auto probe = GetPointCollision(*kayakItem);
1081 int water = GetPointCollision(kayakItem->Pose.Position, probe.GetRoomNumber()).GetWaterTopHeight();
1082 kayak->WaterHeight = water;
1083
1084 if (kayak->WaterHeight == NO_HEIGHT)
1085 {
1086 water = probe.GetFloorHeight();
1087 kayak->WaterHeight = water;
1088 kayak->TrueWater = false;
1089 }
1090 else
1091 {
1092 kayak->WaterHeight -= 5;
1093 kayak->TrueWater = true;
1094 }
1095
1096 if ((ofs - kayakItem->Animation.Velocity.y) > 128 &&
1097 kayakItem->Animation.Velocity.y == 0 &&
1098 water != NO_HEIGHT)
1099 {
1100 int damage = ofs - kayakItem->Animation.Velocity.y;
1101 if (damage > 160)
1102 DoDamage(laraItem, (damage - 160) * 8);
1103 }
1104
1105 if (lara->Context.Vehicle != NO_VALUE)
1106 {
1107 UpdateVehicleRoom(kayakItem, laraItem, probe.GetRoomNumber());
1108
1109 laraItem->Pose.Position = kayakItem->Pose.Position;
1110 laraItem->Pose.Orientation.x = kayakItem->Pose.Orientation.x;
1111 laraItem->Pose.Orientation.y = kayakItem->Pose.Orientation.y;
1112 laraItem->Pose.Orientation.z = kayakItem->Pose.Orientation.z / 2;
1113
1114 AnimateItem(laraItem);
1115 SyncItemAnimation(*kayakItem, *laraItem);
1116
1117 Camera.targetElevation = -ANGLE(30.0f);
1118 Camera.targetDistance = CLICK(8);
1119 }
1120
1121 if (kayak->TrueWater &&
1122 (kayakItem->Animation.Velocity.z != 0.0f || lara->Context.WaterCurrentPull != Vector3i::Zero))
1123 {

Callers 1

HandleLaraVehicleFunction · 0.85

Calls 15

GetKayakInfoFunction · 0.85
KayakUserInputFunction · 0.85
KayakToBackgroundFunction · 0.85
TestTriggersFunction · 0.85
GetPointCollisionFunction · 0.85
DoDamageFunction · 0.85
UpdateVehicleRoomFunction · 0.85
AnimateItemFunction · 0.85
SyncItemAnimationFunction · 0.85
ANGLEFunction · 0.85
SpawnVehicleWakeFunction · 0.85
GetRandomControlFunction · 0.85

Tested by

no test coverage detected