DayZ 1.28
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ CheckContactCache()

void Car::CheckContactCache ( )
inlineprotected

Responsible for damaging the car according to contact events from OnContact.

См. определение в файле CarScript.c строка 1353

1354 {
1355
1356 int contactZonesCount = m_ContactCache.Count();
1357
1358 if (contactZonesCount == 0)
1359 return;
1360
1361
1362 for (int i = 0; i < contactZonesCount; ++i)
1363 {
1364 string zoneName = m_ContactCache.GetKey(i);
1365 array<ref CarContactData> data = m_ContactCache[zoneName];
1366
1367 float dmg = Math.AbsInt(data[0].impulse * m_dmgContactCoef);
1368 float crewDmgBase = Math.AbsInt((data[0].impulse / dBodyGetMass(this)) * 1000 * m_dmgContactCoef);// calculates damage as if the object's weight was 1000kg instead of its actual weight
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();
1376 CrashDebugData.m_CrashDataPoint.m_MomentumPrev = m_MomentumPrevTick;
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;
1380 CrashDebugData.m_CrashDataPoint.m_SpeedWorldDelta = (m_VelocityPrevTick.Length() - GetVelocity(this).Length()) * 3.6;
1381 CrashDebugData.m_CrashDataPoint.m_VelocityCur = GetVelocity(this);
1382 CrashDebugData.m_CrashDataPoint.m_VelocityPrev = m_VelocityPrevTick;
1383 CrashDebugData.m_CrashDataPoint.m_VelocityDot = vector.Dot(m_VelocityPrevTick.Normalized(), GetVelocity(this).Normalized());
1384 CrashDebugData.m_CrashDataPoint.m_Time = GetGame().GetTime();
1385
1386
1387
1388 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_CONSIDERED)
1389 {
1390 Debug.Log("--------------------------------------------------");
1391 Debug.Log("Vehicle:" + GetDisplayName());
1392 Debug.Log("DMG: " + dmg);
1393 Debug.Log("zoneName : "+ zoneName);
1394 Debug.Log("momentumCurr : "+ GetMomentum());
1395 Debug.Log("momentumPrev : "+ m_MomentumPrevTick);
1396 Debug.Log("momentumDelta : "+ data[0].impulse);
1397 Debug.Log("speed(km/h): "+ GetVelocity(this).Length() * 3.6);
1398 Debug.Log("speedPrev(km/h): "+ m_VelocityPrevTick.Length() * 3.6);
1399 Debug.Log("speedDelta(km/h) : "+ (m_VelocityPrevTick.Length() - GetVelocity(this).Length()) * 3.6);
1400 Debug.Log("velocityCur.): "+ GetVelocity(this));
1401 Debug.Log("velocityPrev.): "+ m_VelocityPrevTick);
1402 Debug.Log("velocityDot): "+ vector.Dot(m_VelocityPrevTick.Normalized(), GetVelocity(this).Normalized()));
1403 Debug.Log("GetGame().GetTime(): "+ GetGame().GetTime());
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 //Print("Crash data recorded");
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
1424 pddfFlags = ProcessDirectDamageFlags.NO_TRANSFER;
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
1433 DamageCrew(crewDmgBase);
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 //if (data[0].impulse > TRESHOLD)
1445 //{
1446 Object targetEntity = Object.Cast(data[0].other);
1447 if (targetEntity && targetEntity.IsTree())
1448 {
1449 SEffectManager.CreateParticleServer(targetEntity.GetPosition(), new TreeEffecterParameters("TreeEffecter", 1.0, 0.1));
1450 }
1451 //}
1452 }
1453
1455 UpdateLights();
1456
1457 m_ContactCache.Clear();
1458
1459 }
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
static string GetDisplayName(int liquid_type)
Определения Liquid.c:381
float GetTime()
Определения NotificationSystem.c:35
ProcessDirectDamageFlags
Определения Object.c:2
void Debug()
Определения UniversalTemperatureSource.c:349
proto int GetTime()
returns mission time in milliseconds
float m_dmgContactCoef
Определения CarScript.c:189
void UpdateHeadlightState()
Определения CarScript.c:738
vector m_VelocityPrevTick
Определения CarScript.c:171
float m_MomentumPrevTick
Определения CarScript.c:170
void SynchCrashHeavySound(bool play)
Определения CarScript.c:2460
void SynchCrashLightSound(bool play)
Определения CarScript.c:2441
ref CarContactCache m_ContactCache
Определения CarScript.c:172
void DamageCrew(float dmg)
Responsible for damaging crew in a car crash.
Определения CarScript.c:1462
void UpdateLights(int new_gear=-1)
Определения CarScript.c:1953
proto native float Length()
Returns length of vector (magnitude)
class LOD Object
proto native CGame GetGame()
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
proto native float dBodyGetMass(notnull IEntity ent)

Перекрестные ссылки Math::AbsInt(), GameConstants::CARS_CONTACT_DMG_MIN, GameConstants::CARS_CONTACT_DMG_THRESHOLD, SEffectManager::CreateParticleServer(), DamageCrew(), dBodyGetMass(), vector::Dot(), string::Format(), GetDisplayName(), GetGame(), CGame::GetTime(), GetTime(), GetVelocity(), vector::Length(), Debug::Log(), m_ContactCache, m_dmgContactCoef, m_MomentumPrevTick, m_VelocityPrevTick, SynchCrashHeavySound(), SynchCrashLightSound(), UpdateHeadlightState() и UpdateLights().

Используется в EOnPostSimulate().