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

◆ EOnPostSimulate()

override void Car::EOnPostSimulate ( IEntity other,
float timeSlice )
inlineprotected

actions runned when the engine on

leaking of coolant from radiator when damaged

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

895 {
896 m_Time += timeSlice;
897
898 if (GetGame().IsServer())
899 {
900 #ifdef DIAG_DEVELOPER
901 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.CONTACT)
902 {
903 if (m_ContactCalled)
904 {
905 Debug.Log("Momentum delta: " + (GetMomentum() - m_MomentumPrevTick));
906 Debug.Log("--------------------------------------------------------------------");
907 m_ContactCalled = false;
908 }
909 }
910 #endif
911
912
915 m_MomentumPrevTick = GetMomentum();
916 #ifdef DEVELOPER
917 m_DebugMessageCleanTime += timeSlice;
918 if (m_DebugMessageCleanTime >= DEBUG_MESSAGE_CLEAN_TIME_SECONDS)
919 {
920 m_DebugMessageCleanTime = 0;
921 m_DebugContactDamageMessage = "";
922 }
923 #endif
924 }
925
926 if ( m_Time >= GameConstants.CARS_FLUIDS_TICK )
927 {
928 m_Time = 0;
929
931
932 bool isServerOrOwner = IsServerOrOwner();
933
934 //First of all check if the car should stop the engine
935 if (isServerOrOwner && EngineIsOn())
936 {
937 if (IsDamageDestroyed() || GetFluidFraction(CarFluid.FUEL) <= 0 || m_EngineHealth <= 0)
938 EngineStop();
939
940 //CheckVitalItem(IsVitalCarBattery(), CarBattery.SLOT_ID);
941 //CheckVitalItem(IsVitalTruckBattery(), TruckBattery.SLOT_ID);
942 CheckVitalItem(IsVitalSparkPlug(), "SparkPlug");
943 CheckVitalItem(IsVitalGlowPlug(), "GlowPlug");
944 }
945
946 if (GetGame().IsServer())
947 {
948 if (IsVitalFuelTank())
949 {
950 if (m_FuelTankHealth == GameConstants.DAMAGE_RUINED_VALUE && m_EngineHealth > GameConstants.DAMAGE_RUINED_VALUE)
951 {
952 SetHealth("Engine", "Health", GameConstants.DAMAGE_RUINED_VALUE);
953 }
954 }
955 }
956
958 if ( EngineIsOn() )
959 {
960 if ( GetGame().IsServer() )
961 {
962 float dmg;
963
964 if ( EngineGetRPM() >= EngineGetRPMRedline() )
965 {
966 if (EngineGetRPM() > EngineGetRPMMax())
967 AddHealth( "Engine", "Health", -GetMaxHealth("Engine", "") * 0.05 ); //CAR_RPM_DMG
968
969 // only called on server, don't use deterministic RandomFloat
970 dmg = EngineGetRPM() * 0.001 * Math.RandomFloat( 0.02, 1.0 ); //CARS_TICK_DMG_MIN; //CARS_TICK_DMG_MAX
971 ProcessDirectDamage(DamageType.CUSTOM, null, "Engine", "EnviroDmg", vector.Zero, dmg);
972 SetEngineZoneReceivedHit(true);
973 }
974 else
975 {
976 SetEngineZoneReceivedHit(false);
977 }
978 }
979
980 if (isServerOrOwner)
981 {
983 if ( IsVitalRadiator() )
984 {
985 if ( GetFluidFraction(CarFluid.COOLANT) > 0 && m_RadiatorHealth < 0.5 ) //CARS_LEAK_THRESHOLD
986 LeakFluid( CarFluid.COOLANT );
987 }
988
989 if ( GetFluidFraction(CarFluid.FUEL) > 0 && m_FuelTankHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
990 LeakFluid( CarFluid.FUEL );
991
992 if ( GetFluidFraction(CarFluid.BRAKE) > 0 && m_EngineHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
993 LeakFluid( CarFluid.BRAKE );
994
995 if ( GetFluidFraction(CarFluid.OIL) > 0 && m_EngineHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
996 LeakFluid( CarFluid.OIL );
997
998 if ( m_EngineHealth < 0.25 )
999 LeakFluid( CarFluid.OIL );
1000 }
1001
1002 if ( GetGame().IsServer() )
1003 {
1004 if ( IsVitalRadiator() )
1005 {
1006 if ( GetFluidFraction( CarFluid.COOLANT ) < 0.5 && GetFluidFraction( CarFluid.COOLANT ) >= 0 )
1007 {
1008 // only called on server, don't use deterministic RandomFloat
1009 dmg = ( 1 - GetFluidFraction(CarFluid.COOLANT) ) * Math.RandomFloat( 0.02, 10.00 ); //CARS_DMG_TICK_MIN_COOLANT; //CARS_DMG_TICK_MAX_COOLANT
1010 AddHealth( "Engine", "Health", -dmg );
1011 SetEngineZoneReceivedHit(true);
1012 }
1013 }
1014 }
1015
1016 //FX only on Client and in Single
1017 if (!GetGame().IsDedicatedServer())
1018 {
1019 if (!SEffectManager.IsEffectExist(m_exhaustPtcFx))
1020 {
1021 m_exhaustFx = new EffExhaustSmoke();
1022 m_exhaustPtcFx = SEffectManager.PlayOnObject( m_exhaustFx, this, m_exhaustPtcPos, m_exhaustPtcDir );
1023 m_exhaustFx.SetParticleStateLight();
1024 }
1025
1026 if (IsVitalRadiator() && GetFluidFraction(CarFluid.COOLANT) < 0.5)
1027 {
1028 if (!SEffectManager.IsEffectExist(m_coolantPtcFx))
1029 {
1030 m_coolantFx = new EffCoolantSteam();
1031 m_coolantPtcFx = SEffectManager.PlayOnObject(m_coolantFx, this, m_coolantPtcPos, vector.Zero);
1032 }
1033
1034 if (m_coolantFx)
1035 {
1036 if (GetFluidFraction(CarFluid.COOLANT) > 0)
1037 m_coolantFx.SetParticleStateLight();
1038 else
1039 m_coolantFx.SetParticleStateHeavy();
1040 }
1041 }
1042 else
1043 {
1044 if (SEffectManager.IsEffectExist(m_coolantPtcFx))
1045 SEffectManager.Stop(m_coolantPtcFx);
1046 }
1047 }
1048 }
1049 else
1050 {
1051 //FX only on Client and in Single
1052 if ( !GetGame().IsDedicatedServer() )
1053 {
1054 if (SEffectManager.IsEffectExist(m_exhaustPtcFx))
1055 {
1056 SEffectManager.Stop(m_exhaustPtcFx);
1057 m_exhaustPtcFx = -1;
1058 }
1059
1060 if (SEffectManager.IsEffectExist(m_coolantPtcFx))
1061 {
1062 SEffectManager.Stop(m_coolantPtcFx);
1063 m_coolantPtcFx = -1;
1064 }
1065 }
1066 }
1067
1068 }
1069
1070 //FX only on Client and in Single
1071 if ( !GetGame().IsDedicatedServer() )
1072 {
1073 float carSpeed = GetVelocity(this).Length();
1074 for (int i = 0; i < WheelCount(); i++)
1075 {
1076 EffWheelSmoke eff = m_WheelSmokeFx.Get(i);
1077 int ptrEff = m_WheelSmokePtcFx.Get(i);
1078 bool haveParticle = false;
1079
1080 CarWheel wheel = CarWheel.Cast(WheelGetEntity(i));
1081 if (wheel && WheelHasContact(i))
1082 {
1083 float wheelSpeed = WheelGetAngularVelocity(i) * wheel.GetRadius();
1084
1085 vector wheelPos = WheelGetContactPosition(i);
1086 vector wheelVel = dBodyGetVelocityAt(this, wheelPos);
1087
1088 vector transform[3];
1089 transform[2] = WheelGetDirection(i);
1090 transform[1] = vector.Up;
1091 transform[0] = transform[2] * transform[1];
1092
1093 wheelVel = wheelVel.InvMultiply3(transform);
1094
1095 float bodySpeed = wheelVel[2];
1096
1097 bool applyEffect = false;
1098 if ((wheelSpeed > 0 && bodySpeed > 0) || (wheelSpeed < 0 && bodySpeed < 0))
1099 {
1100 applyEffect = Math.AbsFloat(wheelSpeed) > Math.AbsFloat(bodySpeed) + EffWheelSmoke.WHEEL_SMOKE_THRESHOLD;
1101 }
1102 else
1103 {
1104 applyEffect = Math.AbsFloat(wheelSpeed) > EffWheelSmoke.WHEEL_SMOKE_THRESHOLD;
1105 }
1106
1107 if (applyEffect)
1108 {
1109 haveParticle = true;
1110
1111 string surface;
1112 GetGame().SurfaceGetType(wheelPos[0], wheelPos[2], surface);
1113 wheelPos = WorldToModel(wheelPos);
1114
1115 if (!SEffectManager.IsEffectExist(ptrEff))
1116 {
1117 eff = new EffWheelSmoke();
1118 eff.SetSurface(surface);
1119 ptrEff = SEffectManager.PlayOnObject(eff, this, wheelPos, "0 1 -1");
1120 eff.SetCurrentLocalPosition(wheelPos);
1121 m_WheelSmokeFx.Set(i, eff);
1122 m_WheelSmokePtcFx.Set(i, ptrEff);
1123 }
1124 else
1125 {
1126 if (!eff.IsPlaying() && Surface.GetWheelParticleID(surface) != 0)
1127 eff.Start();
1128 eff.SetSurface(surface);
1129 eff.SetCurrentLocalPosition(wheelPos);
1130 }
1131 }
1132 }
1133
1134 if (!haveParticle)
1135 {
1136 if (eff && eff.IsPlaying())
1137 eff.Stop();
1138 }
1139 }
1140 }
1141 }
CarFluid
Type of vehicle's fluid. (native, do not change or extend)
Определения Car.c:19
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
void Debug()
Определения UniversalTemperatureSource.c:349
proto float SurfaceGetType(float x, float z, out string type)
Returns: Y position the surface was found.
bool IsVitalGlowPlug()
Определения CarScript.c:2601
bool IsVitalRadiator()
Определения CarScript.c:2611
vector m_exhaustPtcDir
Определения CarScript.c:221
vector m_coolantPtcPos
Определения CarScript.c:223
void LeakFluid(CarFluid fluid)
Определения CarScript.c:2393
vector m_VelocityPrevTick
Определения CarScript.c:171
float m_MomentumPrevTick
Определения CarScript.c:170
ref EffVehicleSmoke m_coolantFx
Particles.
Определения CarScript.c:212
float m_Time
Определения CarScript.c:174
float m_EngineHealth
Определения CarScript.c:197
void CarPartsHealthCheck()
Определения CarScript.c:2416
vector m_exhaustPtcPos
Определения CarScript.c:220
void CheckContactCache()
Responsible for damaging the car according to contact events from OnContact.
Определения CarScript.c:1353
float m_RadiatorHealth
Определения CarScript.c:198
float m_FuelTankHealth
Определения CarScript.c:199
int m_exhaustPtcFx
Определения CarScript.c:218
ref EffVehicleSmoke m_exhaustFx
Определения CarScript.c:214
ref array< int > m_WheelSmokePtcFx
Определения CarScript.c:297
void CheckVitalItem(bool isVital, int slotId)
Определения CarScript.c:2371
int m_coolantPtcFx
Определения CarScript.c:217
ref array< ref EffWheelSmoke > m_WheelSmokeFx
Определения CarScript.c:296
bool IsVitalFuelTank()
Определения CarScript.c:2616
bool IsServerOrOwner()
Определения CarScript.c:3077
void SetSurface(string surface)
Определения WheelSmoke.c:9
override void Stop()
Stops all elements this effect consists of.
Определения EffectParticle.c:204
override void Start()
Plays all elements this effect consists of.
Определения EffectParticle.c:181
override void SetCurrentLocalPosition(vector pos, bool updateCached=true)
Set the current local position of the managed Particle.
Определения EffectParticle.c:411
proto native float Length()
Returns length of vector (magnitude)
proto vector InvMultiply3(vector mat[3])
Invert-transforms vector.
static const vector Up
Определения EnConvert.c:107
proto native CGame GetGame()
proto native vector dBodyGetVelocityAt(notnull IEntity body, vector globalpos)
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.

Перекрестные ссылки Math::AbsFloat(), CarPartsHealthCheck(), GameConstants::CARS_FLUIDS_TICK, CheckContactCache(), CheckVitalItem(), GameConstants::DAMAGE_DAMAGED_VALUE, GameConstants::DAMAGE_RUINED_VALUE, dBodyGetVelocityAt(), GetGame(), GetVelocity(), Surface::GetWheelParticleID(), vector::InvMultiply3(), SEffectManager::IsEffectExist(), IsServerOrOwner(), IsVitalFuelTank(), CarScript::IsVitalGlowPlug(), CarScript::IsVitalRadiator(), CarScript::IsVitalSparkPlug(), LeakFluid(), vector::Length(), Debug::Log(), m_coolantFx, m_coolantPtcFx, m_coolantPtcPos, m_EngineHealth, m_exhaustFx, m_exhaustPtcDir, m_exhaustPtcFx, m_exhaustPtcPos, m_FuelTankHealth, m_MomentumPrevTick, m_RadiatorHealth, m_Time, m_VelocityPrevTick, m_WheelSmokeFx, m_WheelSmokePtcFx, SEffectManager::PlayOnObject(), Math::RandomFloat(), EffectParticle::SetCurrentLocalPosition(), EffWheelSmoke::SetSurface(), EffectParticle::Start(), EffectParticle::Stop(), SEffectManager::Stop(), CGame::SurfaceGetType(), vector::Up, EffWheelSmoke::WHEEL_SMOKE_THRESHOLD и vector::Zero.