Responsible for damaging the car according to contact events from OnContact.
1354 {
1355
1357
1358 if (contactZonesCount == 0)
1359 return;
1360
1361
1362 for (int i = 0; i < contactZonesCount; ++i)
1363 {
1366
1369
1370 #ifdef DIAG_DEVELOPER
1371 CrashDebugData.m_CrashDataPoint = new CrashDebugData();
1372 CrashDebugData.m_CrashDataPoint.m_VehicleType =
GetDisplayName();
1373 CrashDebugData.m_CrashDataPoint.m_Damage = dmg;
1374 CrashDebugData.m_CrashDataPoint.m_Zone = zoneName;
1375 CrashDebugData.m_CrashDataPoint.m_MomentumCurr = GetMomentum();
1377 CrashDebugData.m_CrashDataPoint.m_MomentumDelta = data[0].impulse;
1378 CrashDebugData.m_CrashDataPoint.m_SpeedWorld =
GetVelocity(
this).
Length() * 3.6;
1379 CrashDebugData.m_CrashDataPoint.m_SpeedWorldPrev =
m_VelocityPrevTick.Length() * 3.6;
1381 CrashDebugData.m_CrashDataPoint.m_VelocityCur =
GetVelocity(
this);
1385
1386
1387
1388 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_CONSIDERED)
1389 {
1390 Debug.Log(
"--------------------------------------------------");
1392 Debug.Log(
"DMG: " + dmg);
1393 Debug.Log(
"zoneName : "+ zoneName);
1394 Debug.Log(
"momentumCurr : "+ GetMomentum());
1396 Debug.Log(
"momentumDelta : "+ data[0].impulse);
1404 Debug.Log(
"--------------------------------------------------");
1405 }
1406 #endif
1407 if ( dmg < GameConstants.CARS_CONTACT_DMG_MIN )
1408 continue;
1409
1410 int pddfFlags;
1411 #ifdef DIAG_DEVELOPER
1412 CrashDebugData.m_CrashData.Insert(CrashDebugData.m_CrashDataPoint);
1413 CrashDebugData.m_CrashDataPoint.m_Speedometer = GetSpeedometer();
1414
1415 #endif
1416 if (dmg < GameConstants.CARS_CONTACT_DMG_THRESHOLD)
1417 {
1418 #ifdef DIAG_DEVELOPER
1419 CrashDebugData.m_CrashDataPoint.m_DamageType = "Small";
1420 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1421 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(),
GetGame().
GetTime() ));
1422 #endif
1425 }
1426 else
1427 {
1428 #ifdef DIAG_DEVELOPER
1429 CrashDebugData.m_CrashDataPoint.m_DamageType = "Big";
1430 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1431 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(),
GetGame().
GetTime() ));
1432 #endif
1435 pddfFlags = 0;
1436 }
1437
1438 #ifdef DEVELOPER
1439 m_DebugContactDamageMessage += string.Format("%1: %2\n", zoneName, dmg);
1440 #endif
1441
1442 ProcessDirectDamage(
DamageType.CUSTOM, null, zoneName,
"EnviroDmg",
"0 0 0", dmg, pddfFlags);
1443
1444
1445
1447 if (targetEntity && targetEntity.IsTree())
1448 {
1449 SEffectManager.CreateParticleServer(targetEntity.GetPosition(), new TreeEffecterParameters("TreeEffecter", 1.0, 0.1));
1450 }
1451
1452 }
1453
1456
1458
1459 }
DamageType
exposed from C++ (do not change)
static string GetDisplayName(int liquid_type)
proto int GetTime()
returns mission time in milliseconds
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.
void UpdateLights(int new_gear=-1)
proto native float Length()
Returns length of vector (magnitude)
proto native CGame GetGame()
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
proto native float dBodyGetMass(notnull IEntity ent)