DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
OffroadHatchback.c
Go to the documentation of this file.
2{
6
8 {
9 //m_dmgContactCoef = 0.075;
10
11 m_EngineStartOK = "offroad_engine_start_SoundSet";
12 m_EngineStartBattery = "offroad_engine_failed_start_battery_SoundSet";
13 m_EngineStartPlug = "offroad_engine_failed_start_sparkplugs_SoundSet";
14 m_EngineStartFuel = "offroad_engine_failed_start_fuel_SoundSet";
15 m_EngineStopFuel = "offroad_engine_stop_fuel_SoundSet";
16
17 m_CarDoorOpenSound = "offroad_door_open_SoundSet";
18 m_CarDoorCloseSound = "offroad_door_close_SoundSet";
19 m_CarSeatShiftInSound = "Offroad_SeatShiftIn_SoundSet";
20 m_CarSeatShiftOutSound = "Offroad_SeatShiftOut_SoundSet";
21
22 m_CarHornShortSoundName = "Offroad_Horn_Short_SoundSet";
23 m_CarHornLongSoundName = "Offroad_Horn_SoundSet";
24
25 SetEnginePos("0 0.7 1.2");
26 }
27
28 override void EEInit()
29 {
30 super.EEInit();
31
32 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
33 {
41
44 }
45 }
46
47 override void OnEngineStart()
48 {
49 super.OnEngineStart();
50
51 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
52 {
53 m_UTSource.SetDefferedActive(true, 20.0);
54 }
55 }
56
57 override void OnEngineStop()
58 {
59 super.OnEngineStop();
60
61 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
62 {
63 m_UTSource.SetDefferedActive(false, 10.0);
64 }
65 }
66
67 override void EOnPostSimulate(IEntity other, float timeSlice)
68 {
69 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
70 {
71 if (m_UTSource.IsActive())
72 {
74 }
75 }
76 }
77
78 override int GetAnimInstance()
79 {
80 return VehicleAnimInstances.HATCHBACK;
81 }
82
84 {
85 return 3.5;
86 }
87
88 override int GetSeatAnimationType( int posIdx )
89 {
90 switch (posIdx)
91 {
92 case 0:
93 return DayZPlayerConstants.VEHICLESEAT_DRIVER;
94 case 1:
95 return DayZPlayerConstants.VEHICLESEAT_CODRIVER;
96 case 2:
97 return DayZPlayerConstants.VEHICLESEAT_PASSENGER_L;
98 case 3:
99 return DayZPlayerConstants.VEHICLESEAT_PASSENGER_R;
100 }
101
102 return 0;
103
104 }
105
106
108 {
109 return CarRearLightBase.Cast( ScriptedLightBase.CreateLight(OffroadHatchbackRearLight) );
110 }
111
113 {
114 return CarLightBase.Cast( ScriptedLightBase.CreateLight(OffroadHatchbackFrontLight) );
115 }
116
117 override bool CanReleaseAttachment(EntityAI attachment)
118 {
119 if (!super.CanReleaseAttachment(attachment))
120 {
121 return false;
122 }
123
124 if (EngineIsOn() || GetCarDoorsState("NivaHood") == CarDoorState.DOORS_CLOSED)
125 {
126 string attType = attachment.GetType();
127 if (attType == "CarRadiator" || attType == "CarBattery" || attType == "SparkPlug")
128 {
129 return false;
130 }
131 }
132
133 return true;
134 }
135
136 override protected bool CanManipulateSpareWheel(string slotSelectionName)
137 {
138 return GetCarDoorsState("NivaHood") != CarDoorState.DOORS_CLOSED;
139 }
140
141 override bool CanDisplayAttachmentCategory( string category_name )
142 {
143 if (!super.CanDisplayAttachmentCategory(category_name))
144 {
145 return false;
146 }
147
148 category_name.ToLower();
149 if (category_name.Contains("engine"))
150 {
151 if (GetCarDoorsState("NivaHood") == CarDoorState.DOORS_CLOSED)
152 {
153 return false;
154 }
155 }
156
157 return true;
158 }
159
160 override bool CanDisplayCargo()
161 {
162 if (!super.CanDisplayCargo())
163 {
164 return false;
165 }
166
167 if (GetCarDoorsState("NivaTrunk") == CarDoorState.DOORS_CLOSED)
168 {
169 return false;
170 }
171
172 return true;
173 }
174
175 override int GetCarDoorsState(string slotType)
176 {
177 CarDoor carDoor;
178
179 Class.CastTo(carDoor, FindAttachmentBySlotName(slotType));
180 if (!carDoor)
181 {
182 return CarDoorState.DOORS_MISSING;
183 }
184
185 switch (slotType)
186 {
187 case "NivaDriverDoors":
188 return TranslateAnimationPhaseToCarDoorState("DoorsDriver");
189
190 case "NivaCoDriverDoors":
191 return TranslateAnimationPhaseToCarDoorState("DoorsCoDriver");
192
193 case "NivaHood":
194 return TranslateAnimationPhaseToCarDoorState("DoorsHood");
195
196 case "NivaTrunk":
197 return TranslateAnimationPhaseToCarDoorState("DoorsTrunk");
198 }
199
200 return CarDoorState.DOORS_MISSING;
201 }
202
203 override bool CrewCanGetThrough(int posIdx)
204 {
205 CarDoor carDoor;
206 switch (posIdx)
207 {
208 case 0:
209 if (GetCarDoorsState("NivaDriverDoors") == CarDoorState.DOORS_CLOSED)
210 return false;
211 else if (GetAnimationPhase("SeatDriver") > 0.5)
212 return false;
213
214 return true;
215
216 case 1:
217 if (GetCarDoorsState("NivaCoDriverDoors") == CarDoorState.DOORS_CLOSED)
218 return false;
219 else if (GetAnimationPhase("SeatCoDriver") > 0.5)
220 return false;
221
222 return true;
223
224 case 2:
225 if (GetCarDoorsState("NivaDriverDoors") == CarDoorState.DOORS_CLOSED)
226 return false;
227 else if (GetAnimationPhase("SeatDriver") <= 0.5)
228 return false;
229
230 return true;
231
232 case 3:
233 if (GetCarDoorsState("NivaCoDriverDoors") == CarDoorState.DOORS_CLOSED)
234 return false;
235 else if (GetAnimationPhase("SeatCoDriver") <= 0.5)
236 return false;
237
238 return true;
239 }
240
241 return false;
242 }
243
244 override string GetDoorSelectionNameFromSeatPos(int posIdx)
245 {
246 switch (posIdx)
247 {
248 case 0:
249 case 2:
250 return "doors_driver";
251 case 1:
252 case 3:
253 return "doors_codriver";
254 }
255
256 return super.GetDoorSelectionNameFromSeatPos(posIdx);
257 }
258
259 override string GetDoorInvSlotNameFromSeatPos(int posIdx)
260 {
261 switch (posIdx)
262 {
263 case 0:
264 case 2:
265 return "NivaDriverDoors";
266 case 1:
267 case 3:
268 return "NivaCoDriverDoors";
269 }
270
271 return super.GetDoorInvSlotNameFromSeatPos(posIdx);
272 }
273
274 // 0 full ambient and engine sound
275 // 1 zero ambient and engine sound
276 override float OnSound(CarSoundCtrl ctrl, float oldValue)
277 {
278 float tempCap = 0.0;
279
280 switch (ctrl)
281 {
282 case CarSoundCtrl.DOORS:
283 float newValue = 0;
284 if (GetCarDoorsState("NivaDriverDoors") == CarDoorState.DOORS_CLOSED)
285 {
286 newValue += 0.5;
287 }
288
289 if (GetCarDoorsState("NivaCoDriverDoors") == CarDoorState.DOORS_CLOSED)
290 {
291 newValue += 0.5;
292 }
293
294 if (GetCarDoorsState("NivaTrunk") == CarDoorState.DOORS_CLOSED)
295 {
296 newValue += 0.3;
297 }
298
299 if (GetHealthLevel("WindowFront") == GameConstants.STATE_RUINED)
300 {
301 newValue -= 0.6;
302 }
303
304 if (GetHealthLevel("WindowLR") == GameConstants.STATE_RUINED)
305 {
306 newValue -= 0.2;
307 }
308
309 if (GetHealthLevel("WindowRR") == GameConstants.STATE_RUINED)
310 {
311 newValue -= 0.2;
312 }
313
314 return Math.Clamp(newValue, 0, 1);
315 break;
316 }
317
318 return super.OnSound(ctrl, oldValue);
319 }
320
321 override string GetAnimSourceFromSelection( string selection )
322 {
323 switch (selection)
324 {
325 case "doors_driver":
326 return "DoorsDriver";
327 case "doors_codriver":
328 return "DoorsCoDriver";
329 case "doors_hood":
330 return "DoorsHood";
331 case "doors_trunk":
332 return "DoorsTrunk";
333 case "seatback_driver":
334 return "SeatDriver";
335 case "seatback_codriver":
336 return "SeatCoDriver";
337 }
338
339 return "";
340 }
341
342 override string GetDoorConditionPointFromSelection(string selection)
343 {
344 switch (selection)
345 {
346 case "seat_driver":
347 case "seatback_driver":
348 case "seat_cargo1":
349 return "seat_con_1_1";
350 case "seat_codriver":
351 case "seatback_codriver":
352 case "seat_cargo2":
353 return "seat_con_2_1";
354 }
355
356 return "";
357 }
358
359 override int GetCrewIndex(string selection)
360 {
361 switch (selection)
362 {
363 case "seatback_driver":
364 return 0;
365 case "seatback_codriver":
366 return 1;
367 }
368
369 return -1;
370 }
371
372 override bool IsVitalTruckBattery()
373 {
374 return false;
375 }
376
377 override bool IsVitalGlowPlug()
378 {
379 return false;
380 }
381
382 override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
383 {
384 if (nextSeat == 0 && GetAnimationPhase("SeatDriver") > 0.5)
385 return false;
386
387 if (nextSeat == 1 && GetAnimationPhase("SeatCoDriver") > 0.5)
388 return false;
389
390 switch (currentSeat)
391 {
392 case 0:
393 return nextSeat == 1;
394
395 case 1:
396 return nextSeat == 0;
397
398 case 2:
399 return nextSeat == 3;
400
401 case 3:
402 return nextSeat == 2;
403 }
404
405 return false;
406 }
407
408 override bool CanReachDoorsFromSeat( string pDoorsSelection, int pCurrentSeat )
409 {
410 switch (pCurrentSeat)
411 {
412 case 0:
413 return pDoorsSelection == "DoorsDriver";
414
415 case 1:
416 return pDoorsSelection == "DoorsCoDriver";
417
418 case 2:
419 return pDoorsSelection == "DoorsDriver";
420
421 case 3:
422 return pDoorsSelection == "DoorsCoDriver";
423 }
424
425 return false;
426 }
427
428 override int GetSeatIndexFromDoor( string pDoorSelection )
429 {
430 switch (pDoorSelection)
431 {
432 case "DoorsDriver":
433 return 0;
434 case "DoorsCoDriver":
435 return 1;
436 }
437
438 return -1;
439 }
440
441 override void SetActions()
442 {
443 super.SetActions();
444
446 }
447
448 override void OnDebugSpawn()
449 {
453
454 GetInventory().CreateInInventory("HatchbackWheel");
455 GetInventory().CreateInInventory("HatchbackWheel");
456 GetInventory().CreateInInventory("HatchbackWheel" );
457 GetInventory().CreateInInventory("HatchbackWheel");
458
459 GetInventory().CreateInInventory("HatchbackDoors_Driver");
460 GetInventory().CreateInInventory("HatchbackDoors_CoDriver");
461 GetInventory().CreateInInventory("HatchbackHood");
462 GetInventory().CreateInInventory("HatchbackTrunk");
463
464 //-----IN CAR CARGO
465 GetInventory().CreateInInventory("HatchbackWheel");
466 GetInventory().CreateInInventory("HatchbackWheel");
467 }
468}
469
470class OffroadHatchback_White extends OffroadHatchback
471{
472 override void OnDebugSpawn()
478 GetInventory().CreateInInventory("HatchbackWheel");
479 GetInventory().CreateInInventory("HatchbackWheel");
480 GetInventory().CreateInInventory("HatchbackWheel");
481 GetInventory().CreateInInventory("HatchbackWheel");
482
483 GetInventory().CreateInInventory("HatchbackDoors_Driver_White");
484 GetInventory().CreateInInventory("HatchbackDoors_CoDriver_White");
485 GetInventory().CreateInInventory("HatchbackHood_White");
486 GetInventory().CreateInInventory("HatchbackTrunk_White");
487
488 //-----IN CAR CARGO
489 GetInventory().CreateInInventory("HatchbackWheel");
490 GetInventory().CreateInInventory("HatchbackWheel");
491 }
492}
493
494class OffroadHatchback_Blue extends OffroadHatchback
495{
496 override void OnDebugSpawn()
497 {
501
502 GetInventory().CreateInInventory("HatchbackWheel");
503 GetInventory().CreateInInventory("HatchbackWheel");
504 GetInventory().CreateInInventory("HatchbackWheel");
505 GetInventory().CreateInInventory("HatchbackWheel");
506
507 GetInventory().CreateInInventory("HatchbackDoors_Driver_Blue");
508 GetInventory().CreateInInventory("HatchbackDoors_CoDriver_Blue");
509 GetInventory().CreateInInventory("HatchbackHood_Blue");
510 GetInventory().CreateInInventory("HatchbackTrunk_Blue");
511
512 //-----IN CAR CARGO
513 GetInventory().CreateInInventory("HatchbackWheel");
514 GetInventory().CreateInInventory("HatchbackWheel");
515 }
516}
void AddAction(typename actionName)
CarSoundCtrl
Car's sound controller list. (native, do not change or extend)
Definition Car.c:4
string m_CarSeatShiftInSound
Definition CarScript.c:216
CarDoorState TranslateAnimationPhaseToCarDoorState(string animation)
Definition CarScript.c:2192
CarDoorState
Definition CarScript.c:2
protected void SpawnUniversalParts()
Definition CarScript.c:2480
string m_EngineStartOK
Sounds.
Definition CarScript.c:208
protected void FillUpCarFluids()
Definition CarScript.c:2548
string m_CarDoorCloseSound
Definition CarScript.c:215
string m_EngineStartBattery
Definition CarScript.c:209
string m_EngineStartPlug
Definition CarScript.c:210
protected void SpawnAdditionalItems()
Definition CarScript.c:2518
string m_EngineStartFuel
Definition CarScript.c:211
string m_CarHornShortSoundName
Definition CarScript.c:219
string m_CarHornLongSoundName
Definition CarScript.c:220
string m_EngineStopFuel
Definition CarScript.c:212
string m_CarSeatShiftOutSound
Definition CarScript.c:217
string m_CarDoorOpenSound
Definition CarScript.c:214
protected ref UniversalTemperatureSourceSettings m_UTSSettings
override int GetCarDoorsState(string slotType)
protected ref UniversalTemperatureSource m_UTSource
protected ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
VehicleAnimInstances
override int GetCarDoorsState(string slotType)
override void OnDebugSpawn()
override bool CanDisplayAttachmentCategory(string category_name)
override void EOnPostSimulate(IEntity other, float timeSlice)
override float GetTransportCameraDistance()
override bool IsVitalGlowPlug()
override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
override bool CanDisplayCargo()
override int GetAnimInstance()
override bool CrewCanGetThrough(int posIdx)
override CarLightBase CreateFrontLight()
override int GetSeatIndexFromDoor(string pDoorSelection)
override CarRearLightBase CreateRearLight()
override void EEInit()
override float OnSound(CarSoundCtrl ctrl, float oldValue)
override bool IsVitalTruckBattery()
override int GetCrewIndex(string selection)
override bool CanReleaseAttachment(EntityAI attachment)
override void OnEngineStart()
override string GetAnimSourceFromSelection(string selection)
override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
override protected bool CanManipulateSpareWheel(string slotSelectionName)
override string GetDoorConditionPointFromSelection(string selection)
override string GetDoorSelectionNameFromSeatPos(int posIdx)
override int GetSeatAnimationType(int posIdx)
override string GetDoorInvSlotNameFromSeatPos(int posIdx)
override void SetActions()
void OffroadHatchback()
override void OnEngineStop()
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition EnMath.c:7
override void OnDebugSpawn()
original Timer deletes m_params which is unwanted
float m_TemperatureMax
min temperature you can get from the TemperatureSource
float m_RangeFull
temperature cap that will limit the return value from GetTemperature method
bool m_ManualUpdate
if the Update is running periodically
float m_TemperatureMin
how often the Update is ticking
float m_RangeMax
range where the full temperature is given to receiver
float m_TemperatureCap
max temperature you can get from the TemperatureSource
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
const int STATE_RUINED
Definition constants.c:742
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'.
bool Contains(string sample)
Returns true if sample is substring of string.
Definition EnString.c:286
proto int ToLower()
Changes string to lowercase. Returns length.