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

◆ EOnPostSimulate()

override void EOnPostSimulate ( IEntity other,
float timeSlice )
protected

actions runned when the engine on

leaking of coolant from radiator when damaged

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

863 {
864 m_Time += timeSlice;
865
866 if (GetGame().IsServer())
867 {
870
871 #ifdef DIAG_DEVELOPER
872 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.CONTACT)
873 {
874 if (m_ContactCalled)
875 {
876 Debug.Log("Momentum delta: " + (GetMomentum() - m_MomentumPrevTick));
877 Debug.Log("--------------------------------------------------------------------");
878 m_ContactCalled = false;
879 }
880 }
881 #endif
882
883
886 m_MomentumPrevTick = GetMomentum();
887 #ifdef DEVELOPER
888 m_DebugMessageCleanTime += timeSlice;
889 if (m_DebugMessageCleanTime >= DEBUG_MESSAGE_CLEAN_TIME_SECONDS)
890 {
891 m_DebugMessageCleanTime = 0;
892 m_DebugContactDamageMessage = "";
893 }
894 #endif
895 }
896
898 {
899 m_Time = 0;
900
902
903 //First of all check if the car should stop the engine
904 if (GetGame().IsServer() && EngineIsOn())
905 {
906 if ( GetFluidFraction(CarFluid.FUEL) <= 0 || m_EngineHealth <= 0 )
907 EngineStop();
908
909 CheckVitalItem(IsVitalCarBattery(), "CarBattery");
910 CheckVitalItem(IsVitalTruckBattery(), "TruckBattery");
911 CheckVitalItem(IsVitalSparkPlug(), "SparkPlug");
912 CheckVitalItem(IsVitalGlowPlug(), "GlowPlug");
913 }
914
915 if (GetGame().IsServer())
916 {
917 if (IsVitalFuelTank())
918 {
920 {
921 SetHealth("Engine", "Health", GameConstants.DAMAGE_RUINED_VALUE);
922 }
923 }
924 }
925
927 if ( EngineIsOn() )
928 {
929 if ( GetGame().IsServer() )
930 {
931 float dmg;
932
933 if ( EngineGetRPM() >= EngineGetRPMRedline() )
934 {
935 if (EngineGetRPM() > EngineGetRPMMax())
936 AddHealth( "Engine", "Health", -GetMaxHealth("Engine", "") * 0.05 ); //CAR_RPM_DMG
937
938 dmg = EngineGetRPM() * 0.001 * Math.RandomFloat( 0.02, 1.0 ); //CARS_TICK_DMG_MIN; //CARS_TICK_DMG_MAX
939 ProcessDirectDamage(DamageType.CUSTOM, null, "Engine", "EnviroDmg", vector.Zero, dmg);
940 SetEngineZoneReceivedHit(true);
941 }
942 else
943 {
944 SetEngineZoneReceivedHit(false);
945 }
946
948 if ( IsVitalRadiator() )
949 {
950 if ( GetFluidFraction(CarFluid.COOLANT) > 0 && m_RadiatorHealth < 0.5 ) //CARS_LEAK_THRESHOLD
951 LeakFluid( CarFluid.COOLANT );
952 }
953
954 if ( GetFluidFraction(CarFluid.FUEL) > 0 && m_FuelTankHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
955 LeakFluid( CarFluid.FUEL );
956
957 if ( GetFluidFraction(CarFluid.BRAKE) > 0 && m_EngineHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
958 LeakFluid( CarFluid.BRAKE );
959
960 if ( GetFluidFraction(CarFluid.OIL) > 0 && m_EngineHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
961 LeakFluid( CarFluid.OIL );
962
963 if ( m_EngineHealth < 0.25 )
964 LeakFluid( CarFluid.OIL );
965
966 if ( IsVitalRadiator() )
967 {
968 if ( GetFluidFraction( CarFluid.COOLANT ) < 0.5 && GetFluidFraction( CarFluid.COOLANT ) >= 0 )
969 {
970 dmg = ( 1 - GetFluidFraction(CarFluid.COOLANT) ) * Math.RandomFloat( 0.02, 10.00 ); //CARS_DMG_TICK_MIN_COOLANT; //CARS_DMG_TICK_MAX_COOLANT
971 AddHealth( "Engine", "Health", -dmg );
972 SetEngineZoneReceivedHit(true);
973 }
974 }
975 }
976
977 //FX only on Client and in Single
978 if (!GetGame().IsDedicatedServer())
979 {
981 {
984 m_exhaustFx.SetParticleStateLight();
985 }
986
987 if (IsVitalRadiator() && GetFluidFraction(CarFluid.COOLANT) < 0.5)
988 {
990 {
993 }
994
995 if (m_coolantFx)
996 {
997 if (GetFluidFraction(CarFluid.COOLANT) > 0)
998 m_coolantFx.SetParticleStateLight();
999 else
1000 m_coolantFx.SetParticleStateHeavy();
1001 }
1002 }
1003 else
1004 {
1007 }
1008 }
1009 }
1010 else
1011 {
1012 //FX only on Client and in Single
1013 if ( !GetGame().IsDedicatedServer() )
1014 {
1016 {
1018 m_exhaustPtcFx = -1;
1019 }
1020
1022 {
1024 m_coolantPtcFx = -1;
1025 }
1026 }
1027 }
1028
1029 }
1030
1031 //FX only on Client and in Single
1032 if ( !GetGame().IsDedicatedServer() )
1033 {
1034 float carSpeed = GetVelocity(this).Length();
1035 for (int i = 0; i < WheelCount(); i++)
1036 {
1037 EffWheelSmoke eff = m_WheelSmokeFx.Get(i);
1038 int ptrEff = m_WheelSmokePtcFx.Get(i);
1039 bool haveParticle = false;
1040
1041 if (WheelHasContact(i))
1042 {
1043 CarWheel wheel = CarWheel.Cast(WheelGetEntity(i));
1044 float wheelSpeed = WheelGetAngularVelocity(i) * wheel.GetRadius();
1045
1046 vector wheelPos = WheelGetContactPosition(i);
1047 vector wheelVel = dBodyGetVelocityAt(this, wheelPos);
1048
1049 vector transform[3];
1050 transform[2] = WheelGetDirection(i);
1051 transform[1] = vector.Up;
1052 transform[0] = transform[2] * transform[1];
1053
1054 wheelVel = wheelVel.InvMultiply3(transform);
1055
1056 float bodySpeed = wheelVel[2];
1057
1058 bool applyEffect = false;
1059 if ((wheelSpeed > 0 && bodySpeed > 0) || (wheelSpeed < 0 && bodySpeed < 0))
1060 {
1061 applyEffect = Math.AbsFloat(wheelSpeed) > Math.AbsFloat(bodySpeed) + EffWheelSmoke.WHEEL_SMOKE_THRESHOLD;
1062 }
1063 else
1064 {
1065 applyEffect = Math.AbsFloat(wheelSpeed) > EffWheelSmoke.WHEEL_SMOKE_THRESHOLD;
1066 }
1067
1068 if (applyEffect)
1069 {
1070 haveParticle = true;
1071
1072 string surface;
1073 GetGame().SurfaceGetType(wheelPos[0], wheelPos[2], surface);
1074 wheelPos = WorldToModel(wheelPos);
1075
1076 if (!SEffectManager.IsEffectExist(ptrEff))
1077 {
1078 eff = new EffWheelSmoke();
1079 eff.SetSurface(surface);
1080 ptrEff = SEffectManager.PlayOnObject(eff, this, wheelPos, "0 1 -1");
1081 eff.SetCurrentLocalPosition(wheelPos);
1082 m_WheelSmokeFx.Set(i, eff);
1083 m_WheelSmokePtcFx.Set(i, ptrEff);
1084 }
1085 else
1086 {
1087 if (!eff.IsPlaying() && Surface.GetWheelParticleID(surface) != 0)
1088 eff.Start();
1089 eff.SetSurface(surface);
1090 eff.SetCurrentLocalPosition(wheelPos);
1091 }
1092 }
1093 }
1094
1095 if (!haveParticle)
1096 {
1097 if (eff && eff.IsPlaying())
1098 eff.Stop();
1099 }
1100 }
1101 }
1102 //}
1103 }
CarFluid
Type of vehicle's fluid. (native, do not change or extend)
Определения Car.c:19
vector m_VelocityPrevTick
Определения CarScript.c:143
ref EffVehicleSmoke m_coolantFx
Particles.
Определения CarScript.c:185
float m_FuelTankHealth
Определения CarScript.c:171
ref array< ref EffWheelSmoke > m_WheelSmokeFx
Определения CarScript.c:270
bool IsVitalGlowPlug()
Определения CarScript.c:2456
void CheckVitalItem(bool isVital, string itemName)
Определения CarScript.c:2260
vector m_exhaustPtcPos
Определения CarScript.c:193
int m_coolantPtcFx
Определения CarScript.c:190
float m_EngineHealth
Определения CarScript.c:169
void CheckContactCache()
Responsible for damaging the car according to contact events from OnContact.
Определения CarScript.c:1311
int m_exhaustPtcFx
Определения CarScript.c:191
override void HandleByCrewMemberState(ECrewMemberState state)
Определения CarScript.c:1644
void LeakFluid(CarFluid fluid)
Определения CarScript.c:2273
float m_MomentumPrevTick
Определения CarScript.c:142
ref array< int > m_WheelSmokePtcFx
Определения CarScript.c:271
vector m_coolantPtcPos
Определения CarScript.c:196
bool IsVitalRadiator()
Определения CarScript.c:2466
bool IsVitalCarBattery()
Определения CarScript.c:2446
vector m_exhaustPtcDir
Определения CarScript.c:194
ref EffVehicleSmoke m_exhaustFx
Определения CarScript.c:187
bool IsVitalTruckBattery()
Определения CarScript.c:2451
void CarPartsHealthCheck()
Определения CarScript.c:2296
float m_RadiatorHealth
Определения CarScript.c:170
bool IsVitalFuelTank()
Определения CarScript.c:2471
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
ECrewMemberState
Определения ECrewMemberState.c:2
float m_Time
Определения WoundInfection.c:22
proto float SurfaceGetType(float x, float z, out string type)
Returns: Y position the surface was found.
Определения InventoryItem.c:413
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.
Определения Debug.c:122
Определения Debug.c:2
Определения CoolantSteam.c:2
Определения ExhaustSmoke.c:2
const float WHEEL_SMOKE_THRESHOLD
Определения WheelSmoke.c:3
void SetSurface(string surface)
Определения WheelSmoke.c:9
Определения WheelSmoke.c:2
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
Определения constants.c:659
Определения EnMath.c:7
static int PlayOnObject(notnull Effect eff, Object obj, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_rotation_relative_to_world=false)
Play an Effect.
Определения EffectManager.c:70
static void Stop(int effect_id)
Stops the Effect.
Определения EffectManager.c:110
static bool IsEffectExist(int effect_id)
Checks whether an Effect ID is registered in SEffectManager.
Определения EffectManager.c:294
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
static int GetWheelParticleID(string surface_name)
Определения Surface.c:8
Определения Surface.c:2
proto native float Length()
Returns length of vector (magnitude)
static const vector Zero
Определения EnConvert.c:110
proto vector InvMultiply3(vector mat[3])
Invert-transforms vector.
static const vector Up
Определения EnConvert.c:107
Определения EnConvert.c:106
proto native CGame GetGame()
const int CARS_FLUIDS_TICK
Определения constants.c:825
const float DAMAGE_RUINED_VALUE
Определения constants.c:862
const float DAMAGE_DAMAGED_VALUE
Определения constants.c:860
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
static proto float AbsFloat(float f)
Returns absolute value.
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(), HandleByCrewMemberState(), vector::InvMultiply3(), SEffectManager::IsEffectExist(), CarScript::IsVitalCarBattery(), IsVitalFuelTank(), CarScript::IsVitalGlowPlug(), CarScript::IsVitalRadiator(), CarScript::IsVitalSparkPlug(), CarScript::IsVitalTruckBattery(), 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.