DayZ 1.30
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 строка 807

808 {
809 m_Time += timeSlice;
810
811 if (g_Game.IsServer())
812 {
813 #ifdef DIAG_DEVELOPER
814 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.CONTACT)
815 {
816 if (m_ContactCalled)
817 {
818 Debug.Log("Momentum delta: " + (GetMomentum() - m_MomentumPrevTick));
819 Debug.Log("--------------------------------------------------------------------");
820 m_ContactCalled = false;
821 }
822 }
823 #endif
824
825
827 m_VelocityPrevTick = GetVelocity(this);
828 m_MomentumPrevTick = GetMomentum();
829 #ifdef DIAG_DEVELOPER
830 m_DebugMessageCleanTime += timeSlice;
831 if (m_DebugMessageCleanTime >= DEBUG_MESSAGE_CLEAN_TIME_SECONDS)
832 {
833 m_DebugMessageCleanTime = 0;
834 m_DebugContactDamageMessage = "";
835 }
836 #endif
837 }
838
839 if (m_Time >= GameConstants.CARS_FLUIDS_TICK)
840 {
841 m_Time = 0;
842
844
845 bool isServerOrOwner = IsServerOrOwner();
846
847 //First of all check if the car should stop the engine
848 if (isServerOrOwner && EngineIsOn())
849 {
850 if (IsDamageDestroyed() || GetFluidFraction(CarFluid.FUEL) <= 0 || m_EngineHealth <= 0)
851 EngineStop();
852
853 CheckVitalItemCallback(IsVitalSparkPlug(), SparkPlug.SLOT_ID, this, "EngineStop");
854 CheckVitalItemCallback(IsVitalGlowPlug(), GlowPlug.SLOT_ID, this, "EngineStop");
855 }
856
857 if (g_Game.IsServer())
858 {
859 if (IsVitalFuelTank())
860 {
861 if (m_FuelTankHealth == GameConstants.DAMAGE_RUINED_VALUE && m_EngineHealth > GameConstants.DAMAGE_RUINED_VALUE)
862 {
863 SetHealth("Engine", "Health", GameConstants.DAMAGE_RUINED_VALUE);
864 }
865 }
866 }
867
869 if (EngineIsOn())
870 {
871 if (g_Game.IsServer())
872 {
873 float dmg;
874
876 {
878 AddHealth( "Engine", "Health", -GetMaxHealth("Engine", "") * 0.05 ); //CAR_RPM_DMG
879
880 // only called on server, don't use deterministic RandomFloat
881 dmg = EngineGetRPM() * 0.001 * Math.RandomFloat( 0.02, 1.0 ); //CARS_TICK_DMG_MIN; //CARS_TICK_DMG_MAX
882 ProcessDirectDamage(DamageType.CUSTOM, null, "Engine", "EnviroDmg", vector.Zero, dmg);
883 SetEngineZoneReceivedHit(true);
884 }
885 else
886 {
887 SetEngineZoneReceivedHit(false);
888 }
889 }
890
891 if (isServerOrOwner)
892 {
894 if ( IsVitalRadiator() )
895 {
896 if ( GetFluidFraction(CarFluid.COOLANT) > 0 && m_RadiatorHealth < 0.5 ) //CARS_LEAK_THRESHOLD
897 LeakFluid( CarFluid.COOLANT );
898 }
899
900 if ( GetFluidFraction(CarFluid.FUEL) > 0 && m_FuelTankHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
901 LeakFluid( CarFluid.FUEL );
902
903 if ( GetFluidFraction(CarFluid.BRAKE) > 0 && m_EngineHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
904 LeakFluid( CarFluid.BRAKE );
905
906 if ( GetFluidFraction(CarFluid.OIL) > 0 && m_EngineHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
907 LeakFluid( CarFluid.OIL );
908
909 if ( m_EngineHealth < 0.25 )
910 LeakFluid( CarFluid.OIL );
911 }
912
913 if ( g_Game.IsServer() )
914 {
915 if ( IsVitalRadiator() )
916 {
917 if ( GetFluidFraction( CarFluid.COOLANT ) < 0.5 && GetFluidFraction( CarFluid.COOLANT ) >= 0 )
918 {
919 // only called on server, don't use deterministic RandomFloat
920 dmg = ( 1 - GetFluidFraction(CarFluid.COOLANT) ) * Math.RandomFloat( 0.02, 10.00 ); //CARS_DMG_TICK_MIN_COOLANT; //CARS_DMG_TICK_MAX_COOLANT
921 AddHealth( "Engine", "Health", -dmg );
922 SetEngineZoneReceivedHit(true);
923 }
924 }
925 }
926 }
927 }
928 }
bool IsDamageDestroyed(ActionTarget target)
Определения ActionBase.c:1275
string Debug()
Определения CachedEquipmentStorageBase.c:26
CarFluid
Type of vehicle's fluid. (native, do not change or extend)
Определения Car.c:18
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:4074
proto native float EngineGetRPMRedline()
Returns engine's maximal working rpm without damaging the engine.
proto native void EngineStop()
Stops the engine.
proto native bool EngineIsOn()
Returns true when engine is running, false otherwise.
proto native float EngineGetRPM()
Returns engine's rpm value.
proto native float GetFluidFraction(MotorbikeFluid fluid)
proto native float EngineGetRPMMax()
Returns engine's max rpm before engine blows up.
override bool IsVitalGlowPlug()
override bool IsVitalSparkPlug()
bool IsVitalRadiator()
Определения CarScript.c:2206
void LeakFluid(CarFluid fluid)
Определения CarScript.c:2098
float m_Time
Определения CarScript.c:100
float m_EngineHealth
Определения CarScript.c:122
void PartsHealthCheck()
Определения CarScript.c:2121
void CheckContactCache()
Responsible for damaging the car according to contact events from OnContact.
Определения CarScript.c:1279
float m_RadiatorHealth
Определения CarScript.c:123
float m_FuelTankHealth
Определения CarScript.c:124
bool IsServerOrOwner()
Определения CarScript.c:2592
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.

Перекрестные ссылки GameConstants::CARS_FLUIDS_TICK, CheckContactCache(), GameConstants::DAMAGE_DAMAGED_VALUE, GameConstants::DAMAGE_RUINED_VALUE, EngineGetRPM(), EngineGetRPMMax(), EngineGetRPMRedline(), EngineIsOn(), EngineStop(), g_Game, GetFluidFraction(), GetVelocity(), IsDamageDestroyed(), IsServerOrOwner(), CarScript::IsVitalGlowPlug(), CarScript::IsVitalRadiator(), CarScript::IsVitalSparkPlug(), LeakFluid(), Debug::Log(), m_EngineHealth, m_FuelTankHealth, m_RadiatorHealth, m_Time, PartsHealthCheck(), Math::RandomFloat() и vector::Zero.