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

◆ CheckContactCache()

void Car::CheckContactCache ( )
inlineprotected

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

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

1484 {
1485
1486 int contactZonesCount = m_ContactCache.Count();
1487
1488 if (contactZonesCount == 0)
1489 return;
1490
1491
1492 for (int i = 0; i < contactZonesCount; ++i)
1493 {
1494 string zoneName = m_ContactCache.GetKey(i);
1495 array<ref CarContactData> data = m_ContactCache[zoneName];
1496
1497 float dmg = Math.AbsInt(data[0].impulse * m_dmgContactCoef);
1498 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
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();
1506 CrashDebugData.m_CrashDataPoint.m_MomentumPrev = m_MomentumPrevTick;
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;
1510 CrashDebugData.m_CrashDataPoint.m_SpeedWorldDelta = (m_VelocityPrevTick.Length() - GetVelocity(this).Length()) * 3.6;
1511 CrashDebugData.m_CrashDataPoint.m_VelocityCur = GetVelocity(this);
1512 CrashDebugData.m_CrashDataPoint.m_VelocityPrev = m_VelocityPrevTick;
1513 CrashDebugData.m_CrashDataPoint.m_VelocityDot = vector.Dot(m_VelocityPrevTick.Normalized(), GetVelocity(this).Normalized());
1514 CrashDebugData.m_CrashDataPoint.m_Time = g_Game.GetTime();
1515
1516
1517
1518 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_CONSIDERED)
1519 {
1520 Debug.Log("--------------------------------------------------");
1521 Debug.Log("Vehicle:" + GetDisplayName());
1522 Debug.Log("DMG: " + dmg);
1523 Debug.Log("zoneName : "+ zoneName);
1524 Debug.Log("momentumCurr : "+ GetMomentum());
1525 Debug.Log("momentumPrev : "+ m_MomentumPrevTick);
1526 Debug.Log("momentumDelta : "+ data[0].impulse);
1527 Debug.Log("speed(km/h): "+ GetVelocity(this).Length() * 3.6);
1528 Debug.Log("speedPrev(km/h): "+ m_VelocityPrevTick.Length() * 3.6);
1529 Debug.Log("speedDelta(km/h) : "+ (m_VelocityPrevTick.Length() - GetVelocity(this).Length()) * 3.6);
1530 Debug.Log("velocityCur.): "+ GetVelocity(this));
1531 Debug.Log("velocityPrev.): "+ m_VelocityPrevTick);
1532 Debug.Log("velocityDot): "+ vector.Dot(m_VelocityPrevTick.Normalized(), GetVelocity(this).Normalized()));
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 //Print("Crash data recorded");
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
1554 pddfFlags = ProcessDirectDamageFlags.NO_TRANSFER;
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
1563 DamageCrew(crewDmgBase);
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 //if (data[0].impulse > TRESHOLD)
1575 //{
1576 Object targetEntity = Object.Cast(data[0].other);
1577 if (targetEntity && targetEntity.IsTree())
1578 {
1579 SEffectManager.CreateParticleServer(targetEntity.GetPosition(), new TreeEffecterParameters("TreeEffecter", 1.0, 0.1));
1580 }
1581 //}
1582 }
1583
1585 UpdateLights();
1586
1587 m_ContactCache.Clear();
1588
1589 }
string Debug()
Определения CachedEquipmentStorageBase.c:29
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:3942
static string GetDisplayName(int liquid_type)
Определения Liquid.c:382
ProcessDirectDamageFlags
Определения Object.c:2
float m_dmgContactCoef
Определения CarScript.c:198
void UpdateHeadlightState()
Определения CarScript.c:792
vector m_VelocityPrevTick
Определения CarScript.c:180
float m_MomentumPrevTick
Определения CarScript.c:179
void SynchCrashHeavySound(bool play)
Определения CarScript.c:2603
void SynchCrashLightSound(bool play)
Определения CarScript.c:2584
ref CarContactCache m_ContactCache
Определения CarScript.c:181
void DamageCrew(float dmg)
Responsible for damaging crew in a car crash.
Определения CarScript.c:1592
override void UpdateLights(int new_gear=-1)
Определения CarScript.c:2095
proto native float Length()
Returns length of vector (magnitude)
class LOD Object
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(), g_Game, GetDisplayName(), GetVelocity(), vector::Length(), Debug::Log(), m_ContactCache, m_dmgContactCoef, m_MomentumPrevTick, m_VelocityPrevTick, SynchCrashHeavySound(), SynchCrashLightSound(), UpdateHeadlightState() и UpdateLights().

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