Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
sedan_02.c
Go to the documentation of this file.
1 class Sedan_02 extends CarScript
2 {
6 
7  void Sedan_02()
8  {
9  m_dmgContactCoef = 0.0790;
10 
11  m_EngineStartOK = "Sedan_02_engine_start_SoundSet";
12  m_EngineStartBattery = "Sedan_02_engine_failed_start_battery_SoundSet";
13  m_EngineStartPlug = "Sedan_02_engine_failed_start_sparkplugs_SoundSet";
14  m_EngineStartFuel = "Sedan_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 = "Sedan_02_Horn_Short_SoundSet";
21  m_CarHornLongSoundName = "Sedan_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  {
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.S120;
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 CarLightBase.Cast(ScriptedLightBase.CreateLight(Sedan_02FrontLight));
102  }
103 
104  // Override for car-specific light type
106  {
107  return CarRearLightBase.Cast(ScriptedLightBase.CreateLight(Sedan_02RearLight));
108  }
109 
110  override bool CanReleaseAttachment( EntityAI attachment )
111  {
112  if (!super.CanReleaseAttachment(attachment))
113  {
114  return false;
115  }
116 
117  string attType = attachment.GetType();
118  switch (attType)
119  {
120  case "CarBattery":
121  if (GetCarDoorsState("Sedan_02_Trunk") == CarDoorState.DOORS_CLOSED || EngineIsOn())
122  {
123  return false;
124  }
125  break;
126 
127  case "SparkPlug":
128  if (GetCarDoorsState("Sedan_02_Trunk") == CarDoorState.DOORS_CLOSED || EngineIsOn())
129  {
130  return false;
131  }
132  break;
133 
134  case "CarRadiator":
135  if (GetCarDoorsState("Sedan_02_Hood") == CarDoorState.DOORS_CLOSED || EngineIsOn())
136  {
137  return false;
138  }
139  break;
140  }
141 
142  return true;
143  }
144 
145  override protected bool CanManipulateSpareWheel(string slotSelectionName)
146  {
147  return GetCarDoorsState("Sedan_02_Hood") != CarDoorState.DOORS_CLOSED;
148  }
149 
150  override bool CanDisplayAttachmentCategory(string category_name)
151  {
152  if ( !super.CanDisplayAttachmentCategory(category_name))
153  {
154  return false;
155  }
156 
157  category_name.ToLower();
158  if (category_name.Contains("engine"))
159  {
160  if (GetCarDoorsState("Sedan_02_Trunk") == CarDoorState.DOORS_CLOSED)
161  {
162  return false;
163  }
164  }
165 
166  if (category_name.Contains("trunk"))
167  {
168  if (GetCarDoorsState("Sedan_02_Hood") == CarDoorState.DOORS_CLOSED)
169  {
170  return false;
171  }
172  }
173 
174  return true;
175  }
176 
177  override bool CanDisplayCargo()
178  {
179  if ( !super.CanDisplayCargo() )
180  return false;
181 
182  if ( GetCarDoorsState("Sedan_02_Hood") == CarDoorState.DOORS_CLOSED )
183  return false;
184 
185  return true;
186  }
187 
188  override int GetCarDoorsState(string slotType)
189  {
190  CarDoor carDoor;
191 
192  Class.CastTo( carDoor, FindAttachmentBySlotName( slotType ) );
193  if (!carDoor)
194  {
195  return CarDoorState.DOORS_MISSING;
196  }
197 
198  switch (slotType)
199  {
200  case "Sedan_02_Door_1_1":
201  return TranslateAnimationPhaseToCarDoorState("DoorsDriver");
202 
203  case "Sedan_02_Door_2_1":
204  return TranslateAnimationPhaseToCarDoorState("DoorsCoDriver");
205 
206  case "Sedan_02_Door_1_2":
207  return TranslateAnimationPhaseToCarDoorState("DoorsCargo1");
208 
209  case "Sedan_02_Door_2_2":
210  return TranslateAnimationPhaseToCarDoorState("DoorsCargo2");
211 
212  case "Sedan_02_Hood":
213  return TranslateAnimationPhaseToCarDoorState("DoorsHood");
214 
215  case "Sedan_02_Trunk":
216  return TranslateAnimationPhaseToCarDoorState("DoorsTrunk");
217  }
218 
219  return CarDoorState.DOORS_MISSING;
220  }
221 
222 
223  override bool CrewCanGetThrough( int posIdx )
224  {
225  switch( posIdx )
226  {
227  case 0:
228  if ( GetCarDoorsState("Sedan_02_Door_1_1") == CarDoorState.DOORS_CLOSED )
229  return false;
230 
231  return true;
232  break;
233 
234  case 1:
235  if ( GetCarDoorsState("Sedan_02_Door_2_1") == CarDoorState.DOORS_CLOSED )
236  return false;
237 
238  return true;
239  break;
240 
241  case 2:
242  if ( GetCarDoorsState("Sedan_02_Door_1_2") == CarDoorState.DOORS_CLOSED )
243  return false;
244 
245  return true;
246  break;
247 
248  case 3:
249  if ( GetCarDoorsState("Sedan_02_Door_2_2") == CarDoorState.DOORS_CLOSED )
250  return false;
251 
252  return true;
253  break;
254  }
255 
256  return false;
257  }
258 
259  override string GetDoorSelectionNameFromSeatPos(int posIdx)
260  {
261  switch( posIdx )
262  {
263  case 0:
264  return "doors_driver";
265  break;
266  case 1:
267  return "doors_codriver";
268  break;
269  case 2:
270  return "doors_cargo1";
271  break;
272  case 3:
273  return "doors_cargo2";
274  break;
275  }
276 
277  return super.GetDoorSelectionNameFromSeatPos(posIdx);
278  }
279 
280  override string GetDoorInvSlotNameFromSeatPos(int posIdx)
281  {
282  switch( posIdx )
283  {
284  case 0:
285  return "Sedan_02_Door_1_1";
286  break;
287  case 1:
288  return "Sedan_02_Door_2_1";
289  break;
290  case 2:
291  return "Sedan_02_Door_1_2";
292  break;
293  case 3:
294  return "Sedan_02_Door_2_2";
295  break;
296  }
297 
298  return super.GetDoorInvSlotNameFromSeatPos(posIdx);
299  }
300 
301  override float OnSound(CarSoundCtrl ctrl, float oldValue)
302  {
303  switch ( ctrl )
304  {
305  case CarSoundCtrl.DOORS:
306  float newValue = 0;
307  if (GetCarDoorsState("Sedan_02_Door_1_1") == CarDoorState.DOORS_CLOSED)
308  {
309  newValue += 0.25;
310  }
311 
312  if (GetCarDoorsState("Sedan_02_Door_2_1") == CarDoorState.DOORS_CLOSED)
313  {
314  newValue += 0.25;
315  }
316 
317  if (GetCarDoorsState("Sedan_02_Door_1_2") == CarDoorState.DOORS_CLOSED)
318  {
319  newValue += 0.25;
320  }
321 
322  if (GetCarDoorsState("Sedan_02_Door_2_2") == CarDoorState.DOORS_CLOSED)
323  {
324  newValue += 0.25;
325  }
326 
327  return Math.Clamp(newValue, 0, 1);
328  break;
329  }
330 
331  return super.OnSound(ctrl, oldValue);
332  }
333 
334  override string GetAnimSourceFromSelection( string selection )
335  {
336  switch( selection )
337  {
338  case "doors_driver":
339  return "DoorsDriver";
340  case "doors_codriver":
341  return "DoorsCoDriver";
342  case "doors_cargo1":
343  return "DoorsCargo1";
344  case "doors_cargo2":
345  return "DoorsCargo2";
346  case "doors_hood":
347  return "DoorsHood";
348  case "doors_trunk":
349  return "DoorsTrunk";
350  }
351 
352  return "";
353  }
354 
355 
356  override bool IsVitalTruckBattery()
357  {
358  return false;
359  }
360 
361  override bool IsVitalGlowPlug()
362  {
363  return false;
364  }
365 
366  override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
367  {
368  switch (currentSeat)
369  {
370  case 0:
371  return nextSeat == 1;
372 
373  case 1:
374  return nextSeat == 0;
375 
376  case 2:
377  return nextSeat == 3;
378 
379  case 3:
380  return nextSeat == 2;
381  }
382 
383  return false;
384  }
385 
386  override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
387  {
388  switch (pCurrentSeat)
389  {
390  case 0:
391  return pDoorsSelection == "DoorsDriver";
392 
393  case 1:
394  return pDoorsSelection == "DoorsCoDriver";
395 
396  case 2:
397  return pDoorsSelection == "DoorsCargo1";
398 
399  case 3:
400  return pDoorsSelection == "DoorsCargo2";
401  }
402 
403  return false;
404  }
405 
406  override void OnDebugSpawn()
407  {
410  FillUpCarFluids();
411 
412  GetInventory().CreateInInventory("Sedan_02_Wheel");
413  GetInventory().CreateInInventory("Sedan_02_Wheel");
414  GetInventory().CreateInInventory("Sedan_02_Wheel");
415  GetInventory().CreateInInventory("Sedan_02_Wheel");
416  GetInventory().CreateInInventory("Sedan_02_Wheel");
417 
418  GetInventory().CreateInInventory("Sedan_02_Door_1_1");
419  GetInventory().CreateInInventory("Sedan_02_Door_1_2");
420  GetInventory().CreateInInventory("Sedan_02_Door_2_1");
421  GetInventory().CreateInInventory("Sedan_02_Door_2_2");
422  GetInventory().CreateInInventory("Sedan_02_Hood");
423  GetInventory().CreateInInventory("Sedan_02_Trunk");
424 
425  //-----IN CAR CARGO
426  GetInventory().CreateInInventory("Sedan_02_Wheel");
427  GetInventory().CreateInInventory("Sedan_02_Wheel");
428  }
429 }
430 
431 class Sedan_02_Red extends Sedan_02
432 {
433  override void OnDebugSpawn()
434  {
437  FillUpCarFluids();
438 
439  GetInventory().CreateInInventory("Sedan_02_Wheel");
440  GetInventory().CreateInInventory("Sedan_02_Wheel");
441  GetInventory().CreateInInventory("Sedan_02_Wheel");
442  GetInventory().CreateInInventory("Sedan_02_Wheel");
443 
444  GetInventory().CreateInInventory("Sedan_02_Door_1_1_Red");
445  GetInventory().CreateInInventory("Sedan_02_Door_1_2_Red");
446  GetInventory().CreateInInventory("Sedan_02_Door_2_1_Red");
447  GetInventory().CreateInInventory("Sedan_02_Door_2_2_Red");
448  GetInventory().CreateInInventory("Sedan_02_Hood_Red");
449  GetInventory().CreateInInventory("Sedan_02_Trunk_Red");
450 
451  //-----IN CAR CARGO
452  GetInventory().CreateInInventory("Sedan_02_Wheel");
453  GetInventory().CreateInInventory("Sedan_02_Wheel");
454  }
455 }
456 
457 class Sedan_02_Grey extends Sedan_02
458 {
459  override void OnDebugSpawn()
460  {
463  FillUpCarFluids();
464 
465  GetInventory().CreateInInventory("Sedan_02_Wheel");
466  GetInventory().CreateInInventory("Sedan_02_Wheel");
467  GetInventory().CreateInInventory("Sedan_02_Wheel");
468  GetInventory().CreateInInventory("Sedan_02_Wheel");
469 
470  GetInventory().CreateInInventory("Sedan_02_Door_1_1_Grey");
471  GetInventory().CreateInInventory("Sedan_02_Door_1_2_Grey");
472  GetInventory().CreateInInventory("Sedan_02_Door_2_1_Grey");
473  GetInventory().CreateInInventory("Sedan_02_Door_2_2_Grey");
474  GetInventory().CreateInInventory("Sedan_02_Hood_Grey");
475  GetInventory().CreateInInventory("Sedan_02_Trunk_Grey");
476 
477  //-----IN CAR CARGO
478  GetInventory().CreateInInventory("Sedan_02_Wheel");
479  GetInventory().CreateInInventory("Sedan_02_Wheel");
480  }
481 }
GetGame
proto native CGame GetGame()
m_UTSLEngine
protected ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
Definition: sedan_02.c:4
CanManipulateSpareWheel
override protected bool CanManipulateSpareWheel(string slotSelectionName)
Definition: sedan_02.c:144
CarDoor
Definition: inventoryitem.c:496
OnEngineStart
override void OnEngineStart()
Definition: sedan_02.c:44
UniversalTemperatureSourceLambdaEngine
Definition: universaltemperaturesourcelambdabaseimpl.c:62
m_CarDoorCloseSound
string m_CarDoorCloseSound
Definition: carscript.c:216
GetDoorSelectionNameFromSeatPos
override string GetDoorSelectionNameFromSeatPos(int posIdx)
Definition: sedan_02.c:258
m_UTSource
protected ref UniversalTemperatureSource m_UTSource
Definition: sedan_02.c:2
Sedan_02
void Sedan_02()
Definition: sedan_02.c:6
CarRearLightBase
Definition: civiliansedanrearlight.c:1
SpawnAdditionalItems
protected void SpawnAdditionalItems()
Definition: carscript.c:2670
m_CarHornLongSoundName
string m_CarHornLongSoundName
Definition: carscript.c:221
CreateRearLight
override CarRearLightBase CreateRearLight()
Definition: sedan_02.c:104
CarScript
Definition: civiliansedan.c:1
OnDebugSpawn
class Sedan_02 extends CarScript OnDebugSpawn()
Definition: sedan_02.c:433
m_CarHornShortSoundName
string m_CarHornShortSoundName
Definition: carscript.c:220
CanReleaseAttachment
override bool CanReleaseAttachment(EntityAI attachment)
Definition: sedan_02.c:109
EEInit
override void EEInit()
Definition: sedan_02.c:25
OnSound
override float OnSound(CarSoundCtrl ctrl, float oldValue)
Definition: sedan_02.c:300
m_dmgContactCoef
protected float m_dmgContactCoef
Definition: carscript.c:161
UniversalTemperatureSource
original Timer deletes m_params which is unwanted
Definition: universaltemperaturesource.c:25
GetAnimSourceFromSelection
override string GetAnimSourceFromSelection(string selection)
Definition: sedan_02.c:333
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
Sedan_02
Definition: sedan_02.c:457
IEntity
Definition: enentity.c:164
CanDisplayCargo
override bool CanDisplayCargo()
Definition: sedan_02.c:176
CanDisplayAttachmentCategory
override bool CanDisplayAttachmentCategory(string category_name)
Definition: sedan_02.c:149
CreateFrontLight
override CarLightBase CreateFrontLight()
Definition: sedan_02.c:98
UniversalTemperatureSourceSettings
Definition: universaltemperaturesource.c:1
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
CarDoorState
CarDoorState
Definition: carscript.c:1
CanReachDoorsFromSeat
override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
Definition: sedan_02.c:385
ScriptedLightBase
Definition: pointlightbase.c:1
IsVitalGlowPlug
override bool IsVitalGlowPlug()
Definition: sedan_02.c:360
EOnPostSimulate
override void EOnPostSimulate(IEntity other, float timeSlice)
Definition: sedan_02.c:64
SpawnUniversalParts
protected void SpawnUniversalParts()
Definition: carscript.c:2632
CanReachSeatFromSeat
override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
Definition: sedan_02.c:365
m_EngineStopFuel
string m_EngineStopFuel
Definition: carscript.c:213
CarLightBase
Definition: carrearlightbase.c:1
CrewCanGetThrough
override bool CrewCanGetThrough(int posIdx)
Definition: sedan_02.c:222
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
OnEngineStop
override void OnEngineStop()
Definition: sedan_02.c:54
GetAnimInstance
override int GetAnimInstance()
Definition: sedan_02.c:75
IsVitalTruckBattery
override bool IsVitalTruckBattery()
Definition: sedan_02.c:355
GetCarDoorsState
override int GetCarDoorsState(string slotType)
Definition: sedan_02.c:187
VehicleAnimInstances
VehicleAnimInstances
Definition: vehicleaniminstances.c:1
m_EngineStartPlug
string m_EngineStartPlug
Definition: carscript.c:211
GetDoorInvSlotNameFromSeatPos
override string GetDoorInvSlotNameFromSeatPos(int posIdx)
Definition: sedan_02.c:279
GetSeatAnimationType
override int GetSeatAnimationType(int posIdx)
Definition: sedan_02.c:80
Math
Definition: enmath.c:6
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_UTSSettings
protected ref UniversalTemperatureSourceSettings m_UTSSettings
Definition: sedan_02.c:3
m_EngineStartFuel
string m_EngineStartFuel
Definition: carscript.c:212
m_EngineStartOK
string m_EngineStartOK
Sounds.
Definition: carscript.c:209
EntityAI
Definition: building.c:5