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

Function UPVEffects

TombEngine/Objects/TR3/Vehicles/upv.cpp:301–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

299 }
300
301 void UPVEffects(short itemNumber)
302 {
303 if (itemNumber == NO_VALUE)
304 return;
305
306 auto* UPVItem = &g_Level.Items[itemNumber];
307 auto* UPV = GetUPVInfo(UPVItem);
308 auto* laraItem = LaraItem.Get();
309 auto* lara = GetLaraInfo(laraItem);
310
311 if (lara->Context.Vehicle == itemNumber)
312 {
313 UPV->TurbineRotation += UPV->Velocity ? (UPV->Velocity / 8) : ANGLE(2.0f);
314 UPV->LeftRudderRotation = (UPV->TurnRate.x + UPV->TurnRate.y) * 8;
315 UPV->RightRudderRotation = (UPV->TurnRate.x + -UPV->TurnRate.y) * 8;
316
317 if (UPV->Velocity)
318 {
319 auto pos = GetJointPosition(UPVItem, UPVBites[UPV_BITE_TURBINE]).ToVector3();
320 TriggerUPVMist(pos.x, pos.y + UPV_SHIFT, pos.z, abs(UPV->Velocity) / VEHICLE_VELOCITY_SCALE, UPVItem->Pose.Orientation.y + ANGLE(180.0f));
321
322 auto sphere = BoundingSphere(pos, BLOCK(1 / 32.0f));
323 if (Random::TestProbability(1 / 2.0f))
324 {
325 auto bubblePos = Random::GeneratePointInSphere(sphere);
326 int probedRoomNumber = GetPointCollision(bubblePos, UPVItem->RoomNumber).GetRoomNumber();
327
328 for (int i = 0; i < 3; i++)
329 SpawnBubble(bubblePos, probedRoomNumber, (int)BubbleFlags::HighAmplitude);
330 }
331 }
332 }
333
334 for (int lp = 0; lp < 2; lp++)
335 {
336 int random = 31 - (GetRandomControl() & 3);
337 auto pos = GetJointPosition(UPVItem, UPVBites[UPV_BITE_FRONT_LIGHT].BoneID, Vector3i(
338 UPVBites[UPV_BITE_FRONT_LIGHT].Position.x,
339 UPVBites[UPV_BITE_FRONT_LIGHT].Position.y,
340 (int)UPVBites[UPV_BITE_FRONT_LIGHT].Position.z << (lp * 6)
341 ));
342
343 GameVector origin;
344 if (lp == 1)
345 {
346 auto target = GameVector(pos, UPVItem->RoomNumber);
347 LOS(&origin, &target);
348 pos = Vector3i(target.x, target.y, target.z);
349 }
350 else
351 origin = GameVector(pos, UPVItem->RoomNumber);
352
353 SpawnDynamicLight(pos.x, pos.y, pos.z, 16 + (lp << 3), random, random, random);
354 }
355
356 if (UPV->HarpoonTimer)
357 UPV->HarpoonTimer--;
358 }

Callers 1

UPVControlFunction · 0.85

Calls 15

GetUPVInfoFunction · 0.85
ANGLEFunction · 0.85
GetJointPositionFunction · 0.85
TriggerUPVMistFunction · 0.85
TestProbabilityFunction · 0.85
GeneratePointInSphereFunction · 0.85
GetPointCollisionFunction · 0.85
SpawnBubbleFunction · 0.85
GetRandomControlFunction · 0.85
LOSFunction · 0.85
SpawnDynamicLightFunction · 0.85
Vector3iClass · 0.50

Tested by

no test coverage detected