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