DayZ 1.29
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 строка 948

949 {
950 m_Time += timeSlice;
951
952 if (g_Game.IsServer())
953 {
954 #ifdef DIAG_DEVELOPER
955 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.CONTACT)
956 {
957 if (m_ContactCalled)
958 {
959 Debug.Log("Momentum delta: " + (GetMomentum() - m_MomentumPrevTick));
960 Debug.Log("--------------------------------------------------------------------");
961 m_ContactCalled = false;
962 }
963 }
964 #endif
965
966
969 m_MomentumPrevTick = GetMomentum();
970 #ifdef DEVELOPER
971 m_DebugMessageCleanTime += timeSlice;
972 if (m_DebugMessageCleanTime >= DEBUG_MESSAGE_CLEAN_TIME_SECONDS)
973 {
974 m_DebugMessageCleanTime = 0;
975 m_DebugContactDamageMessage = "";
976 }
977 #endif
978 }
979
980 if ( m_Time >= GameConstants.CARS_FLUIDS_TICK )
981 {
982 m_Time = 0;
983
985
986 bool isServerOrOwner = IsServerOrOwner();
987
988 //First of all check if the car should stop the engine
989 if (isServerOrOwner && EngineIsOn())
990 {
991 if (IsDamageDestroyed() || GetFluidFraction(CarFluid.FUEL) <= 0 || m_EngineHealth <= 0)
992 EngineStop();
993
994 //CheckVitalItem(IsVitalCarBattery(), CarBattery.SLOT_ID);
995 //CheckVitalItem(IsVitalTruckBattery(), TruckBattery.SLOT_ID);
996 CheckVitalItem(IsVitalSparkPlug(), "SparkPlug");
997 CheckVitalItem(IsVitalGlowPlug(), "GlowPlug");
998 }
999
1000 if (g_Game.IsServer())
1001 {
1002 if (IsVitalFuelTank())
1003 {
1004 if (m_FuelTankHealth == GameConstants.DAMAGE_RUINED_VALUE && m_EngineHealth > GameConstants.DAMAGE_RUINED_VALUE)
1005 {
1006 SetHealth("Engine", "Health", GameConstants.DAMAGE_RUINED_VALUE);
1007 }
1008 }
1009 }
1010
1012 if ( EngineIsOn() )
1013 {
1014 if ( g_Game.IsServer() )
1015 {
1016 float dmg;
1017
1018 if ( EngineGetRPM() >= EngineGetRPMRedline() )
1019 {
1020 if (EngineGetRPM() > EngineGetRPMMax())
1021 AddHealth( "Engine", "Health", -GetMaxHealth("Engine", "") * 0.05 ); //CAR_RPM_DMG
1022
1023 // only called on server, don't use deterministic RandomFloat
1024 dmg = EngineGetRPM() * 0.001 * Math.RandomFloat( 0.02, 1.0 ); //CARS_TICK_DMG_MIN; //CARS_TICK_DMG_MAX
1025 ProcessDirectDamage(DamageType.CUSTOM, null, "Engine", "EnviroDmg", vector.Zero, dmg);
1026 SetEngineZoneReceivedHit(true);
1027 }
1028 else
1029 {
1030 SetEngineZoneReceivedHit(false);
1031 }
1032 }
1033
1034 if (isServerOrOwner)
1035 {
1037 if ( IsVitalRadiator() )
1038 {
1039 if ( GetFluidFraction(CarFluid.COOLANT) > 0 && m_RadiatorHealth < 0.5 ) //CARS_LEAK_THRESHOLD
1040 LeakFluid( CarFluid.COOLANT );
1041 }
1042
1043 if ( GetFluidFraction(CarFluid.FUEL) > 0 && m_FuelTankHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
1044 LeakFluid( CarFluid.FUEL );
1045
1046 if ( GetFluidFraction(CarFluid.BRAKE) > 0 && m_EngineHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
1047 LeakFluid( CarFluid.BRAKE );
1048
1049 if ( GetFluidFraction(CarFluid.OIL) > 0 && m_EngineHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
1050 LeakFluid( CarFluid.OIL );
1051
1052 if ( m_EngineHealth < 0.25 )
1053 LeakFluid( CarFluid.OIL );
1054 }
1055
1056 if ( g_Game.IsServer() )
1057 {
1058 if ( IsVitalRadiator() )
1059 {
1060 if ( GetFluidFraction( CarFluid.COOLANT ) < 0.5 && GetFluidFraction( CarFluid.COOLANT ) >= 0 )
1061 {
1062 // only called on server, don't use deterministic RandomFloat
1063 dmg = ( 1 - GetFluidFraction(CarFluid.COOLANT) ) * Math.RandomFloat( 0.02, 10.00 ); //CARS_DMG_TICK_MIN_COOLANT; //CARS_DMG_TICK_MAX_COOLANT
1064 AddHealth( "Engine", "Health", -dmg );
1065 SetEngineZoneReceivedHit(true);
1066 }
1067 }
1068 }
1069
1070 //FX only on Client and in Single
1071 if (!g_Game.IsDedicatedServer())
1072 {
1073 if (!SEffectManager.IsEffectExist(m_exhaustPtcFx))
1074 {
1075 m_exhaustFx = new EffExhaustSmoke();
1076 m_exhaustPtcFx = SEffectManager.PlayOnObject( m_exhaustFx, this, m_exhaustPtcPos, m_exhaustPtcDir );
1077 m_exhaustFx.SetParticleStateLight();
1078 }
1079
1080 if (IsVitalRadiator() && GetFluidFraction(CarFluid.COOLANT) < 0.5)
1081 {
1082 if (!SEffectManager.IsEffectExist(m_coolantPtcFx))
1083 {
1084 m_coolantFx = new EffCoolantSteam();
1085 m_coolantPtcFx = SEffectManager.PlayOnObject(m_coolantFx, this, m_coolantPtcPos, vector.Zero);
1086 }
1087
1088 if (m_coolantFx)
1089 {
1090 if (GetFluidFraction(CarFluid.COOLANT) > 0)
1091 m_coolantFx.SetParticleStateLight();
1092 else
1093 m_coolantFx.SetParticleStateHeavy();
1094 }
1095 }
1096 else
1097 {
1098 if (SEffectManager.IsEffectExist(m_coolantPtcFx))
1099 SEffectManager.Stop(m_coolantPtcFx);
1100 }
1101 }
1102 }
1103 else
1104 {
1105 //FX only on Client and in Single
1106 if ( !g_Game.IsDedicatedServer() )
1107 {
1108 if (SEffectManager.IsEffectExist(m_exhaustPtcFx))
1109 {
1110 SEffectManager.Stop(m_exhaustPtcFx);
1111 m_exhaustPtcFx = -1;
1112 }
1113
1114 if (SEffectManager.IsEffectExist(m_coolantPtcFx))
1115 {
1116 SEffectManager.Stop(m_coolantPtcFx);
1117 m_coolantPtcFx = -1;
1118 }
1119 }
1120 }
1121
1122 }
1123
1124 //FX only on Client and in Single
1125 if ( !g_Game.IsDedicatedServer() )
1126 {
1127 float carSpeed = GetVelocity(this).Length();
1128 for (int i = 0; i < WheelCount(); i++)
1129 {
1130 EffWheelSmoke eff = m_WheelSmokeFx.Get(i);
1131 int ptrEff = m_WheelSmokePtcFx.Get(i);
1132 bool haveParticle = false;
1133
1134 CarWheel wheel = CarWheel.Cast(WheelGetEntity(i));
1135 if (wheel && WheelHasContact(i))
1136 {
1137 float wheelSpeed = WheelGetAngularVelocity(i) * wheel.GetRadius();
1138
1139 vector wheelPos = WheelGetContactPosition(i);
1140 vector wheelVel = dBodyGetVelocityAt(this, wheelPos);
1141
1142 vector transform[3];
1143 transform[2] = WheelGetDirection(i);
1144 transform[1] = vector.Up;
1145 transform[0] = transform[2] * transform[1];
1146
1147 wheelVel = wheelVel.InvMultiply3(transform);
1148
1149 float bodySpeed = wheelVel[2];
1150
1151 bool applyEffect = false;
1152 if ((wheelSpeed > 0 && bodySpeed > 0) || (wheelSpeed < 0 && bodySpeed < 0))
1153 {
1154 applyEffect = Math.AbsFloat(wheelSpeed) > Math.AbsFloat(bodySpeed) + EffWheelSmoke.WHEEL_SMOKE_THRESHOLD;
1155 }
1156 else
1157 {
1158 applyEffect = Math.AbsFloat(wheelSpeed) > EffWheelSmoke.WHEEL_SMOKE_THRESHOLD;
1159 }
1160
1161 if (applyEffect)
1162 {
1163 haveParticle = true;
1164
1165 string surface;
1166 g_Game.SurfaceGetType(wheelPos[0], wheelPos[2], surface);
1167 wheelPos = WorldToModel(wheelPos);
1168
1169 if (!SEffectManager.IsEffectExist(ptrEff))
1170 {
1171 eff = new EffWheelSmoke();
1172 eff.SetSurface(surface);
1173 ptrEff = SEffectManager.PlayOnObject(eff, this, wheelPos, "0 1 -1");
1174 eff.SetCurrentLocalPosition(wheelPos);
1175 m_WheelSmokeFx.Set(i, eff);
1176 m_WheelSmokePtcFx.Set(i, ptrEff);
1177 }
1178 else
1179 {
1180 if (!eff.IsPlaying() && Surface.GetWheelParticleID(surface) != 0)
1181 eff.Start();
1182 eff.SetSurface(surface);
1183 eff.SetCurrentLocalPosition(wheelPos);
1184 }
1185 }
1186 }
1187
1188 if (!haveParticle)
1189 {
1190 if (eff && eff.IsPlaying())
1191 eff.Stop();
1192 }
1193 }
1194 }
1195 }
string Debug()
Определения CachedEquipmentStorageBase.c:29
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
DayZGame g_Game
Определения DayZGame.c:3942
bool IsVitalGlowPlug()
Определения CarScript.c:2744
bool IsVitalRadiator()
Определения CarScript.c:2754
vector m_exhaustPtcDir
Определения CarScript.c:230
vector m_coolantPtcPos
Определения CarScript.c:232
void LeakFluid(CarFluid fluid)
Определения CarScript.c:2536
vector m_VelocityPrevTick
Определения CarScript.c:180
float m_MomentumPrevTick
Определения CarScript.c:179
ref EffVehicleSmoke m_coolantFx
Particles.
Определения CarScript.c:221
float m_Time
Определения CarScript.c:183
float m_EngineHealth
Определения CarScript.c:206
void CarPartsHealthCheck()
Определения CarScript.c:2559
vector m_exhaustPtcPos
Определения CarScript.c:229
void CheckContactCache()
Responsible for damaging the car according to contact events from OnContact.
Определения CarScript.c:1483
float m_RadiatorHealth
Определения CarScript.c:207
float m_FuelTankHealth
Определения CarScript.c:208
int m_exhaustPtcFx
Определения CarScript.c:227
ref EffVehicleSmoke m_exhaustFx
Определения CarScript.c:223
ref array< int > m_WheelSmokePtcFx
Определения CarScript.c:304
void CheckVitalItem(bool isVital, int slotId)
Определения CarScript.c:2513
int m_coolantPtcFx
Определения CarScript.c:226
ref array< ref EffWheelSmoke > m_WheelSmokeFx
Определения CarScript.c:303
bool IsVitalFuelTank()
Определения CarScript.c:2759
bool IsServerOrOwner()
Определения CarScript.c:3222
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:120
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(), g_Game, 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(), vector::Up, EffWheelSmoke::WHEEL_SMOKE_THRESHOLD и vector::Zero.