Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
truck_01_base.c
Go to the documentation of this file.
1class Truck_01_Base extends CarScript
2{
3 protected ref UniversalTemperatureSource m_UTSource;
4 protected ref UniversalTemperatureSourceSettings m_UTSSettings;
6
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_EngineStop = "Truck_01_engine_stop_SoundSet";
17 m_EngineStopFuel = "Truck_01_engine_stop_fuel_SoundSet";
18
19 m_CarDoorOpenSound = "Truck_01_door_open_SoundSet";
20 m_CarDoorCloseSound = "Truck_01_door_close_SoundSet";
21
22 m_CarHornShortSoundName = "Truck_01_Horn_Short_SoundSet";
23 m_CarHornLongSoundName = "Truck_01_Horn_SoundSet";
24
25 SetEnginePos("0 1.4 2.25");
26 }
27
29 {
30 m_UTSource = null;
31 m_UTSSettings = null;
32 m_UTSLEngine = null;
33 }
34
35 override void EEInit()
36 {
37 super.EEInit();
38
39 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
40 {
42 m_UTSSettings.m_ManualUpdate = true;
44 m_UTSSettings.m_TemperatureCap = 0;
45 m_UTSSettings.m_RangeFull = 0.5;
46 m_UTSSettings.m_RangeMax = 2;
47
50 }
51 }
52
53 override void OnEngineStart()
54 {
55 super.OnEngineStart();
56
57 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
58 {
59 if (m_UTSource)
60 m_UTSource.SetDefferedActive(true, 20.0);
61 }
62 }
63
64 override void OnEngineStop()
65 {
66 super.OnEngineStop();
67
68 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
69 {
70 if (m_UTSource)
71 m_UTSource.SetDefferedActive(false, 10.0);
72 }
73 }
74
75 override void EOnPostSimulate(IEntity other, float timeSlice)
76 {
77 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
78 {
79 if (m_UTSource && m_UTSource.IsActive())
80 {
82 }
83 }
84 }
85
87 {
88 return 6.5;
89 }
90
92 {
93 return "0 3.2 0";
94 }
95
96 override int GetAnimInstance()
97 {
98 return VehicleAnimInstances.V3S;
99 }
100
101 override int GetSeatAnimationType(int posIdx)
102 {
103 switch (posIdx)
104 {
105 case 0:
106 return DayZPlayerConstants.VEHICLESEAT_DRIVER;
107 case 1:
108 return DayZPlayerConstants.VEHICLESEAT_CODRIVER;
109 }
110
111 return 0;
112 }
113
114 // Override for car-specific light type
116 {
117 return CarLightBase.Cast(ScriptedLightBase.CreateLight(Truck_01FrontLight));
118 }
119
120 // Override for car-specific light type
122 {
123 return CarRearLightBase.Cast(ScriptedLightBase.CreateLight(Truck_01RearLight));
124 }
125
126 override bool CanReleaseAttachment(EntityAI attachment)
127 {
128 if (!super.CanReleaseAttachment(attachment))
129 {
130 return false;
131 }
132
133 if (EngineIsOn() && attachment.GetType() == "TruckBattery")
134 {
135 return false;
136 }
137
138 return true;
139 }
140
141 override protected bool CanManipulateSpareWheel(string slotSelectionName)
142 {
143 if (slotSelectionName == "wheel_spare_1")
144 {
145 return GetAnimationPhase("wheelSidePlate1") == 1.0;
146 }
147
148 if (slotSelectionName == "wheel_spare_2")
149 {
150 return GetAnimationPhase("wheelSidePlate2") == 1.0;
151 }
152
153 return super.CanManipulateSpareWheel(slotSelectionName);
154 }
155
156 override bool CrewCanGetThrough( int posIdx )
157 {
158 CarDoor carDoor;
159 switch( posIdx )
160 {
161 case 0:
162 if ( GetCarDoorsState("Truck_01_Door_1_1") == CarDoorState.DOORS_CLOSED )
163 return false;
164
165 return true;
166
167 case 1:
168 if ( GetCarDoorsState("Truck_01_Door_2_1") == CarDoorState.DOORS_CLOSED )
169 return false;
170
171 return true;
172 }
173
174 return false;
175 }
176
177 override string GetDoorSelectionNameFromSeatPos(int posIdx)
178 {
179 switch( posIdx )
180 {
181 case 0:
182 return "doors_driver";
183 break;
184 case 1:
185 return "doors_codriver";
186 break;
187 }
188
189 return super.GetDoorSelectionNameFromSeatPos(posIdx);
190 }
191
192 override string GetDoorInvSlotNameFromSeatPos(int posIdx)
193 {
194 switch( posIdx )
195 {
196 case 0:
197 return "Truck_01_Door_1_1";
198 break;
199 case 1:
200 return "Truck_01_Door_2_1";
201 break;
202 }
203
204 return super.GetDoorInvSlotNameFromSeatPos(posIdx);
205 }
206
207 override float OnSound(CarSoundCtrl ctrl, float oldValue)
208 {
209 switch (ctrl)
210 {
211 case CarSoundCtrl.DOORS:
212 float newValue = 0;
213
214 //-----
215 if (GetCarDoorsState("Truck_01_Door_1_1") == CarDoorState.DOORS_CLOSED)
216 {
217 newValue += 0.4;
218 }
219
220 if (GetCarDoorsState("Truck_01_Door_2_1") == CarDoorState.DOORS_CLOSED)
221 {
222 newValue += 0.4;
223 }
224
225 return Math.Clamp(newValue, 0, 1);
226 break;
227 }
228
229 return super.OnSound(ctrl, oldValue);
230 }
231
232 override void OnAnimationPhaseStarted(string animSource, float phase)
233 {
234 super.OnAnimationPhaseStarted(animSource, phase);
235
236 #ifndef SERVER
237 switch (animSource)
238 {
239 case "wheelsideplate1":
240 case "wheelsideplate2":
241 EffectSound sound = CreateSoundForAnimationSource(animSource);
242 if (phase == 0)
243 {
244 sound.SetSoundSet("Truck_01_Gear_Open_Side_Plate_SoundSet");
245 }
246 else
247 {
248 sound.SetSoundSet("Truck_01_Gear_Close_Side_Plate_SoundSet");
249 }
250
251 sound.SetSoundFadeIn(0.1);
252 sound.SetSoundFadeOut(0.1);
253
255 sound.SoundPlay();
256 break;
257 }
258 #endif
259 }
260
261 override int GetCarDoorsState( string slotType )
262 {
263 CarDoor carDoor;
264 Class.CastTo(carDoor, FindAttachmentBySlotName(slotType));
265 if (!carDoor)
266 {
267 return CarDoorState.DOORS_MISSING;
268 }
269
270 switch (slotType)
271 {
272 case "Truck_01_Door_1_1":
273 return TranslateAnimationPhaseToCarDoorState("DoorsDriver");
274 case "Truck_01_Door_2_1":
275 return TranslateAnimationPhaseToCarDoorState("DoorsCoDriver");
276 case "Truck_01_Hood":
277 return TranslateAnimationPhaseToCarDoorState("DoorsHood");
278 }
279
280 return CarDoorState.DOORS_MISSING;
281 }
282
283 override string GetAnimSourceFromSelection( string selection )
284 {
285 switch( selection )
286 {
287 case "doors_driver":
288 return "DoorsDriver";
289 case "doors_codriver":
290 return "DoorsCoDriver";
291 case "doors_hood":
292 return "DoorsHood";
293 case "doors_trunk":
294 return "DoorsTrunk";
295 case "wheelsideplate1":
296 return "WheelSidePlate1";
297 case "wheelsideplate2":
298 return "WheelSidePlate2";
299 }
300
301 return "";
302 }
303
304 override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
305 {
306 switch (currentSeat)
307 {
308 case 0:
309 return nextSeat == 1;
310 case 1:
311 return nextSeat == 0;
312 }
313
314 return false;
315 }
316
317 override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
318 {
319 switch (pCurrentSeat)
320 {
321 case 0:
322 return pDoorsSelection == "DoorsDriver";
323
324 case 1:
325 return pDoorsSelection == "DoorsCoDriver";
326 }
327
328 return false;
329 }
330
331 override int GetSeatIndexFromDoor( string pDoorSelection )
332 {
333 switch (pDoorSelection)
334 {
335 case "DoorsDriver":
336 return 0;
337
338 case "DoorsCoDriver":
339 return 1;
340 }
341
342 return -1;
343 }
344
345
346 override bool IsVitalCarBattery()
347 {
348 return false;
349 }
350
351 override bool IsVitalSparkPlug()
352 {
353 return false;
354 }
355
356 override bool IsVitalGlowPlug()
357 {
358 return false;
359 }
360
361 override bool IsVitalEngineBelt()
362 {
363 return false;
364 }
365
366 override bool IsVitalRadiator()
367 {
368 return false;
369 }
370
382
383 override void OnDebugSpawn()
384 {
385 SpawnUniversalParts();
386 SpawnAdditionalItems();
387 FillUpCarFluids();
388
389 GameInventory inventory = GetInventory();
390 inventory.CreateInInventory("Truck_01_Wheel");
391 inventory.CreateInInventory("Truck_01_Wheel");
392
393 inventory.CreateInInventory("Truck_01_WheelDouble");
394 inventory.CreateInInventory("Truck_01_WheelDouble");
395 inventory.CreateInInventory("Truck_01_WheelDouble");
396 inventory.CreateInInventory("Truck_01_WheelDouble");
397
398 inventory.CreateInInventory("Truck_01_Door_1_1");
399 inventory.CreateInInventory("Truck_01_Door_2_1");
400 inventory.CreateInInventory("Truck_01_Hood");
401
402 //-----IN CAR CARGO
403 inventory.CreateInInventory("Truck_01_Wheel");
404 inventory.CreateInInventory("Truck_01_Wheel");
405 inventory.CreateInInventory("Truck_01_WheelDouble");
406 inventory.CreateInInventory("Truck_01_WheelDouble");
407 }
408};
ActionDetachFromTarget_SpecificSlot_WoodenPlanks ActionDetachFromTarget_SpecificSlot ActionDetachFromTarget_SpecificSlot_MetalSheets()
ActionDetachFromTarget_SpecificSlotsCategory_Barrel ActionDetachFromTarget_SpecificSlotsCategory ActionDetachFromTarget_SpecificSlotsCategory_WoodenCrate()
ActionDetachFromTarget_SpecificSlotsCategory ActionDetachFromTarget ActionDetachFromTarget_SpecificSlot_WoodenLogs()
void AddAction(typename actionName)
CarSoundCtrl
Car's sound controller list. (native, do not change or extend).
Definition car.c:4
CarDoorState
Definition carscript.c:2
override int GetCarDoorsState(string slotType)
ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
override int GetCarDoorsState(string slotType)
override void OnDebugSpawn()
override void EOnPostSimulate(IEntity other, float timeSlice)
ref UniversalTemperatureSourceSettings m_UTSSettings
override vector GetTransportCameraOffset()
void ~Truck_01_Base()
override bool IsVitalCarBattery()
override float GetTransportCameraDistance()
override bool IsVitalGlowPlug()
override bool IsVitalRadiator()
override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
override int GetAnimInstance()
override bool CrewCanGetThrough(int posIdx)
override CarLightBase CreateFrontLight()
override int GetSeatIndexFromDoor(string pDoorSelection)
override CarRearLightBase CreateRearLight()
override void EEInit()
ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
override float OnSound(CarSoundCtrl ctrl, float oldValue)
override bool CanReleaseAttachment(EntityAI attachment)
override void OnEngineStart()
override string GetAnimSourceFromSelection(string selection)
override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
override bool IsVitalSparkPlug()
override string GetDoorSelectionNameFromSeatPos(int posIdx)
override int GetSeatAnimationType(int posIdx)
ref UniversalTemperatureSource m_UTSource
override string GetDoorInvSlotNameFromSeatPos(int posIdx)
override bool IsVitalEngineBelt()
bool CanManipulateSpareWheel(string slotSelectionName)
void Truck_01_Base()
override void OnAnimationPhaseStarted(string animSource, float phase)
override void SetActions()
override void OnEngineStop()
Super root of all classes in Enforce script.
Definition enscript.c:11
Wrapper class for managing sound through SEffectManager.
Definition effectsound.c:5
bool SoundPlay()
Plays sound.
void SetSoundSet(string snd)
Set soundset for the sound.
void SetSoundFadeOut(float fade_out)
Set the sound fade out duration.
void SetSoundFadeIn(float fade_in)
Set the sound fade in duration.
script counterpart to engine's class Inventory
Definition inventory.c:81
EntityAI CreateInInventory(string type)
Definition inventory.c:876
Internal ancestor of all Entity implementations.
Definition enentity.c:165
Definition enmath.c:7
Manager class for managing Effect (EffectParticle, EffectSound).
static int EffectRegister(Effect effect)
Registers Effect in SEffectManager.
original Timer deletes m_params which is unwanted
DayZGame g_Game
Definition dayzgame.c:3942
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
ref UniversalTemperatureSourceSettings m_UTSSettings
ref UniversalTemperatureSource m_UTSource
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Definition constants.c:811
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
UniversalTemperatureSourceLambdaBaseImpl UniversalTemperatureSourceLambdaBase UniversalTemperatureSourceLambdaEngine()
VehicleAnimInstances