Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
offroad_02.c
Go to the documentation of this file.
1 class Offroad_02 extends CarScript
2 {
6 
7  void Offroad_02()
8  {
9  //m_dmgContactCoef = 0.0365;
10 
11  m_EngineStartOK = "Offroad_02_engine_start_SoundSet";
12  m_EngineStartBattery = "Offroad_02_engine_failed_start_battery_SoundSet";
13  m_EngineStartPlug = "Offroad_02_engine_failed_start_sparkplugs_SoundSet";
14  m_EngineStartFuel = "Offroad_02_engine_failed_start_fuel_SoundSet";
15  m_EngineStopFuel = "offroad_engine_stop_fuel_SoundSet";
16 
17  m_CarDoorOpenSound = "offroad_02_door_open_SoundSet";
18  m_CarDoorCloseSound = "offroad_02_door_close_SoundSet";
19 
20  m_CarHornShortSoundName = "Offroad_02_Horn_Short_SoundSet";
21  m_CarHornLongSoundName = "Offroad_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.HMMWV;
79  }
80 
81  override float GetTransportCameraDistance()
82  {
83  return 5.1;
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(Offroad_02FrontLight));
107  }
108 
109  // Override for car-specific light type
111  {
112  return CarRearLightBase.Cast(ScriptedLightBase.CreateLight(Offroad_02RearLight));
113  }
114 
115  override bool CanReleaseAttachment( EntityAI attachment )
116  {
117  if (!super.CanReleaseAttachment(attachment))
118  {
119  return false;
120  }
121 
122  string attType = attachment.GetType();
123  switch (attType)
124  {
125  case "CarBattery":
126  if (GetCarDoorsState("Offroad_02_Hood") == CarDoorState.DOORS_CLOSED || EngineIsOn())
127  {
128  return false;
129  }
130  break;
131 
132  case "GlowPlug":
133  if (GetCarDoorsState("Offroad_02_Hood") == CarDoorState.DOORS_CLOSED || EngineIsOn())
134  {
135  return false;
136  }
137  break;
138  }
139 
140  return true;
141  }
142 
143  override protected bool CanManipulateSpareWheel(string slotSelectionName)
144  {
145  return GetCarDoorsState("Offroad_02_Trunk") != CarDoorState.DOORS_CLOSED;
146  }
147 
148  override bool CanDisplayAttachmentCategory(string category_name)
149  {
150  if ( !super.CanDisplayAttachmentCategory(category_name))
151  {
152  return false;
153  }
154 
155  category_name.ToLower();
156  if (category_name.Contains("engine"))
157  {
158  if (GetCarDoorsState("Offroad_02_Hood") == CarDoorState.DOORS_CLOSED)
159  {
160  return false;
161  }
162  }
163 
164  return true;
165  }
166 
167  override bool CanDisplayCargo()
168  {
169  if ( !super.CanDisplayCargo() )
170  return false;
171 
172  if ( GetCarDoorsState("Offroad_02_Trunk") == CarDoorState.DOORS_CLOSED )
173  return false;
174 
175  return true;
176  }
177 
178  override int GetCarDoorsState(string slotType)
179  {
180  CarDoor carDoor;
181 
182  Class.CastTo( carDoor, FindAttachmentBySlotName( slotType ) );
183  if (!carDoor)
184  {
185  return CarDoorState.DOORS_MISSING;
186  }
187 
188  switch (slotType)
189  {
190  case "Offroad_02_Door_1_1":
191  return TranslateAnimationPhaseToCarDoorState("DoorsDriver");
192 
193  case "Offroad_02_Door_2_1":
194  return TranslateAnimationPhaseToCarDoorState("DoorsCoDriver");
195 
196  case "Offroad_02_Door_1_2":
197  return TranslateAnimationPhaseToCarDoorState("DoorsCargo1");
198 
199  case "Offroad_02_Door_2_2":
200  return TranslateAnimationPhaseToCarDoorState("DoorsCargo2");
201 
202  case "Offroad_02_Hood":
203  return TranslateAnimationPhaseToCarDoorState("DoorsHood");
204 
205  case "Offroad_02_Trunk":
206  return TranslateAnimationPhaseToCarDoorState("DoorsTrunk");
207  }
208 
209  return CarDoorState.DOORS_MISSING;
210  }
211 
212 
213  override bool CrewCanGetThrough( int posIdx )
214  {
215  switch( posIdx )
216  {
217  case 0:
218  if ( GetCarDoorsState("Offroad_02_Door_1_1") == CarDoorState.DOORS_CLOSED )
219  return false;
220 
221  return true;
222  break;
223 
224  case 1:
225  if ( GetCarDoorsState("Offroad_02_Door_2_1") == CarDoorState.DOORS_CLOSED )
226  return false;
227 
228  return true;
229  break;
230 
231  case 2:
232  if ( GetCarDoorsState("Offroad_02_Door_1_2") == CarDoorState.DOORS_CLOSED )
233  return false;
234 
235  return true;
236  break;
237 
238  case 3:
239  if ( GetCarDoorsState("Offroad_02_Door_2_2") == CarDoorState.DOORS_CLOSED )
240  return false;
241 
242  return true;
243  break;
244  }
245 
246  return false;
247  }
248 
249  override string GetDoorSelectionNameFromSeatPos(int posIdx)
250  {
251  switch( posIdx )
252  {
253  case 0:
254  return "doors_driver";
255  break;
256  case 1:
257  return "doors_codriver";
258  break;
259  case 2:
260  return "doors_cargo1";
261  break;
262  case 3:
263  return "doors_cargo2";
264  break;
265  }
266 
267  return super.GetDoorSelectionNameFromSeatPos(posIdx);
268  }
269 
270  override string GetDoorInvSlotNameFromSeatPos(int posIdx)
271  {
272  switch (posIdx)
273  {
274  case 0:
275  return "Offroad_02_Door_1_1";
276  case 1:
277  return "Offroad_02_Door_2_1";
278  case 2:
279  return "Offroad_02_Door_1_2";
280  case 3:
281  return "Offroad_02_Door_2_2";
282  }
283 
284  return super.GetDoorInvSlotNameFromSeatPos(posIdx);
285  }
286 
287  override float OnSound(CarSoundCtrl ctrl, float oldValue)
288  {
289  switch ( ctrl )
290  {
291  case CarSoundCtrl.DOORS:
292  float newValue = 0;
293  if (GetCarDoorsState("Offroad_02_Door_1_1") == CarDoorState.DOORS_CLOSED)
294  {
295  newValue += 0.25;
296  }
297 
298  if (GetCarDoorsState("Offroad_02_Door_2_1") == CarDoorState.DOORS_CLOSED)
299  {
300  newValue += 0.25;
301  }
302 
303  if (GetCarDoorsState("Offroad_02_Door_1_2") == CarDoorState.DOORS_CLOSED)
304  {
305  newValue += 0.25;
306  }
307 
308  if (GetCarDoorsState("Offroad_02_Door_2_2") == CarDoorState.DOORS_CLOSED)
309  {
310  newValue += 0.25;
311  }
312 
313  return Math.Clamp(newValue, 0, 1);
314  break;
315  }
316 
317  return super.OnSound(ctrl, oldValue);
318  }
319 
320  override string GetAnimSourceFromSelection(string selection)
321  {
322  switch (selection)
323  {
324  case "doors_driver":
325  return "DoorsDriver";
326  case "doors_codriver":
327  return "DoorsCoDriver";
328  case "doors_cargo1":
329  return "DoorsCargo1";
330  case "doors_cargo2":
331  return "DoorsCargo2";
332  case "doors_hood":
333  return "DoorsHood";
334  case "doors_trunk":
335  return "DoorsTrunk";
336  }
337 
338  return "";
339  }
340 
341  override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
342  {
343  switch (currentSeat)
344  {
345  case 0:
346  return nextSeat == 1;
347  case 1:
348  return nextSeat == 0;
349  case 2:
350  return nextSeat == 3;
351  case 3:
352  return nextSeat == 2;
353  }
354 
355  return false;
356  }
357 
358  override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
359  {
360  switch (pCurrentSeat)
361  {
362  case 0:
363  return pDoorsSelection == "DoorsDriver";
364  case 1:
365  return pDoorsSelection == "DoorsCoDriver";
366  case 2:
367  return pDoorsSelection == "DoorsCargo1";
368  case 3:
369  return pDoorsSelection == "DoorsCargo2";
370  }
371 
372  return false;
373  }
374 
375  override bool IsVitalTruckBattery()
376  {
377  return false;
378  }
379 
380  override bool IsVitalSparkPlug()
381  {
382  return false;
383  }
384 
385  override bool IsVitalRadiator()
386  {
387  return false;
388  }
389 
390  override void OnDebugSpawn()
391  {
394  FillUpCarFluids();
395 
396  GetInventory().CreateInInventory("Offroad_02_Wheel");
397  GetInventory().CreateInInventory("Offroad_02_Wheel");
398  GetInventory().CreateInInventory("Offroad_02_Wheel");
399  GetInventory().CreateInInventory("Offroad_02_Wheel");
400 
401  GetInventory().CreateInInventory("Offroad_02_Door_1_1");
402  GetInventory().CreateInInventory("Offroad_02_Door_1_2");
403  GetInventory().CreateInInventory("Offroad_02_Door_2_1");
404  GetInventory().CreateInInventory("Offroad_02_Door_2_2");
405  GetInventory().CreateInInventory("Offroad_02_Hood");
406  GetInventory().CreateInInventory("Offroad_02_Trunk");
407 
408  //-----IN CAR CARGO
409  GetInventory().CreateInInventory("Offroad_02_Wheel");
410  GetInventory().CreateInInventory("Offroad_02_Wheel");
411  }
412 }
GetGame
proto native CGame GetGame()
m_UTSource
protected ref UniversalTemperatureSource m_UTSource
Definition: fireplacebase.c:224
CarDoor
Definition: inventoryitem.c:496
OnSound
override float OnSound(CarSoundCtrl ctrl, float oldValue)
Definition: carscript.c:1301
UniversalTemperatureSourceLambdaEngine
Definition: universaltemperaturesourcelambdabaseimpl.c:62
m_CarDoorCloseSound
string m_CarDoorCloseSound
Definition: carscript.c:216
OnEngineStart
override void OnEngineStart()
Gets called everytime the engine starts.
Definition: carscript.c:1612
CreateRearLight
protected CarRearLightBase CreateRearLight()
Definition: carscript.c:2067
CarRearLightBase
Definition: civiliansedanrearlight.c:1
SpawnAdditionalItems
protected void SpawnAdditionalItems()
Definition: carscript.c:2670
CrewCanGetThrough
override bool CrewCanGetThrough(int posIdx)
Definition: civiliansedan.c:204
m_CarHornLongSoundName
string m_CarHornLongSoundName
Definition: carscript.c:221
CreateFrontLight
protected CarLightBase CreateFrontLight()
Definition: carscript.c:2073
CanReleaseAttachment
override bool CanReleaseAttachment(EntityAI attachment)
Definition: fireplacebase.c:2654
CarScript
Definition: civiliansedan.c:1
GetAnimSourceFromSelection
string GetAnimSourceFromSelection(string selection)
Definition: carscript.c:2199
GetAnimInstance
override int GetAnimInstance()
Definition: civiliansedan.c:75
m_CarHornShortSoundName
string m_CarHornShortSoundName
Definition: carscript.c:220
UniversalTemperatureSource
original Timer deletes m_params which is unwanted
Definition: universaltemperaturesource.c:25
GetCarDoorsState
int GetCarDoorsState(string slotType)
Definition: carscript.c:2331
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
GetTransportCameraDistance
override float GetTransportCameraDistance()
Definition: civiliansedan.c:80
m_UTSSettings
protected ref UniversalTemperatureSourceSettings m_UTSSettings
Definition: fireplacebase.c:225
IEntity
Definition: enentity.c:164
OnDebugSpawn
class Hatchback_02_Blue extends Hatchback_02 OnDebugSpawn
Definition: hatchback_02.c:404
CanManipulateSpareWheel
protected bool CanManipulateSpareWheel(string slotSelectionName)
Definition: carscript.c:843
UniversalTemperatureSourceSettings
Definition: universaltemperaturesource.c:1
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
CarDoorState
CarDoorState
Definition: carscript.c:1
GetDoorSelectionNameFromSeatPos
string GetDoorSelectionNameFromSeatPos(int posIdx)
Definition: carscript.c:2225
IsVitalTruckBattery
bool IsVitalTruckBattery()
Definition: carscript.c:2269
ScriptedLightBase
Definition: pointlightbase.c:1
IsVitalRadiator
bool IsVitalRadiator()
Definition: carscript.c:2289
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
EOnPostSimulate
override void EOnPostSimulate(IEntity other, float timeSlice)
Definition: land_underground_waterreservoir.c:166
GetDoorInvSlotNameFromSeatPos
string GetDoorInvSlotNameFromSeatPos(int posIdx)
Definition: carscript.c:2230
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
CanDisplayCargo
override bool CanDisplayCargo()
Definition: itembase.c:3998
EEInit
override void EEInit()
Definition: contaminatedarea.c:27
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
Math
Definition: enmath.c:6
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
IsVitalSparkPlug
bool IsVitalSparkPlug()
Definition: carscript.c:2274
m_EngineStartFuel
string m_EngineStartFuel
Definition: carscript.c:212
m_EngineStartOK
string m_EngineStartOK
Sounds.
Definition: carscript.c:209
EntityAI
Definition: building.c:5
OnEngineStop
override void OnEngineStop()
Gets called everytime the engine stops.
Definition: carscript.c:1628