DayZ 1.24
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 {
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 m_UTSource.SetDefferedActive(true, 20.0);
52 }
53
54 override void OnEngineStop()
55 {
56 super.OnEngineStop();
57
58 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
59 m_UTSource.SetDefferedActive(false, 10.0);
60 }
61
62 override void EOnPostSimulate(IEntity other, float timeSlice)
63 {
64 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
65 {
66 if (m_UTSource.IsActive())
68 }
69 }
70
72 {
73 return 6.5;
74 }
75
77 {
78 return "0 3.2 0";
79 }
80
81 override int GetAnimInstance()
82 {
83 return VehicleAnimInstances.V3S;
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 }
95
96 return 0;
97 }
98
99 // Override for car-specific light type
101 {
102 return CarLightBase.Cast(ScriptedLightBase.CreateLight(Truck_01FrontLight));
103 }
104
105 // Override for car-specific light type
107 {
108 return CarRearLightBase.Cast(ScriptedLightBase.CreateLight(Truck_01RearLight));
109 }
110
112 {
113 if (!super.CanReleaseAttachment(attachment))
114 return false;
115
116 if (EngineIsOn() && attachment.GetType() == "TruckBattery")
117 return false;
118
119 return true;
120 }
121
122 override protected bool CanManipulateSpareWheel(string slotSelectionName)
123 {
124 if (slotSelectionName == "wheel_spare_1")
125 return GetAnimationPhase("wheelSidePlate1") == 1.0);
126
127 if (slotSelectionName == "wheel_spare_2")
128 return GetAnimationPhase("wheelSidePlate2") == 1.0);
129
130 return super.CanManipulateSpareWheel(slotSelectionName);
131 }
132
133override bool CrewCanGetThrough(int posIdx)
134 {
136 switch (posIdx)
137 {
138 case 0:
139 if (GetCarDoorsState("Truck_01_Door_1_1") == CarDoorState.DOORS_CLOSED)
140 return false;
141
142 return true;
143
144 case 1:
145 if (GetCarDoorsState("Truck_01_Door_2_1") == CarDoorState.DOORS_CLOSED)
146 return false;
147
148 return true;
149 }
150
151 return false;
152 }
153
155 {
156 switch (posIdx)
157 {
158 case 0:
159 return "doors_driver";
160 break;
161 case 1:
162 return "doors_codriver";
163 break;
164 }
165
166 return super.GetDoorSelectionNameFromSeatPos(posIdx);
167 }
168
170 {
171 switch (posIdx)
172 {
173 case 0:
174 return "Truck_01_Door_1_1";
175 break;
176 case 1:
177 return "Truck_01_Door_2_1";
178 break;
179 }
180
181 return super.GetDoorInvSlotNameFromSeatPos(posIdx);
182 }
183
184 override float OnSound(CarSoundCtrl ctrl, float oldValue)
185 {
186 switch (ctrl)
187 {
188 case CarSoundCtrl.DOORS:
189 float newValue = 0;
190
191 //-----
192 if (GetCarDoorsState("Truck_01_Door_1_1") == CarDoorState.DOORS_CLOSED)
193 newValue += 0.4;
194
195 if (GetCarDoorsState("Truck_01_Door_2_1") == CarDoorState.DOORS_CLOSED)
196 newValue += 0.4;
197
198 return Math.Clamp(newValue, 0, 1);
199 break;
200 }
201
202 return super.OnSound(ctrl, oldValue);
203 }
204
205 override void OnAnimationPhaseStarted(string animSource, float phase)
206 {
207 super.OnAnimationPhaseStarted(animSource, phase);
208
209#ifndef SERVER
210 switch (animSource)
211 {
212 case "wheelsideplate1":
213 case "wheelsideplate2":
215 if (phase == 0)
216 sound = SEffectManager.PlaySound("Truck_01_Gear_Open_Side_Plate_SoundSet", GetPosition(), 0.1, 0.1);
217 else
218 sound = SEffectManager.PlaySound("Truck_01_Gear_Close_Side_Plate_SoundSet", GetPosition(), 0.1, 0.1);
219
220 if (sound)
221 sound.SetAutodestroy(true);
222 break;
223 }
224#endif
225 }
226
227 override int GetCarDoorsState(string slotType)
228 {
230 Class.CastTo(carDoor, FindAttachmentBySlotName(slotType));
231 if (!carDoor)
232 return CarDoorState.DOORS_MISSING;
233
234 switch (slotType)
235 {
236 case "Truck_01_Door_1_1":
237 return TranslateAnimationPhaseToCarDoorState("DoorsDriver");
238 case "Truck_01_Door_2_1":
239 return TranslateAnimationPhaseToCarDoorState("DoorsCoDriver");
240 case "Truck_01_Hood":
241 return TranslateAnimationPhaseToCarDoorState("DoorsHood");
242 }
243
244 return CarDoorState.DOORS_MISSING;
245 }
246
247 override string GetAnimSourceFromSelection(string selection)
248 {
249 switch (selection)
250 {
251 case "doors_driver":
252 return "DoorsDriver";
253 case "doors_codriver":
254 return "DoorsCoDriver";
255 case "doors_hood":
256 return "DoorsHood";
257 case "doors_trunk":
258 return "DoorsTrunk";
259 case "wheelsideplate1":
260 return "WheelSidePlate1";
261 case "wheelsideplate2":
262 return "WheelSidePlate2";
263 }
264
265 return "";
266 }
267
269 {
270 switch (currentSeat)
271 {
272 case 0:
273 return nextSeat == 1;
274 case 1:
275 return nextSeat == 0;
276 }
277
278 return false;
279 }
280
282 {
283 switch (pCurrentSeat)
284 {
285 case 0:
286 return pDoorsSelection == "DoorsDriver";
287
288 case 1:
289 return pDoorsSelection == "DoorsCoDriver";
290 }
291
292 return false;
293 }
294
296 {
297 switch (pDoorSelection)
298 {
299 case "DoorsDriver":
300 return 0;
301
302 case "DoorsCoDriver":
303 return 1;
304 }
305
306 return -1;
307 }
308
309
310 override bool IsVitalCarBattery()
311 {
312 return false;
313 }
314
315 override bool IsVitalSparkPlug()
316 {
317 return false;
318 }
319
320 override bool IsVitalGlowPlug()
321 {
322 return false;
323 }
324
325 override bool IsVitalEngineBelt()
326 {
327 return false;
328 }
329
330 override bool IsVitalRadiator()
331 {
332 return false;
333 }
334
346
347 override void OnDebugSpawn()
348 {
352
353 GetInventory().CreateInInventory("Truck_01_Wheel");
354 GetInventory().CreateInInventory("Truck_01_Wheel");
355
356 GetInventory().CreateInInventory("Truck_01_WheelDouble");
357 GetInventory().CreateInInventory("Truck_01_WheelDouble");
358 GetInventory().CreateInInventory("Truck_01_WheelDouble");
359 GetInventory().CreateInInventory("Truck_01_WheelDouble");
360
361 GetInventory().CreateInInventory("Truck_01_Door_1_1");
362 GetInventory().CreateInInventory("Truck_01_Door_2_1");
363 GetInventory().CreateInInventory("Truck_01_Hood");
364
365 //-----IN CAR CARGO
366 GetInventory().CreateInInventory("Truck_01_Wheel");
367 GetInventory().CreateInInventory("Truck_01_Wheel");
368 GetInventory().CreateInInventory("Truck_01_WheelDouble");
369 GetInventory().CreateInInventory("Truck_01_WheelDouble");
370 }
371};
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
void SpawnUniversalParts()
Definition CarScript.c:2516
CarDoorState TranslateAnimationPhaseToCarDoorState(string animation)
Definition CarScript.c:2241
CarDoorState
Definition CarScript.c:2
void SpawnAdditionalItems()
Definition CarScript.c:2554
string m_EngineStartOK
Sounds.
Definition CarScript.c:207
string m_CarDoorCloseSound
Definition CarScript.c:214
string m_EngineStartBattery
Definition CarScript.c:208
string m_EngineStartPlug
Definition CarScript.c:209
string m_EngineStartFuel
Definition CarScript.c:210
string m_CarHornShortSoundName
Definition CarScript.c:218
void FillUpCarFluids()
Definition CarScript.c:2578
int GetCarDoorsState(string slotType)
Definition CarScript.c:2236
vector m_enginePtcPos
Definition CarScript.c:193
string m_CarHornLongSoundName
Definition CarScript.c:219
string m_EngineStopFuel
Definition CarScript.c:211
string m_CarDoorOpenSound
Definition CarScript.c:213
ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
ref UniversalTemperatureSourceSettings m_UTSSettings
ref UniversalTemperatureSource m_UTSource
class JsonUndergroundAreaTriggerData GetPosition
VehicleAnimInstances
override float OnSound(CarSoundCtrl ctrl, float oldValue)
override bool IsVitalEngineBelt()
override float GetTransportCameraDistance()
override string GetDoorSelectionNameFromSeatPos(int posIdx)
override int GetAnimInstance()
void Truck_01_Base()
override CarRearLightBase CreateRearLight()
override void OnDebugSpawn()
override int GetSeatIndexFromDoor(string pDoorSelection)
override string GetDoorInvSlotNameFromSeatPos(int posIdx)
override CarLightBase CreateFrontLight()
override bool IsVitalGlowPlug()
override int GetCarDoorsState(string slotType)
override void OnAnimationPhaseStarted(string animSource, float phase)
override string GetAnimSourceFromSelection(string selection)
override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
override void EOnPostSimulate(IEntity other, float timeSlice)
override void OnEngineStart()
override bool CanReleaseAttachment(EntityAI attachment)
override void SetActions()
override void EEInit()
override bool IsVitalRadiator()
override bool CrewCanGetThrough(int posIdx)
override bool IsVitalCarBattery()
override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
override bool IsVitalSparkPlug()
bool CanManipulateSpareWheel(string slotSelectionName)
override void OnEngineStop()
override vector GetTransportCameraOffset()
override int GetSeatAnimationType(int posIdx)
Super root of all classes in Enforce script.
Definition EnScript.c:11
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
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
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
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'.