Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
offroadhatchback.c
Go to the documentation of this file.
1 class OffroadHatchback extends CarScript
2 {
6 
7  void OffroadHatchback()
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  {
35  m_UTSSettings.m_ManualUpdate = true;
36  m_UTSSettings.m_TemperatureMin = 0;
37  m_UTSSettings.m_TemperatureMax = 30;
38  m_UTSSettings.m_RangeFull = 0.5;
39  m_UTSSettings.m_RangeMax = 2;
40  m_UTSSettings.m_TemperatureCap = 25;
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 
83  override float GetTransportCameraDistance()
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 
112  override CarLightBase CreateFrontLight()
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  {
452  FillUpCarFluids();
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 
470 class OffroadHatchback_White extends OffroadHatchback
471 {
472  override void OnDebugSpawn()
473  {
476  FillUpCarFluids();
477 
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 
494 class OffroadHatchback_Blue extends OffroadHatchback
495 {
496  override void OnDebugSpawn()
497  {
500  FillUpCarFluids();
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 }
GetGame
proto native CGame GetGame()
CarDoor
Definition: inventoryitem.c:496
GetAnimInstance
override int GetAnimInstance()
Definition: offroadhatchback.c:77
OffroadHatchback
void OffroadHatchback()
Definition: offroadhatchback.c:6
UniversalTemperatureSourceLambdaEngine
Definition: universaltemperaturesourcelambdabaseimpl.c:62
m_CarDoorCloseSound
string m_CarDoorCloseSound
Definition: carscript.c:216
GetAnimSourceFromSelection
override string GetAnimSourceFromSelection(string selection)
Definition: offroadhatchback.c:320
CanReachSeatFromSeat
override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
Definition: offroadhatchback.c:381
GetDoorInvSlotNameFromSeatPos
override string GetDoorInvSlotNameFromSeatPos(int posIdx)
Definition: offroadhatchback.c:258
IsVitalGlowPlug
override bool IsVitalGlowPlug()
Definition: offroadhatchback.c:376
SetActions
override void SetActions()
Definition: offroadhatchback.c:440
m_UTSLEngine
protected ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
Definition: offroadhatchback.c:4
CarRearLightBase
Definition: civiliansedanrearlight.c:1
SpawnAdditionalItems
protected void SpawnAdditionalItems()
Definition: carscript.c:2670
CanManipulateSpareWheel
override protected bool CanManipulateSpareWheel(string slotSelectionName)
Definition: offroadhatchback.c:135
m_CarHornLongSoundName
string m_CarHornLongSoundName
Definition: carscript.c:221
CarScript
Definition: civiliansedan.c:1
m_CarHornShortSoundName
string m_CarHornShortSoundName
Definition: carscript.c:220
CreateFrontLight
override CarLightBase CreateFrontLight()
Definition: offroadhatchback.c:111
UniversalTemperatureSource
original Timer deletes m_params which is unwanted
Definition: universaltemperaturesource.c:25
EEInit
override void EEInit()
Definition: offroadhatchback.c:27
m_CarSeatShiftOutSound
string m_CarSeatShiftOutSound
Definition: carscript.c:218
m_CarDoorOpenSound
string m_CarDoorOpenSound
Definition: carscript.c:215
m_UTSource
protected ref UniversalTemperatureSource m_UTSource
Definition: offroadhatchback.c:2
GetDoorSelectionNameFromSeatPos
override string GetDoorSelectionNameFromSeatPos(int posIdx)
Definition: offroadhatchback.c:243
CarSoundCtrl
CarSoundCtrl
Car's sound controller list. (native, do not change or extend)
Definition: car.c:3
EOnPostSimulate
override void EOnPostSimulate(IEntity other, float timeSlice)
Definition: offroadhatchback.c:66
IEntity
Definition: enentity.c:164
GetTransportCameraDistance
override float GetTransportCameraDistance()
Definition: offroadhatchback.c:82
ActionAnimateSeats
Definition: actionanimateseats.c:1
GetSeatIndexFromDoor
override int GetSeatIndexFromDoor(string pDoorSelection)
Definition: offroadhatchback.c:427
OnEngineStart
override void OnEngineStart()
Definition: offroadhatchback.c:46
UniversalTemperatureSourceSettings
Definition: universaltemperaturesource.c:1
IsVitalTruckBattery
override bool IsVitalTruckBattery()
Definition: offroadhatchback.c:371
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
CarDoorState
CarDoorState
Definition: carscript.c:1
GetCrewIndex
override int GetCrewIndex(string selection)
Definition: offroadhatchback.c:358
OffroadHatchback
Definition: offroadhatchback.c:494
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
ScriptedLightBase
Definition: pointlightbase.c:1
CanReleaseAttachment
override bool CanReleaseAttachment(EntityAI attachment)
Definition: offroadhatchback.c:116
GetSeatAnimationType
override int GetSeatAnimationType(int posIdx)
Definition: offroadhatchback.c:87
OnDebugSpawn
class OffroadHatchback extends CarScript OnDebugSpawn()
Definition: offroadhatchback.c:472
CanDisplayCargo
override bool CanDisplayCargo()
Definition: offroadhatchback.c:159
SpawnUniversalParts
protected void SpawnUniversalParts()
Definition: carscript.c:2632
m_EngineStopFuel
string m_EngineStopFuel
Definition: carscript.c:213
CanDisplayAttachmentCategory
override bool CanDisplayAttachmentCategory(string category_name)
Definition: offroadhatchback.c:140
CarLightBase
Definition: carrearlightbase.c:1
m_EngineStartBattery
string m_EngineStartBattery
Definition: carscript.c:210
FillUpCarFluids
protected void FillUpCarFluids()
Definition: carscript.c:2700
TranslateAnimationPhaseToCarDoorState
CarDoorState TranslateAnimationPhaseToCarDoorState(string animation)
Definition: carscript.c:2336
GameConstants
Definition: constants.c:612
VehicleAnimInstances
VehicleAnimInstances
Definition: vehicleaniminstances.c:1
OnEngineStop
override void OnEngineStop()
Definition: offroadhatchback.c:56
m_EngineStartPlug
string m_EngineStartPlug
Definition: carscript.c:211
OnSound
override float OnSound(CarSoundCtrl ctrl, float oldValue)
Definition: offroadhatchback.c:275
CanReachDoorsFromSeat
override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
Definition: offroadhatchback.c:407
GetDoorConditionPointFromSelection
override string GetDoorConditionPointFromSelection(string selection)
Definition: offroadhatchback.c:341
m_UTSSettings
protected ref UniversalTemperatureSourceSettings m_UTSSettings
Definition: offroadhatchback.c:3
Math
Definition: enmath.c:6
m_CarSeatShiftInSound
string m_CarSeatShiftInSound
Definition: carscript.c:217
GetCarDoorsState
override int GetCarDoorsState(string slotType)
Definition: offroadhatchback.c:174
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_EngineStartFuel
string m_EngineStartFuel
Definition: carscript.c:212
m_EngineStartOK
string m_EngineStartOK
Sounds.
Definition: carscript.c:209
EntityAI
Definition: building.c:5
CreateRearLight
override CarRearLightBase CreateRearLight()
Definition: offroadhatchback.c:106
CrewCanGetThrough
override bool CrewCanGetThrough(int posIdx)
Definition: offroadhatchback.c:202