Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
truck_01_base.c
Go to the documentation of this file.
1 class Truck_01_Base extends CarScript
2 {
6 
7  void Truck_01_Base()
8  {
9  //m_dmgContactCoef = 0.018;
10  m_enginePtcPos = "0 1.346 2.205";
11 
12  m_EngineStartOK = "Truck_01_engine_start_SoundSet";
13  m_EngineStartBattery = "Truck_01_engine_failed_start_battery_SoundSet";
14  m_EngineStartPlug = "Truck_01_engine_failed_start_sparkplugs_SoundSet";
15  m_EngineStartFuel = "Truck_01_engine_failed_start_fuel_SoundSet";
16  m_EngineStopFuel = "Truck_01_engine_stop_fuel_SoundSet";
17 
18  m_CarDoorOpenSound = "Truck_01_door_open_SoundSet";
19  m_CarDoorCloseSound = "Truck_01_door_close_SoundSet";
20 
21  m_CarHornShortSoundName = "Truck_01_Horn_Short_SoundSet";
22  m_CarHornLongSoundName = "Truck_01_Horn_SoundSet";
23 
24  SetEnginePos("0 1.4 2.25");
25  }
26 
27  override void EEInit()
28  {
29  super.EEInit();
30 
31  if (GetGame().IsServer() || !GetGame().IsMultiplayer())
32  {
34  m_UTSSettings.m_ManualUpdate = true;
35  m_UTSSettings.m_TemperatureMin = 0;
36  m_UTSSettings.m_TemperatureMax = 30;
37  m_UTSSettings.m_RangeFull = 0.5;
38  m_UTSSettings.m_RangeMax = 2;
39  m_UTSSettings.m_TemperatureCap = 25;
40 
43  }
44  }
45 
46  override void OnEngineStart()
47  {
48  super.OnEngineStart();
49 
50  if (GetGame().IsServer() || !GetGame().IsMultiplayer())
51  {
52  m_UTSource.SetDefferedActive(true, 20.0);
53  }
54  }
55 
56  override void OnEngineStop()
57  {
58  super.OnEngineStop();
59 
60  if (GetGame().IsServer() || !GetGame().IsMultiplayer())
61  {
62  m_UTSource.SetDefferedActive(false, 10.0);
63  }
64  }
65 
66  override void EOnPostSimulate(IEntity other, float timeSlice)
67  {
68  if (GetGame().IsServer() || !GetGame().IsMultiplayer())
69  {
70  if (m_UTSource.IsActive())
71  {
73  }
74  }
75  }
76 
77  override float GetTransportCameraDistance()
78  {
79  return 6.5;
80  }
81 
82  override vector GetTransportCameraOffset()
83  {
84  return "0 3.2 0";
85  }
86 
87  override int GetAnimInstance()
88  {
89  return VehicleAnimInstances.V3S;
90  }
91 
92  override int GetSeatAnimationType(int posIdx)
93  {
94  switch (posIdx)
95  {
96  case 0:
97  return DayZPlayerConstants.VEHICLESEAT_DRIVER;
98  case 1:
99  return DayZPlayerConstants.VEHICLESEAT_CODRIVER;
100  }
101 
102  return 0;
103  }
104 
105  // Override for car-specific light type
106  override CarLightBase CreateFrontLight()
107  {
108  return CarLightBase.Cast(ScriptedLightBase.CreateLight(Truck_01FrontLight));
109  }
110 
111  // Override for car-specific light type
113  {
114  return CarRearLightBase.Cast(ScriptedLightBase.CreateLight(Truck_01RearLight));
115  }
116 
117  override bool CanReleaseAttachment(EntityAI attachment)
118  {
119  if (!super.CanReleaseAttachment(attachment))
120  {
121  return false;
122  }
123 
124  if (EngineIsOn() && attachment.GetType() == "TruckBattery")
125  {
126  return false;
127  }
128 
129  return true;
130  }
131 
132  override protected bool CanManipulateSpareWheel(string slotSelectionName)
133  {
134  if (slotSelectionName == "wheel_spare_1")
135  {
136  return GetAnimationPhase("wheelSidePlate1") == 1.0);
137  }
138 
139  if (slotSelectionName == "wheel_spare_2")
140  {
141  return GetAnimationPhase("wheelSidePlate2") == 1.0);
142  }
143 
144  return super.CanManipulateSpareWheel(slotSelectionName);
145  }
146 
147  override bool CrewCanGetThrough( int posIdx )
148  {
149  CarDoor carDoor;
150  switch( posIdx )
151  {
152  case 0:
153  if ( GetCarDoorsState("Truck_01_Door_1_1") == CarDoorState.DOORS_CLOSED )
154  return false;
155 
156  return true;
157 
158  case 1:
159  if ( GetCarDoorsState("Truck_01_Door_2_1") == CarDoorState.DOORS_CLOSED )
160  return false;
161 
162  return true;
163  }
164 
165  return false;
166  }
167 
168  override string GetDoorSelectionNameFromSeatPos(int posIdx)
169  {
170  switch( posIdx )
171  {
172  case 0:
173  return "doors_driver";
174  break;
175  case 1:
176  return "doors_codriver";
177  break;
178  }
179 
180  return super.GetDoorSelectionNameFromSeatPos(posIdx);
181  }
182 
183  override string GetDoorInvSlotNameFromSeatPos(int posIdx)
184  {
185  switch( posIdx )
186  {
187  case 0:
188  return "Truck_01_Door_1_1";
189  break;
190  case 1:
191  return "Truck_01_Door_2_1";
192  break;
193  }
194 
195  return super.GetDoorInvSlotNameFromSeatPos(posIdx);
196  }
197 
198  override float OnSound(CarSoundCtrl ctrl, float oldValue)
199  {
200  switch (ctrl)
201  {
202  case CarSoundCtrl.DOORS:
203  float newValue = 0;
204 
205  //-----
206  if (GetCarDoorsState("Truck_01_Door_1_1") == CarDoorState.DOORS_CLOSED)
207  {
208  newValue += 0.4;
209  }
210 
211  if (GetCarDoorsState("Truck_01_Door_2_1") == CarDoorState.DOORS_CLOSED)
212  {
213  newValue += 0.4;
214  }
215 
216  return Math.Clamp(newValue, 0, 1);
217  break;
218  }
219 
220  return super.OnSound(ctrl, oldValue);
221  }
222 
223  override void OnAnimationPhaseStarted(string animSource, float phase)
224  {
225  super.OnAnimationPhaseStarted(animSource, phase);
226 
227  #ifndef SERVER
228  switch (animSource)
229  {
230  case "wheelsideplate1":
231  case "wheelsideplate2":
232  EffectSound sound;
233  if (phase == 0)
234  {
235  sound = SEffectManager.PlaySound("Truck_01_Gear_Open_Side_Plate_SoundSet", GetPosition(), 0.1, 0.1);
236  }
237  else
238  {
239  sound = SEffectManager.PlaySound("Truck_01_Gear_Close_Side_Plate_SoundSet", GetPosition(), 0.1, 0.1);
240  }
241 
242  if (sound)
243  {
244  sound.SetAutodestroy(true);
245  }
246  break;
247  }
248  #endif
249  }
250 
251  override int GetCarDoorsState( string slotType )
252  {
253  CarDoor carDoor;
254  Class.CastTo(carDoor, FindAttachmentBySlotName(slotType));
255  if (!carDoor)
256  {
257  return CarDoorState.DOORS_MISSING;
258  }
259 
260  switch (slotType)
261  {
262  case "Truck_01_Door_1_1":
263  return TranslateAnimationPhaseToCarDoorState("DoorsDriver");
264  case "Truck_01_Door_2_1":
265  return TranslateAnimationPhaseToCarDoorState("DoorsCoDriver");
266  case "Truck_01_Hood":
267  return TranslateAnimationPhaseToCarDoorState("DoorsHood");
268  }
269 
270  return CarDoorState.DOORS_MISSING;
271  }
272 
273  override string GetAnimSourceFromSelection( string selection )
274  {
275  switch( selection )
276  {
277  case "doors_driver":
278  return "DoorsDriver";
279  case "doors_codriver":
280  return "DoorsCoDriver";
281  case "doors_hood":
282  return "DoorsHood";
283  case "doors_trunk":
284  return "DoorsTrunk";
285  case "wheelsideplate1":
286  return "WheelSidePlate1";
287  case "wheelsideplate2":
288  return "WheelSidePlate2";
289  }
290 
291  return "";
292  }
293 
294  override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
295  {
296  switch (currentSeat)
297  {
298  case 0:
299  return nextSeat == 1;
300  case 1:
301  return nextSeat == 0;
302  }
303 
304  return false;
305  }
306 
307  override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
308  {
309  switch (pCurrentSeat)
310  {
311  case 0:
312  return pDoorsSelection == "DoorsDriver";
313 
314  case 1:
315  return pDoorsSelection == "DoorsCoDriver";
316  }
317 
318  return false;
319  }
320 
321  override int GetSeatIndexFromDoor( string pDoorSelection )
322  {
323  switch (pDoorSelection)
324  {
325  case "DoorsDriver":
326  return 0;
327 
328  case "DoorsCoDriver":
329  return 1;
330  }
331 
332  return -1;
333  }
334 
335 
336  override bool IsVitalCarBattery()
337  {
338  return false;
339  }
340 
341  override bool IsVitalSparkPlug()
342  {
343  return false;
344  }
345 
346  override bool IsVitalGlowPlug()
347  {
348  return false;
349  }
350 
351  override bool IsVitalEngineBelt()
352  {
353  return false;
354  }
355 
356  override bool IsVitalRadiator()
357  {
358  return false;
359  }
360 
361  override void SetActions()
362  {
363  super.SetActions();
364 
371  }
372 
373  override void OnDebugSpawn()
374  {
377  FillUpCarFluids();
378 
379  GetInventory().CreateInInventory("Truck_01_Wheel");
380  GetInventory().CreateInInventory("Truck_01_Wheel");
381 
382  GetInventory().CreateInInventory("Truck_01_WheelDouble");
383  GetInventory().CreateInInventory("Truck_01_WheelDouble");
384  GetInventory().CreateInInventory("Truck_01_WheelDouble");
385  GetInventory().CreateInInventory("Truck_01_WheelDouble");
386 
387  GetInventory().CreateInInventory("Truck_01_Door_1_1");
388  GetInventory().CreateInInventory("Truck_01_Door_2_1");
389  GetInventory().CreateInInventory("Truck_01_Hood");
390 
391  //-----IN CAR CARGO
392  GetInventory().CreateInInventory("Truck_01_Wheel");
393  GetInventory().CreateInInventory("Truck_01_Wheel");
394  GetInventory().CreateInInventory("Truck_01_WheelDouble");
395  GetInventory().CreateInInventory("Truck_01_WheelDouble");
396  }
397 };
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
ActionDetachFromTarget_SpecificSlot_MetalSheets
ActionDetachFromTarget_SpecificSlot_WoodenPlanks ActionDetachFromTarget_SpecificSlot ActionDetachFromTarget_SpecificSlot_MetalSheets()
Definition: actiondetachfromtarget.c:223
OnDebugSpawn
class Truck_01_Base extends CarScript OnDebugSpawn
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
ActionDetachFromTarget_SpecificSlotsCategory_WoodenCrate
ActionEnterLadder ActionDetachFromTarget_SpecificSlotsCategory_WoodenCrate
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
Truck_01_Base
Definition: truck_01_chassis.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
IsVitalEngineBelt
bool IsVitalEngineBelt()
Definition: carscript.c:2284
UniversalTemperatureSource
original Timer deletes m_params which is unwanted
Definition: universaltemperaturesource.c:25
GetCarDoorsState
int GetCarDoorsState(string slotType)
Definition: carscript.c:2331
IsVitalCarBattery
bool IsVitalCarBattery()
Definition: carscript.c:2264
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
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
EffectSound
Wrapper class for managing sound through SEffectManager.
Definition: effectsound.c:4
ActionDetachFromTarget_SpecificSlot_WoodenPlanks
Definition: actiondetachfromtarget.c:213
CanManipulateSpareWheel
protected bool CanManipulateSpareWheel(string slotSelectionName)
Definition: carscript.c:843
GetSeatIndexFromDoor
override int GetSeatIndexFromDoor(string pDoorSelection)
Definition: offroadhatchback.c:427
vector
Definition: enconvert.c:105
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
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
ScriptedLightBase
Definition: pointlightbase.c:1
SetActions
void SetActions()
Definition: advancedcommunication.c:79
IsVitalRadiator
bool IsVitalRadiator()
Definition: carscript.c:2289
SpawnUniversalParts
protected void SpawnUniversalParts()
Definition: carscript.c:2632
m_EngineStopFuel
string m_EngineStopFuel
Definition: carscript.c:213
OnAnimationPhaseStarted
override void OnAnimationPhaseStarted(string animSource, float phase)
Definition: remotedetonator.c:181
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
IsVitalGlowPlug
bool IsVitalGlowPlug()
Definition: carscript.c:2279
ActionSidePlateInteract
Definition: actionsideplateinteract.c:1
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
ActionDetachFromTarget_SpecificSlotsCategory_Barrel
Definition: actiondetachfromtarget.c:229
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
SEffectManager
Manager class for managing Effect (EffectParticle, EffectSound)
Definition: effectmanager.c:5
m_EngineStartOK
string m_EngineStartOK
Sounds.
Definition: carscript.c:209
EntityAI
Definition: building.c:5
m_enginePtcPos
protected vector m_enginePtcPos
Definition: carscript.c:195
ActionDetachFromTarget_SpecificSlot_WoodenLogs
ActionDetachFromTarget_SpecificSlotsCategory ActionDetachFromTarget ActionDetachFromTarget_SpecificSlot_WoodenLogs()
Definition: actiondetachfromtarget.c:207
OnEngineStop
override void OnEngineStop()
Gets called everytime the engine stops.
Definition: carscript.c:1628