863 {
865
867 {
870
871 #ifdef DIAG_DEVELOPER
872 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.CONTACT)
873 {
874 if (m_ContactCalled)
875 {
877 Debug.
Log(
"--------------------------------------------------------------------");
878 m_ContactCalled = false;
879 }
880 }
881 #endif
882
883
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 {
900
902
903
904 if (
GetGame().IsServer() && EngineIsOn())
905 {
907 EngineStop();
908
913 }
914
916 {
918 {
920 {
922 }
923 }
924 }
925
927 if ( EngineIsOn() )
928 {
930 {
931 float dmg;
932
933 if ( EngineGetRPM() >= EngineGetRPMRedline() )
934 {
935 if (EngineGetRPM() > EngineGetRPMMax())
936 AddHealth( "Engine", "Health", -GetMaxHealth("Engine", "") * 0.05 );
937
940 SetEngineZoneReceivedHit(true);
941 }
942 else
943 {
944 SetEngineZoneReceivedHit(false);
945 }
946
949 {
952 }
953
956
959
962
965
967 {
968 if ( GetFluidFraction(
CarFluid.COOLANT ) < 0.5 && GetFluidFraction(
CarFluid.COOLANT ) >= 0 )
969 {
971 AddHealth( "Engine", "Health", -dmg );
972 SetEngineZoneReceivedHit(true);
973 }
974 }
975 }
976
977
978 if (!
GetGame().IsDedicatedServer())
979 {
981 {
985 }
986
988 {
990 {
993 }
994
996 {
997 if (GetFluidFraction(
CarFluid.COOLANT) > 0)
999 else
1001 }
1002 }
1003 else
1004 {
1007 }
1008 }
1009 }
1010 else
1011 {
1012
1013 if ( !
GetGame().IsDedicatedServer() )
1014 {
1016 {
1019 }
1020
1022 {
1025 }
1026 }
1027 }
1028
1029 }
1030
1031
1032 if ( !
GetGame().IsDedicatedServer() )
1033 {
1035 for (int i = 0; i < WheelCount(); i++)
1036 {
1039 bool haveParticle = false;
1040
1041 if (WheelHasContact(i))
1042 {
1044 float wheelSpeed = WheelGetAngularVelocity(i) * wheel.GetRadius();
1045
1046 vector wheelPos = WheelGetContactPosition(i);
1048
1050 transform[2] = WheelGetDirection(i);
1052 transform[0] = transform[2] * transform[1];
1053
1055
1056 float bodySpeed = wheelVel[2];
1057
1058 bool applyEffect = false;
1059 if ((wheelSpeed > 0 && bodySpeed > 0) || (wheelSpeed < 0 && bodySpeed < 0))
1060 {
1062 }
1063 else
1064 {
1066 }
1067
1068 if (applyEffect)
1069 {
1070 haveParticle = true;
1071
1072 string surface;
1074 wheelPos = WorldToModel(wheelPos);
1075
1077 {
1084 }
1085 else
1086 {
1091 }
1092 }
1093 }
1094
1095 if (!haveParticle)
1096 {
1097 if (eff && eff.IsPlaying())
1099 }
1100 }
1101 }
1102
1103 }
CarFluid
Type of vehicle's fluid. (native, do not change or extend)
vector m_VelocityPrevTick
ref EffVehicleSmoke m_coolantFx
Particles.
ref array< ref EffWheelSmoke > m_WheelSmokeFx
void CheckVitalItem(bool isVital, string itemName)
void CheckContactCache()
Responsible for damaging the car according to contact events from OnContact.
override void HandleByCrewMemberState(ECrewMemberState state)
void LeakFluid(CarFluid fluid)
ref array< int > m_WheelSmokePtcFx
ref EffVehicleSmoke m_exhaustFx
bool IsVitalTruckBattery()
void CarPartsHealthCheck()
DamageType
exposed from C++ (do not change)
proto float SurfaceGetType(float x, float z, out string type)
Returns: Y position the surface was found.
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.
const float WHEEL_SMOKE_THRESHOLD
void SetSurface(string surface)
override void Stop()
Stops all elements this effect consists of.
override void Start()
Plays all elements this effect consists of.
override void SetCurrentLocalPosition(vector pos, bool updateCached=true)
Set the current local position of the managed Particle.
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.
static void Stop(int effect_id)
Stops the Effect.
static bool IsEffectExist(int effect_id)
Checks whether an Effect ID is registered in SEffectManager.
Manager class for managing Effect (EffectParticle, EffectSound)
static int GetWheelParticleID(string surface_name)
proto native float Length()
Returns length of vector (magnitude)
proto vector InvMultiply3(vector mat[3])
Invert-transforms vector.
proto native CGame GetGame()
const int CARS_FLUIDS_TICK
const float DAMAGE_RUINED_VALUE
const float DAMAGE_DAMAGED_VALUE
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.