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