1253 {
1254 int contactZonesCount = m_ContactCache.Count();
1255 if (contactZonesCount == 0)
1256 return;
1257
1258 for (int i = 0; i < contactZonesCount; ++i)
1259 {
1260 string zoneName = m_ContactCache.GetKey(i);
1262
1263 float dmg =
Math.
AbsInt(data[0].m_Impulse * m_VehicleContactDamageCoef);
1264 float crewDmgBase =
Math.
AbsInt((data[0].m_Impulse /
dBodyGetMass(
this)) * 500 * m_CrewContactDamageCoef);
1265
1266 #ifdef DIAG_DEVELOPER
1267 CrashDebugData.m_CrashDataPoint = new CrashDebugData();
1268 CrashDebugData.m_CrashDataPoint.m_VehicleType =
GetDisplayName();
1269 CrashDebugData.m_CrashDataPoint.m_Damage = dmg;
1270 CrashDebugData.m_CrashDataPoint.m_Zone = zoneName;
1271 CrashDebugData.m_CrashDataPoint.m_MomentumCurr = GetMomentum();
1272 CrashDebugData.m_CrashDataPoint.m_MomentumPrev = m_MomentumPrevTick;
1273 CrashDebugData.m_CrashDataPoint.m_MomentumDelta = data[0].m_Impulse;
1274 CrashDebugData.m_CrashDataPoint.m_SpeedWorld =
GetVelocity(
this).
Length() * 3.6;
1275 CrashDebugData.m_CrashDataPoint.m_SpeedWorldPrev = m_VelocityPrevTick.Length() * 3.6;
1276 CrashDebugData.m_CrashDataPoint.m_SpeedWorldDelta = (m_VelocityPrevTick.Length() -
GetVelocity(
this).Length()) * 3.6;
1277 CrashDebugData.m_CrashDataPoint.m_VelocityCur =
GetVelocity(
this);
1278 CrashDebugData.m_CrashDataPoint.m_VelocityPrev = m_VelocityPrevTick;
1279 CrashDebugData.m_CrashDataPoint.m_VelocityDot =
vector.
Dot(m_VelocityPrevTick.Normalized(),
GetVelocity(
this).Normalized());
1280 CrashDebugData.m_CrashDataPoint.m_Time =
g_Game.GetTime();
1281
1282 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_CONSIDERED)
1283 {
1284 Debug.
Log(
"--------------------------------------------------");
1287 Debug.
Log(
"zoneName : "+ zoneName);
1288 Debug.
Log(
"momentumCurr : "+ GetMomentum());
1289 Debug.
Log(
"momentumPrev : "+ m_MomentumPrevTick);
1290 Debug.
Log(
"momentumDelta : "+ data[0].m_Impulse);
1292 Debug.
Log(
"speedPrev(km/h): "+ m_VelocityPrevTick.Length() * 3.6);
1293 Debug.
Log(
"speedDelta(km/h) : "+ (m_VelocityPrevTick.Length() -
GetVelocity(
this).Length()) * 3.6);
1295 Debug.
Log(
"velocityPrev.): "+ m_VelocityPrevTick);
1298 Debug.
Log(
"--------------------------------------------------");
1299 }
1300 #endif
1302 continue;
1303
1304 int pddfFlags;
1305 #ifdef DIAG_DEVELOPER
1306 CrashDebugData.m_CrashData.Insert(CrashDebugData.m_CrashDataPoint);
1307 CrashDebugData.m_CrashDataPoint.m_Speedometer =
GetSpeedometer();
1308
1309 #endif
1311 {
1312 #ifdef DIAG_DEVELOPER
1313 CrashDebugData.m_CrashDataPoint.m_DamageType = "Small";
1314 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1316 #endif
1317
1318 SynchCrashLightSound(true);
1320 }
1322 {
1323 #ifdef DIAG_DEVELOPER
1324 CrashDebugData.m_CrashDataPoint.m_DamageType = "Medium";
1325 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1327 #endif
1328
1330 SynchCrashLightSound(true);
1331 }
1332 else
1333 {
1334 #ifdef DIAG_DEVELOPER
1335 CrashDebugData.m_CrashDataPoint.m_DamageType = "Big";
1336 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1338 #endif
1339
1342 SynchCrashHeavySound(true);
1343 pddfFlags = 0;
1344 }
1345
1346 #ifdef DEVELOPER
1347 m_DebugContactDamageMessage += string.Format("%1: %2\n", zoneName, dmg);
1348 #endif
1349
1350 ProcessDirectDamage(
DamageType.CUSTOM, null, zoneName,
"EnviroDmg",
"0 0 0", dmg, pddfFlags);
1351 }
1352
1355
1356 m_ContactCache.Clear();
1357 }
DamageType
exposed from C++ (do not change)
static string GetDisplayName(int liquid_type)
float GetSpeedometer()
Returns the current speed of the vehicle in km/h.
proto native bool FallOver()
Forcibly topple over the motorbike, ejects the player.
override void UpdateLights(int new_gear=-1)
void DamageCrew(float dmg)
Responsible for damaging crew in a car crash.
void UpdateHeadlightState()
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native float Length()
Returns length of vector (magnitude)
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
static proto int AbsInt(int i)
Returns absolute value.
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
proto native float dBodyGetMass(notnull IEntity ent)