DayZ 1.24
Loading...
Searching...
No Matches
Offroad_02.c
Go to the documentation of this file.
1class Offroad_02 extends CarScript
2{
6
7 void Offroad_02()
8 {
9 //m_dmgContactCoef = 0.0365;
10
11 m_EngineStartOK = "Offroad_02_engine_start_SoundSet";
12 m_EngineStartBattery = "Offroad_02_engine_failed_start_battery_SoundSet";
13 m_EngineStartPlug = "Offroad_02_engine_failed_start_sparkplugs_SoundSet";
14 m_EngineStartFuel = "Offroad_02_engine_failed_start_fuel_SoundSet";
15 m_EngineStopFuel = "offroad_engine_stop_fuel_SoundSet";
16
17 m_CarDoorOpenSound = "offroad_02_door_open_SoundSet";
18 m_CarDoorCloseSound = "offroad_02_door_close_SoundSet";
19
20 m_CarHornShortSoundName = "Offroad_02_Horn_Short_SoundSet";
21 m_CarHornLongSoundName = "Offroad_02_Horn_SoundSet";
22
23 SetEnginePos("0 0.7 1.7");
24 }
25
26 override void EEInit()
27 {
28 super.EEInit();
29
30 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
31 {
33 m_UTSSettings.m_ManualUpdate = true;
34 m_UTSSettings.m_TemperatureMin = 0;
35 m_UTSSettings.m_TemperatureMax = 30;
36 m_UTSSettings.m_RangeFull = 0.5;
37 m_UTSSettings.m_RangeMax = 2;
38 m_UTSSettings.m_TemperatureCap = 25;
39
42 }
43 }
44
45 override void OnEngineStart()
46 {
47 super.OnEngineStart();
48
49 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
50 m_UTSource.SetDefferedActive(true, 20.0);
51 }
52
53 override void OnEngineStop()
54 {
55 super.OnEngineStop();
56
57 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
58 m_UTSource.SetDefferedActive(false, 10.0);
59 }
60
61 override void EOnPostSimulate(IEntity other, float timeSlice)
62 {
63 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
64 {
65 if (m_UTSource.IsActive())
67 }
68 }
69
70 override int GetAnimInstance()
71 {
72 return VehicleAnimInstances.HMMWV;
73 }
74
76 {
77 return 5.1;
78 }
79
80 override int GetSeatAnimationType(int posIdx)
81 {
82 switch (posIdx)
83 {
84 case 0:
85 return DayZPlayerConstants.VEHICLESEAT_DRIVER;
86 case 1:
87 return DayZPlayerConstants.VEHICLESEAT_CODRIVER;
88 case 2:
89 return DayZPlayerConstants.VEHICLESEAT_PASSENGER_L;
90 case 3:
91 return DayZPlayerConstants.VEHICLESEAT_PASSENGER_R;
92 }
93
94 return 0;
95 }
96
97 // Override for car-specific light type
99 {
100 return CarLightBase.Cast(ScriptedLightBase.CreateLight(Offroad_02FrontLight));
101 }
102
103 // Override for car-specific light type
105 {
106 return CarRearLightBase.Cast(ScriptedLightBase.CreateLight(Offroad_02RearLight));
107 }
108
110 {
111 if (!super.CanReleaseAttachment(attachment))
112 return false;
113
114 string attType = attachment.GetType();
115 switch (attType)
116 {
117 case "CarBattery":
118 if (GetCarDoorsState("Offroad_02_Hood") == CarDoorState.DOORS_CLOSED || EngineIsOn())
119 return false;
120 break;
121
122 case "GlowPlug":
123 if (GetCarDoorsState("Offroad_02_Hood") == CarDoorState.DOORS_CLOSED || EngineIsOn())
124 return false;
125 break;
126 }
127
128 return true;
129 }
130
131 override protected bool CanManipulateSpareWheel(string slotSelectionName)
132 {
133 return GetCarDoorsState("Offroad_02_Trunk") != CarDoorState.DOORS_CLOSED;
134 }
135
137 {
138 if (!super.CanDisplayAttachmentCategory(category_name))
139 return false;
140
141 category_name.ToLower();
142 if (category_name.Contains("engine"))
143 {
144 if (GetCarDoorsState("Offroad_02_Hood") == CarDoorState.DOORS_CLOSED)
145 return false;
146 }
147
148 return true;
149 }
150
151 override bool CanDisplayCargo()
152 {
153 if (!super.CanDisplayCargo())
154 return false;
155
156 if (GetCarDoorsState("Offroad_02_Trunk") == CarDoorState.DOORS_CLOSED)
157 return false;
158
159 return true;
160 }
161
162 override int GetCarDoorsState(string slotType)
163 {
165
166 Class.CastTo(carDoor, FindAttachmentBySlotName(slotType));
167 if (!carDoor)
168 return CarDoorState.DOORS_MISSING;
169
170 switch (slotType)
171 {
172 case "Offroad_02_Door_1_1":
173 return TranslateAnimationPhaseToCarDoorState("DoorsDriver");
174
175 case "Offroad_02_Door_2_1":
176 return TranslateAnimationPhaseToCarDoorState("DoorsCoDriver");
177
178 case "Offroad_02_Door_1_2":
179 return TranslateAnimationPhaseToCarDoorState("DoorsCargo1");
180
181 case "Offroad_02_Door_2_2":
182 return TranslateAnimationPhaseToCarDoorState("DoorsCargo2");
183
184 case "Offroad_02_Hood":
185 return TranslateAnimationPhaseToCarDoorState("DoorsHood");
186
187 case "Offroad_02_Trunk":
188 return TranslateAnimationPhaseToCarDoorState("DoorsTrunk");
189 }
190
191 return CarDoorState.DOORS_MISSING;
192 }
193
194
195 override bool CrewCanGetThrough(int posIdx)
196 {
197 switch (posIdx)
198 {
199 case 0:
200 if (GetCarDoorsState("Offroad_02_Door_1_1") == CarDoorState.DOORS_CLOSED)
201 return false;
202
203 return true;
204 break;
205
206 case 1:
207 if (GetCarDoorsState("Offroad_02_Door_2_1") == CarDoorState.DOORS_CLOSED)
208 return false;
209
210 return true;
211 break;
212
213 case 2:
214 if (GetCarDoorsState("Offroad_02_Door_1_2") == CarDoorState.DOORS_CLOSED)
215 return false;
216
217 return true;
218 break;
219
220 case 3:
221 if (GetCarDoorsState("Offroad_02_Door_2_2") == CarDoorState.DOORS_CLOSED)
222 return false;
223
224 return true;
225 break;
226 }
227
228 return false;
229 }
230
232 {
233 switch (posIdx)
234 {
235 case 0:
236 return "doors_driver";
237 break;
238 case 1:
239 return "doors_codriver";
240 break;
241 case 2:
242 return "doors_cargo1";
243 break;
244 case 3:
245 return "doors_cargo2";
246 break;
247 }
248
249 return super.GetDoorSelectionNameFromSeatPos(posIdx);
250 }
251
253 {
254 switch (posIdx)
255 {
256 case 0:
257 return "Offroad_02_Door_1_1";
258 case 1:
259 return "Offroad_02_Door_2_1";
260 case 2:
261 return "Offroad_02_Door_1_2";
262 case 3:
263 return "Offroad_02_Door_2_2";
264 }
265
266 return super.GetDoorInvSlotNameFromSeatPos(posIdx);
267 }
268
269 override float OnSound(CarSoundCtrl ctrl, float oldValue)
270 {
271 switch (ctrl)
272 {
273 case CarSoundCtrl.DOORS:
274 float newValue = 0;
275 if (GetCarDoorsState("Offroad_02_Door_1_1") == CarDoorState.DOORS_CLOSED)
276 newValue += 0.25;
277
278 if (GetCarDoorsState("Offroad_02_Door_2_1") == CarDoorState.DOORS_CLOSED)
279 newValue += 0.25;
280
281 if (GetCarDoorsState("Offroad_02_Door_1_2") == CarDoorState.DOORS_CLOSED)
282 newValue += 0.25;
283
284 if (GetCarDoorsState("Offroad_02_Door_2_2") == CarDoorState.DOORS_CLOSED)
285 newValue += 0.25;
286
287 return Math.Clamp(newValue, 0, 1);
288 break;
289 }
290
291 return super.OnSound(ctrl, oldValue);
292 }
293
294 override string GetAnimSourceFromSelection(string selection)
295 {
296 switch (selection)
297 {
298 case "doors_driver":
299 return "DoorsDriver";
300 case "doors_codriver":
301 return "DoorsCoDriver";
302 case "doors_cargo1":
303 return "DoorsCargo1";
304 case "doors_cargo2":
305 return "DoorsCargo2";
306 case "doors_hood":
307 return "DoorsHood";
308 case "doors_trunk":
309 return "DoorsTrunk";
310 }
311
312 return "";
313 }
314
316 {
317 switch (currentSeat)
318 {
319 case 0:
320 return nextSeat == 1;
321 case 1:
322 return nextSeat == 0;
323 case 2:
324 return nextSeat == 3;
325 case 3:
326 return nextSeat == 2;
327 }
328
329 return false;
330 }
331
333 {
334 switch (pCurrentSeat)
335 {
336 case 0:
337 return pDoorsSelection == "DoorsDriver";
338 case 1:
339 return pDoorsSelection == "DoorsCoDriver";
340 case 2:
341 return pDoorsSelection == "DoorsCargo1";
342 case 3:
343 return pDoorsSelection == "DoorsCargo2";
344 }
345
346 return false;
347 }
348
349 override bool IsVitalTruckBattery()
350 {
351 return false;
352 }
353
354 override bool IsVitalSparkPlug()
355 {
356 return false;
357 }
358
359 override bool IsVitalRadiator()
360 {
361 return false;
362 }
363
364 override void OnDebugSpawn()
365 {
369
370 GetInventory().CreateInInventory("Offroad_02_Wheel");
371 GetInventory().CreateInInventory("Offroad_02_Wheel");
372 GetInventory().CreateInInventory("Offroad_02_Wheel");
373 GetInventory().CreateInInventory("Offroad_02_Wheel");
374
375 GetInventory().CreateInInventory("Offroad_02_Door_1_1");
376 GetInventory().CreateInInventory("Offroad_02_Door_1_2");
377 GetInventory().CreateInInventory("Offroad_02_Door_2_1");
378 GetInventory().CreateInInventory("Offroad_02_Door_2_2");
379 GetInventory().CreateInInventory("Offroad_02_Hood");
380 GetInventory().CreateInInventory("Offroad_02_Trunk");
381
382 //-----IN CAR CARGO
383 GetInventory().CreateInInventory("Offroad_02_Wheel");
384 GetInventory().CreateInInventory("Offroad_02_Wheel");
385 }
386}
CarSoundCtrl
Car's sound controller list. (native, do not change or extend)
Definition Car.c:4
void SpawnUniversalParts()
Definition CarScript.c:2516
CarDoorState TranslateAnimationPhaseToCarDoorState(string animation)
Definition CarScript.c:2241
CarDoorState
Definition CarScript.c:2
void SpawnAdditionalItems()
Definition CarScript.c:2554
string m_EngineStartOK
Sounds.
Definition CarScript.c:207
string m_CarDoorCloseSound
Definition CarScript.c:214
string m_EngineStartBattery
Definition CarScript.c:208
string m_EngineStartPlug
Definition CarScript.c:209
string m_EngineStartFuel
Definition CarScript.c:210
string m_CarHornShortSoundName
Definition CarScript.c:218
void FillUpCarFluids()
Definition CarScript.c:2578
string m_CarHornLongSoundName
Definition CarScript.c:219
string m_EngineStopFuel
Definition CarScript.c:211
string m_CarDoorOpenSound
Definition CarScript.c:213
ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
ref UniversalTemperatureSourceSettings m_UTSSettings
ref UniversalTemperatureSource m_UTSource
VehicleAnimInstances
override float OnSound(CarSoundCtrl ctrl, float oldValue)
Definition Offroad_02.c:269
override float GetTransportCameraDistance()
Definition Offroad_02.c:75
override string GetDoorSelectionNameFromSeatPos(int posIdx)
Definition Offroad_02.c:231
override int GetAnimInstance()
Definition Offroad_02.c:70
override CarRearLightBase CreateRearLight()
Definition Offroad_02.c:104
override void OnDebugSpawn()
Definition Offroad_02.c:364
override string GetDoorInvSlotNameFromSeatPos(int posIdx)
Definition Offroad_02.c:252
override CarLightBase CreateFrontLight()
Definition Offroad_02.c:98
override int GetCarDoorsState(string slotType)
override bool IsVitalTruckBattery()
Definition Offroad_02.c:349
ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
override string GetAnimSourceFromSelection(string selection)
Definition Offroad_02.c:294
override bool CanDisplayCargo()
Definition Offroad_02.c:151
void Offroad_02()
Definition Offroad_02.c:7
override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
Definition Offroad_02.c:332
override void EOnPostSimulate(IEntity other, float timeSlice)
Definition Offroad_02.c:61
override void OnEngineStart()
Definition Offroad_02.c:45
override bool CanReleaseAttachment(EntityAI attachment)
Definition Offroad_02.c:109
override void EEInit()
Definition Offroad_02.c:26
override bool IsVitalRadiator()
Definition Offroad_02.c:359
override bool CrewCanGetThrough(int posIdx)
Definition Offroad_02.c:195
ref UniversalTemperatureSource m_UTSource
override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
Definition Offroad_02.c:315
override bool IsVitalSparkPlug()
Definition Offroad_02.c:354
bool CanManipulateSpareWheel(string slotSelectionName)
Definition Offroad_02.c:131
override void OnEngineStop()
Definition Offroad_02.c:53
override bool CanDisplayAttachmentCategory(string category_name)
Definition Offroad_02.c:136
override int GetSeatAnimationType(int posIdx)
Definition Offroad_02.c:80
ref UniversalTemperatureSourceSettings m_UTSSettings
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition EnMath.c:7
original Timer deletes m_params which is unwanted
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.