Responsible for damaging the car according to contact events from OnContact.
1484 {
1485
1487
1488 if (contactZonesCount == 0)
1489 return;
1490
1491
1492 for (int i = 0; i < contactZonesCount; ++i)
1493 {
1496
1499
1500 #ifdef DIAG_DEVELOPER
1501 CrashDebugData.m_CrashDataPoint = new CrashDebugData();
1502 CrashDebugData.m_CrashDataPoint.m_VehicleType =
GetDisplayName();
1503 CrashDebugData.m_CrashDataPoint.m_Damage = dmg;
1504 CrashDebugData.m_CrashDataPoint.m_Zone = zoneName;
1505 CrashDebugData.m_CrashDataPoint.m_MomentumCurr = GetMomentum();
1507 CrashDebugData.m_CrashDataPoint.m_MomentumDelta = data[0].impulse;
1508 CrashDebugData.m_CrashDataPoint.m_SpeedWorld =
GetVelocity(
this).
Length() * 3.6;
1509 CrashDebugData.m_CrashDataPoint.m_SpeedWorldPrev =
m_VelocityPrevTick.Length() * 3.6;
1511 CrashDebugData.m_CrashDataPoint.m_VelocityCur =
GetVelocity(
this);
1514 CrashDebugData.m_CrashDataPoint.m_Time =
g_Game.GetTime();
1515
1516
1517
1518 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_CONSIDERED)
1519 {
1520 Debug.Log(
"--------------------------------------------------");
1522 Debug.Log(
"DMG: " + dmg);
1523 Debug.Log(
"zoneName : "+ zoneName);
1524 Debug.Log(
"momentumCurr : "+ GetMomentum());
1526 Debug.Log(
"momentumDelta : "+ data[0].impulse);
1533 Debug.Log(
"g_Game.GetTime(): "+
g_Game.GetTime());
1534 Debug.Log(
"--------------------------------------------------");
1535 }
1536 #endif
1537 if ( dmg < GameConstants.CARS_CONTACT_DMG_MIN )
1538 continue;
1539
1540 int pddfFlags;
1541 #ifdef DIAG_DEVELOPER
1542 CrashDebugData.m_CrashData.Insert(CrashDebugData.m_CrashDataPoint);
1543 CrashDebugData.m_CrashDataPoint.m_Speedometer = GetSpeedometer();
1544
1545 #endif
1546 if (dmg < GameConstants.CARS_CONTACT_DMG_THRESHOLD)
1547 {
1548 #ifdef DIAG_DEVELOPER
1549 CrashDebugData.m_CrashDataPoint.m_DamageType = "Small";
1550 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1551 Debug.Log(
string.Format(
"[Vehiles:Damage]:: DMG %1 to the %2 zone is SMALL (threshold: %3), SPEEDOMETER: %4, TIME: %5", dmg, zoneName, GameConstants.CARS_CONTACT_DMG_MIN, GetSpeedometer(),
g_Game.GetTime() ));
1552 #endif
1555 }
1556 else
1557 {
1558 #ifdef DIAG_DEVELOPER
1559 CrashDebugData.m_CrashDataPoint.m_DamageType = "Big";
1560 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1561 Debug.Log(
string.Format(
"[Vehiles:Damage]:: DMG %1 to the %2 zone is BIG (threshold: %3), SPEED: %4, TIME: %5", dmg, zoneName, GameConstants.CARS_CONTACT_DMG_THRESHOLD, GetSpeedometer(),
g_Game.GetTime() ));
1562 #endif
1565 pddfFlags = 0;
1566 }
1567
1568 #ifdef DEVELOPER
1569 m_DebugContactDamageMessage += string.Format("%1: %2\n", zoneName, dmg);
1570 #endif
1571
1572 ProcessDirectDamage(
DamageType.CUSTOM, null, zoneName,
"EnviroDmg",
"0 0 0", dmg, pddfFlags);
1573
1574
1575
1577 if (targetEntity && targetEntity.IsTree())
1578 {
1579 SEffectManager.CreateParticleServer(targetEntity.GetPosition(), new TreeEffecterParameters("TreeEffecter", 1.0, 0.1));
1580 }
1581
1582 }
1583
1586
1588
1589 }
DamageType
exposed from C++ (do not change)
static string GetDisplayName(int liquid_type)
void UpdateHeadlightState()
vector m_VelocityPrevTick
void SynchCrashHeavySound(bool play)
void SynchCrashLightSound(bool play)
ref CarContactCache m_ContactCache
void DamageCrew(float dmg)
Responsible for damaging crew in a car crash.
override void UpdateLights(int new_gear=-1)
proto native float Length()
Returns length of vector (magnitude)
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
proto native float dBodyGetMass(notnull IEntity ent)