Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
hatchback_02.c
Go to the documentation of this file.
1 class Hatchback_02 extends CarScript
2 {
6 
7  void Hatchback_02()
8  {
9  //m_dmgContactCoef = 0.070;
10 
11  m_EngineStartOK = "Hatchback_02_engine_start_SoundSet";
12  m_EngineStartBattery = "Hatchback_02_engine_failed_start_battery_SoundSet";
13  m_EngineStartPlug = "Hatchback_02_engine_failed_start_sparkplugs_SoundSet";
14  m_EngineStartFuel = "Hatchback_02_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 
20  m_CarHornShortSoundName = "Hatchback_02_Horn_Short_SoundSet";
21  m_CarHornLongSoundName = "Hatchback_02_Horn_SoundSet";
22 
23  SetEnginePos("0 0.7 1.4");
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  {
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.GOLF;
79  }
80 
81  override int GetSeatAnimationType(int posIdx)
82  {
83  switch (posIdx)
84  {
85  case 0:
86  return DayZPlayerConstants.VEHICLESEAT_DRIVER;
87  case 1:
88  return DayZPlayerConstants.VEHICLESEAT_CODRIVER;
89  case 2:
90  return DayZPlayerConstants.VEHICLESEAT_PASSENGER_L;
91  case 3:
92  return DayZPlayerConstants.VEHICLESEAT_PASSENGER_R;
93  }
94 
95  return 0;
96  }
97 
98  // Override for car-specific light type
100  {
101  return CarRearLightBase.Cast(ScriptedLightBase.CreateLight(Hatchback_02RearLight));
102  }
103 
104  // Override for car-specific light type
105  override CarLightBase CreateFrontLight()
106  {
107  return CarLightBase.Cast(ScriptedLightBase.CreateLight(Hatchback_02FrontLight));
108  }
109 
110  override bool CanReleaseAttachment(EntityAI attachment)
111  {
112  if (!super.CanReleaseAttachment(attachment))
113  {
114  return false;
115  }
116 
117  if (EngineIsOn() || GetCarDoorsState("Hatchback_02_Hood") == CarDoorState.DOORS_CLOSED)
118  {
119  string attType = attachment.GetType();
120  if (attType == "CarRadiator" || attType == "CarBattery" || attType == "SparkPlug")
121  {
122  return false;
123  }
124  }
125 
126  return true;
127  }
128 
129  override protected bool CanManipulateSpareWheel(string slotSelectionName)
130  {
131  return GetCarDoorsState("Hatchback_02_Trunk") != CarDoorState.DOORS_CLOSED;
132  }
133 
134  override bool CanDisplayAttachmentCategory( string category_name )
135  {
136  //super
137  if ( !super.CanDisplayAttachmentCategory( category_name ) )
138  return false;
139  //
140 
141  category_name.ToLower();
142  if ( category_name.Contains("engine") )
143  {
144  if ( GetCarDoorsState("Hatchback_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("Hatchback_02_Trunk") == CarDoorState.DOORS_CLOSED )
157  return false;
158 
159  return true;
160  }
161 
162  override int GetCarDoorsState(string slotType)
163  {
164  CarDoor carDoor;
165 
166  Class.CastTo(carDoor, FindAttachmentBySlotName(slotType));
167  if (!carDoor)
168  {
169  return CarDoorState.DOORS_MISSING;
170  }
171 
172  switch (slotType)
173  {
174  case "Hatchback_02_Door_1_1":
175  return TranslateAnimationPhaseToCarDoorState("DoorsDriver");
176 
177  case "Hatchback_02_Door_2_1":
178  return TranslateAnimationPhaseToCarDoorState("DoorsCoDriver");
179 
180  case "Hatchback_02_Door_1_2":
181  return TranslateAnimationPhaseToCarDoorState("DoorsCargo1");
182 
183  case "Hatchback_02_Door_2_2":
184  return TranslateAnimationPhaseToCarDoorState("DoorsCargo2");
185 
186  case "Hatchback_02_Hood":
187  return TranslateAnimationPhaseToCarDoorState("DoorsHood");
188 
189  case "Hatchback_02_Trunk":
190  return TranslateAnimationPhaseToCarDoorState("DoorsTrunk");
191  }
192 
193  return CarDoorState.DOORS_MISSING;
194  }
195 
196 
197  override bool CrewCanGetThrough(int posIdx)
198  {
199  switch (posIdx)
200  {
201  case 0:
202  if (GetCarDoorsState("Hatchback_02_Door_1_1") == CarDoorState.DOORS_CLOSED)
203  {
204  return false;
205  }
206 
207  return true;
208 
209  case 1:
210  if (GetCarDoorsState("Hatchback_02_Door_2_1") == CarDoorState.DOORS_CLOSED)
211  {
212  return false;
213  }
214 
215  return true;
216 
217  case 2:
218  if (GetCarDoorsState("Hatchback_02_Door_1_2") == CarDoorState.DOORS_CLOSED)
219  {
220  return false;
221  }
222 
223  return true;
224 
225  case 3:
226  if (GetCarDoorsState("Hatchback_02_Door_2_2") == CarDoorState.DOORS_CLOSED)
227  {
228  return false;
229  }
230 
231  return true;
232  }
233 
234  return false;
235  }
236 
237  override string GetDoorSelectionNameFromSeatPos(int posIdx)
238  {
239  switch( posIdx )
240  {
241  case 0:
242  return "doors_driver";
243  break;
244  case 1:
245  return "doors_codriver";
246  break;
247  case 2:
248  return "doors_cargo1";
249  break;
250  case 3:
251  return "doors_cargo2";
252  break;
253  }
254 
255  return super.GetDoorSelectionNameFromSeatPos(posIdx);
256  }
257 
258  override string GetDoorInvSlotNameFromSeatPos(int posIdx)
259  {
260  switch( posIdx )
261  {
262  case 0:
263  return "Hatchback_02_Door_1_1";
264  break;
265  case 1:
266  return "Hatchback_02_Door_2_1";
267  break;
268  case 2:
269  return "Hatchback_02_Door_1_2";
270  break;
271  case 3:
272  return "Hatchback_02_Door_2_2";
273  break;
274  }
275 
276  return super.GetDoorInvSlotNameFromSeatPos(posIdx);
277  }
278 
279  override float OnSound(CarSoundCtrl ctrl, float oldValue)
280  {
281  switch (ctrl)
282  {
283  case CarSoundCtrl.DOORS:
284  float newValue = 0;
285  if (GetCarDoorsState("Hatchback_02_Door_1_1") == CarDoorState.DOORS_CLOSED)
286  {
287  newValue += 0.25;
288  }
289 
290  if (GetCarDoorsState("Hatchback_02_Door_2_1") == CarDoorState.DOORS_CLOSED)
291  {
292  newValue += 0.25;
293  }
294 
295  if (GetCarDoorsState("Hatchback_02_Door_1_2") == CarDoorState.DOORS_CLOSED)
296  {
297  newValue += 0.25;
298  }
299 
300  if (GetCarDoorsState("Hatchback_02_Door_2_2") == CarDoorState.DOORS_CLOSED)
301  {
302  newValue += 0.25;
303  }
304 
305  return Math.Clamp(newValue, 0, 1);
306  break;
307  }
308 
309  return super.OnSound(ctrl, oldValue);
310  }
311 
312  override string GetAnimSourceFromSelection( string selection )
313  {
314  switch( selection )
315  {
316  case "doors_driver":
317  return "DoorsDriver";
318  case "doors_codriver":
319  return "DoorsCoDriver";
320  case "doors_cargo1":
321  return "DoorsCargo1";
322  case "doors_cargo2":
323  return "DoorsCargo2";
324  case "doors_hood":
325  return "DoorsHood";
326  case "doors_trunk":
327  return "DoorsTrunk";
328  }
329 
330  return "";
331  }
332 
333 
334  override bool IsVitalTruckBattery()
335  {
336  return false;
337  }
338 
339  override bool IsVitalGlowPlug()
340  {
341  return false;
342  }
343 
344  override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
345  {
346  switch (currentSeat)
347  {
348  case 0:
349  return nextSeat == 1;
350  case 1:
351  return nextSeat == 0;
352  case 2:
353  return nextSeat == 3;
354  case 3:
355  return nextSeat == 2;
356  }
357 
358  return false;
359  }
360 
361  override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
362  {
363  switch (pCurrentSeat)
364  {
365  case 0:
366  return pDoorsSelection == "DoorsDriver";
367  case 1:
368  return pDoorsSelection == "DoorsCoDriver";
369  case 2:
370  return pDoorsSelection == "DoorsCargo1";
371  case 3:
372  return pDoorsSelection == "DoorsCargo2";
373  }
374 
375  return false;
376  }
377 
378  override void OnDebugSpawn()
379  {
382  FillUpCarFluids();
383 
384  GetInventory().CreateInInventory("Hatchback_02_Wheel");
385  GetInventory().CreateInInventory("Hatchback_02_Wheel");
386  GetInventory().CreateInInventory("Hatchback_02_Wheel");
387  GetInventory().CreateInInventory("Hatchback_02_Wheel");
388 
389  GetInventory().CreateInInventory("Hatchback_02_Door_1_1");
390  GetInventory().CreateInInventory("Hatchback_02_Door_1_2");
391  GetInventory().CreateInInventory("Hatchback_02_Door_2_1");
392  GetInventory().CreateInInventory("Hatchback_02_Door_2_2");
393  GetInventory().CreateInInventory("Hatchback_02_Hood");
394  GetInventory().CreateInInventory("Hatchback_02_Trunk");
395 
396  //-----IN CAR CARGO
397  GetInventory().CreateInInventory("Hatchback_02_Wheel");
398  GetInventory().CreateInInventory("Hatchback_02_Wheel");
399  }
400 }
401 
402 class Hatchback_02_Black extends Hatchback_02
403 {
404  override void OnDebugSpawn()
405  {
408  FillUpCarFluids();
409 
410  GetInventory().CreateInInventory("Hatchback_02_Wheel");
411  GetInventory().CreateInInventory("Hatchback_02_Wheel");
412  GetInventory().CreateInInventory("Hatchback_02_Wheel");
413  GetInventory().CreateInInventory("Hatchback_02_Wheel");
414 
415  GetInventory().CreateInInventory("Hatchback_02_Door_1_1_Black");
416  GetInventory().CreateInInventory("Hatchback_02_Door_1_2_Black");
417  GetInventory().CreateInInventory("Hatchback_02_Door_2_1_Black");
418  GetInventory().CreateInInventory("Hatchback_02_Door_2_2_Black");
419  GetInventory().CreateInInventory("Hatchback_02_Hood_Black");
420  GetInventory().CreateInInventory("Hatchback_02_Trunk_Black");
421 
422  //-----IN CAR CARGO
423  GetInventory().CreateInInventory("Hatchback_02_Wheel");
424  GetInventory().CreateInInventory("Hatchback_02_Wheel");
425  }
426 };
427 
428 class Hatchback_02_Blue extends Hatchback_02
429 {
430  override void OnDebugSpawn()
431  {
434  FillUpCarFluids();
435 
436  GetInventory().CreateInInventory("Hatchback_02_Wheel");
437  GetInventory().CreateInInventory("Hatchback_02_Wheel");
438  GetInventory().CreateInInventory("Hatchback_02_Wheel");
439  GetInventory().CreateInInventory("Hatchback_02_Wheel");
440 
441  GetInventory().CreateInInventory("Hatchback_02_Door_1_1_Blue");
442  GetInventory().CreateInInventory("Hatchback_02_Door_1_2_Blue");
443  GetInventory().CreateInInventory("Hatchback_02_Door_2_1_Blue");
444  GetInventory().CreateInInventory("Hatchback_02_Door_2_2_Blue");
445  GetInventory().CreateInInventory("Hatchback_02_Hood_Blue");
446  GetInventory().CreateInInventory("Hatchback_02_Trunk_Blue");
447 
448  //-----IN CAR CARGO
449  GetInventory().CreateInInventory("Hatchback_02_Wheel");
450  GetInventory().CreateInInventory("Hatchback_02_Wheel");
451  }
452 };
GetGame
proto native CGame GetGame()
CarDoor
Definition: inventoryitem.c:496
CanReachSeatFromSeat
override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
Definition: hatchback_02.c:343
UniversalTemperatureSourceLambdaEngine
Definition: universaltemperaturesourcelambdabaseimpl.c:62
CanDisplayAttachmentCategory
override bool CanDisplayAttachmentCategory(string category_name)
Definition: hatchback_02.c:133
m_CarDoorCloseSound
string m_CarDoorCloseSound
Definition: carscript.c:216
CanReachDoorsFromSeat
override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
Definition: hatchback_02.c:360
CanReleaseAttachment
override bool CanReleaseAttachment(EntityAI attachment)
Definition: hatchback_02.c:109
CanManipulateSpareWheel
override protected bool CanManipulateSpareWheel(string slotSelectionName)
Definition: hatchback_02.c:128
CarRearLightBase
Definition: civiliansedanrearlight.c:1
GetSeatAnimationType
override int GetSeatAnimationType(int posIdx)
Definition: hatchback_02.c:80
SpawnAdditionalItems
protected void SpawnAdditionalItems()
Definition: carscript.c:2670
OnEngineStop
override void OnEngineStop()
Definition: hatchback_02.c:54
GetDoorSelectionNameFromSeatPos
override string GetDoorSelectionNameFromSeatPos(int posIdx)
Definition: hatchback_02.c:236
CanDisplayCargo
override bool CanDisplayCargo()
Definition: hatchback_02.c:150
CreateRearLight
override CarRearLightBase CreateRearLight()
Definition: hatchback_02.c:98
EOnPostSimulate
override void EOnPostSimulate(IEntity other, float timeSlice)
Definition: hatchback_02.c:64
m_UTSource
protected ref UniversalTemperatureSource m_UTSource
Definition: hatchback_02.c:2
m_CarHornLongSoundName
string m_CarHornLongSoundName
Definition: carscript.c:221
m_UTSLEngine
protected ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
Definition: hatchback_02.c:4
GetCarDoorsState
override int GetCarDoorsState(string slotType)
Definition: hatchback_02.c:161
CarScript
Definition: civiliansedan.c:1
m_CarHornShortSoundName
string m_CarHornShortSoundName
Definition: carscript.c:220
OnEngineStart
override void OnEngineStart()
Definition: hatchback_02.c:44
IsVitalTruckBattery
override bool IsVitalTruckBattery()
Definition: hatchback_02.c:333
UniversalTemperatureSource
original Timer deletes m_params which is unwanted
Definition: universaltemperaturesource.c:25
CreateFrontLight
override CarLightBase CreateFrontLight()
Definition: hatchback_02.c:104
m_CarDoorOpenSound
string m_CarDoorOpenSound
Definition: carscript.c:215
CarSoundCtrl
CarSoundCtrl
Car's sound controller list. (native, do not change or extend)
Definition: car.c:3
Hatchback_02
Definition: hatchback_02.c:428
IEntity
Definition: enentity.c:164
Hatchback_02
void Hatchback_02()
Definition: hatchback_02.c:6
OnDebugSpawn
class Hatchback_02_Blue extends Hatchback_02 OnDebugSpawn
Definition: hatchback_02.c:404
UniversalTemperatureSourceSettings
Definition: universaltemperaturesource.c:1
GetAnimInstance
override int GetAnimInstance()
Definition: hatchback_02.c:75
EEInit
override void EEInit()
Definition: hatchback_02.c:25
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
CarDoorState
CarDoorState
Definition: carscript.c:1
ScriptedLightBase
Definition: pointlightbase.c:1
GetDoorInvSlotNameFromSeatPos
override string GetDoorInvSlotNameFromSeatPos(int posIdx)
Definition: hatchback_02.c:257
SpawnUniversalParts
protected void SpawnUniversalParts()
Definition: carscript.c:2632
m_UTSSettings
protected ref UniversalTemperatureSourceSettings m_UTSSettings
Definition: hatchback_02.c:3
m_EngineStopFuel
string m_EngineStopFuel
Definition: carscript.c:213
OnSound
override float OnSound(CarSoundCtrl ctrl, float oldValue)
Definition: hatchback_02.c:278
CarLightBase
Definition: carrearlightbase.c:1
GetAnimSourceFromSelection
override string GetAnimSourceFromSelection(string selection)
Definition: hatchback_02.c:311
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
CrewCanGetThrough
override bool CrewCanGetThrough(int posIdx)
Definition: hatchback_02.c:196
VehicleAnimInstances
VehicleAnimInstances
Definition: vehicleaniminstances.c:1
m_EngineStartPlug
string m_EngineStartPlug
Definition: carscript.c:211
IsVitalGlowPlug
override bool IsVitalGlowPlug()
Definition: hatchback_02.c:338
Math
Definition: enmath.c:6
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