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

◆ OnInput()

override void Car::OnInput ( float dt)
inlineprotected

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

1042 {
1043 super.OnInput(dt);
1044
1045#ifdef DIAG_DEVELOPER
1046 if (m_eDebugMode == ECarDebugMode.NONE)
1047 return;
1048
1049 float currentRPM = EngineGetRPM();
1050 if (currentRPM < EngineGetRPMIdle())
1051 {
1052 if (currentRPM < 1.0 && EngineIsOn())
1053 {
1055 EngineStop();
1056 }
1057 else if (!EngineIsOn())
1058 {
1059 EngineStart();
1060 }
1061
1062 return;
1063 }
1064
1065 float currentSpeed = GetSpeedometer();
1066
1067 float longitudinalWanted = 0.0;
1068 float throttleWanted = 0.0;
1069 float steeringWanted = 0.0;
1070
1071 bool attemptSpeed = false;
1072 float speedWanted = 0;
1073
1074 string text = "";
1075
1076 switch (m_eDebugMode)
1077 {
1078 case ECarDebugMode.FORWARD_10:
1079 attemptSpeed = true;
1080 speedWanted = 3;
1081 break;
1082 case ECarDebugMode.FORWARD_50:
1083 attemptSpeed = true;
1084 speedWanted = 50;
1085 break;
1086 case ECarDebugMode.RANDOM_DRIVING:
1087 attemptSpeed = true;
1088
1089 m_DebugParams.param1 -= dt;
1090 if (m_DebugParams.param1 <= 0)
1091 {
1092 m_DebugParams.param1 = Math.RandomFloatInclusive(0.01, 1.0);
1093
1094 speedWanted = speedWanted + Math.RandomFloatInclusive(-25, 25);
1095
1096 speedWanted = Math.Clamp(speedWanted, -20, 100);
1097
1098 steeringWanted = Math.RandomFloatInclusive(-1, 1);
1099
1100 float steeringWantedSign = (steeringWanted > 0) - (steeringWanted < 0);
1101 steeringWanted = steeringWantedSign * Math.Pow(Math.AbsFloat(steeringWanted), 0.5);
1102
1103 if (Math.AbsFloat(speedWanted - currentSpeed) > 15)
1104 {
1105 steeringWanted *= 0.1;
1106 }
1107
1108 m_DebugParams.param2 = steeringWanted;
1109 m_DebugParams.param3 = speedWanted;
1110 }
1111
1112 steeringWanted = m_DebugParams.param2;
1113 speedWanted = m_DebugParams.param3;
1114
1115 text += "\nTarget Steering: " + steeringWanted;
1116 text += "\nTarget Speed: " + speedWanted;
1117 text += "\nCurrent Speed: " + currentSpeed;
1118
1119 break;
1120 case ECarDebugMode.PREDEFINED_PATH:
1121 attemptSpeed = true;
1122 speedWanted = 50;
1123 break;
1124 }
1125
1126 if (!GetGame().IsDedicatedServer())
1127 {
1128 vector transform[4];
1129 GetTransform(transform);
1130 m_DebugText = DebugTextWorldSpace.CreateInWorld(text, DebugTextFlags.DEFAULT | DebugTextFlags.FACE_CAMERA, transform, 1.0);
1131 }
1132
1133 if (attemptSpeed)
1134 {
1135 longitudinalWanted = speedWanted - currentSpeed;
1136
1137 if (speedWanted > 0.1 && currentSpeed > 0.1)
1138 {
1139 longitudinalWanted = Math.Max(longitudinalWanted, 0.1);
1140 }
1141 else if (speedWanted < 0.1 && currentSpeed < 0.1)
1142 {
1143 longitudinalWanted = Math.Min(longitudinalWanted, -0.1);
1144 }
1145 }
1146
1148 float hillFactor = GetOrientation()[1] / 10.0;
1149 hillFactor += 1.0;
1150 hillFactor = Math.Clamp(hillFactor, 0.5, 5.0);
1151
1153 throttleWanted = (EngineGetRPMMin() - EngineGetRPM()) / (EngineGetRPMMin() - EngineGetRPMRedline());
1154 throttleWanted = 1.0 - throttleWanted;
1155 throttleWanted *= Math.AbsFloat(longitudinalWanted);
1156 throttleWanted *= hillFactor;
1157 throttleWanted = Math.Clamp(throttleWanted, 0.0, 1.0);
1158
1159 bool isManual = GearboxGetType() == CarGearboxType.MANUAL;
1160 bool isReverse = GetGear() == CarGear.REVERSE;
1161
1162 if (isManual)
1163 {
1164 float thrustWantedAbs = Math.AbsFloat(throttleWanted);
1165
1166 /*
1167 wtf enforce script?
1168 bool override1 = false;
1169
1170 if (attemptSpeed)
1171 {
1172 if (speedWanted < 0 && currentSpeed < 10)
1173 {
1174 ShiftTo(CarGear.REVERSE);
1175 override1 = true;
1176 }
1177 else if (speedWanted <= 1)
1178 {
1179 ShiftTo(CarGear.NEUTRAL);
1180 override1 = true;
1181 }
1182 }
1183 */
1184
1185 if (currentRPM > EngineGetRPMRedline() * 0.8)
1186 {
1187 if (thrustWantedAbs > 0.1)
1188 {
1189 ShiftUp();
1190 }
1191 }
1192 else if (GetGear() > CarGear.FIRST && thrustWantedAbs < 0.1)
1193 {
1194 ShiftDown();
1195 }
1196 else if (GetGear() < CarGear.FIRST || (throttleWanted > 0.0 && Math.AbsFloat(currentSpeed) < 5.0))
1197 {
1198 ShiftTo(CarGear.FIRST);
1199 }
1200 }
1201
1202 SetThrottle(throttleWanted);
1203 SetSteering(steeringWanted);
1204 SetBrake(0.1);
1205 SetHandbrake(0.0);
1206 SetBrakesActivateWithoutDriver(false);
1207#endif
1208 }
vector GetOrientation()
Определения AreaDamageManager.c:306
CarGearboxType
Enumerated gearbox types. (native, do not change or extend)
Определения Car.c:24
proto native void ShiftTo(int gear)
Shifts the future gear to selected gear, triggering gearbox simulation.
proto native void SetThrottle(float value)
Sets the future throttle value.
proto native float EngineGetRPMRedline()
Returns engine's maximal working rpm without damaging the engine.
proto native void SetHandbrake(float value)
Sets the future front brake value.
proto native CarGearboxType GearboxGetType()
Returns gearbox type. See CarGearboxType enum for more info.
proto native void EngineStop()
Stops the engine.
proto native void SetBrake(float value)
Sets the future rear brake value.
proto native bool EngineIsOn()
Returns true when engine is running, false otherwise.
proto native float EngineGetRPMIdle()
Returns engine's idle rpm before engine stalls.
proto native void ShiftDown()
Shifts the future gear down, triggering gearbox simulation.
proto native void ShiftUp()
Shifts the future gear up, triggering gearbox simulation.
proto native void EngineStart()
Starts the engine.
proto native float EngineGetRPM()
Returns engine's rpm value.
float GetSpeedometer()
Returns the current speed of the vehicle in km/h.
Определения Motorbike.c:45
proto native float EngineGetRPMMin()
Returns engine's min operating rpm.
proto native void SetSteering(float value)
Sets the future steering value.
proto native int GetGear()
Returns the index of the future gear, -1 if there is no engine.
DayZGame GetGame()
Определения gameplay.c:636
DebugTextFlags
Определения DebugTextFlags.c:8

Перекрестные ссылки Math::AbsFloat(), Math::Clamp(), DebugTextWorldSpace::CreateInWorld(), EngineGetRPM(), EngineGetRPMIdle(), EngineGetRPMMin(), EngineGetRPMRedline(), EngineIsOn(), EngineStart(), EngineStop(), GearboxGetType(), GetGame(), GetGear(), GetOrientation(), GetSpeedometer(), Math::Max(), Math::Min(), Math::Pow(), Math::RandomFloatInclusive(), SetBrake(), SetHandbrake(), SetSteering(), SetThrottle(), ShiftDown(), ShiftTo() и ShiftUp().