DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
Truck_01_Base.c
Go to the documentation of this file.
1class Truck_01_Base extends CarScript
2{
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_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 {
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
78 {
79 return 6.5;
80 }
81
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
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 {
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};
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 TranslateAnimationPhaseToCarDoorState(string animation)
Definition CarScript.c:2192
CarDoorState
Definition CarScript.c:2
protected void SpawnUniversalParts()
Definition CarScript.c:2480
string m_EngineStartOK
Sounds.
Definition CarScript.c:208
protected void FillUpCarFluids()
Definition CarScript.c:2548
string m_CarDoorCloseSound
Definition CarScript.c:215
string m_EngineStartBattery
Definition CarScript.c:209
protected vector m_enginePtcPos
Definition CarScript.c:194
string m_EngineStartPlug
Definition CarScript.c:210
protected void SpawnAdditionalItems()
Definition CarScript.c:2518
string m_EngineStartFuel
Definition CarScript.c:211
string m_CarHornShortSoundName
Definition CarScript.c:219
int GetCarDoorsState(string slotType)
Definition CarScript.c:2187
string m_CarHornLongSoundName
Definition CarScript.c:220
string m_EngineStopFuel
Definition CarScript.c:212
string m_CarDoorOpenSound
Definition CarScript.c:214
protected ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
protected ref UniversalTemperatureSourceSettings m_UTSSettings
protected ref UniversalTemperatureSource m_UTSource
class JsonUndergroundAreaTriggerData GetPosition
VehicleAnimInstances
override int GetCarDoorsState(string slotType)
override void OnDebugSpawn()
override void EOnPostSimulate(IEntity other, float timeSlice)
override vector GetTransportCameraOffset()
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()
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 protected bool CanManipulateSpareWheel(string slotSelectionName)
override bool IsVitalSparkPlug()
override string GetDoorSelectionNameFromSeatPos(int posIdx)
override int GetSeatAnimationType(int posIdx)
override string GetDoorInvSlotNameFromSeatPos(int posIdx)
override bool IsVitalEngineBelt()
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
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Definition EnMath.c:7
Manager class for managing Effect (EffectParticle, EffectSound)
static EffectSound PlaySound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound.
original Timer deletes m_params which is unwanted
float m_TemperatureMax
min temperature you can get from the TemperatureSource
float m_RangeFull
temperature cap that will limit the return value from GetTemperature method
bool m_ManualUpdate
if the Update is running periodically
float m_TemperatureMin
how often the Update is ticking
float m_RangeMax
range where the full temperature is given to receiver
float m_TemperatureCap
max temperature you can get from the TemperatureSource
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
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'.