DayZ 1.24
Loading...
Searching...
No Matches
OffroadHatchback.c
Go to the documentation of this file.
2{
6
8 {
9 //m_dmgContactCoef = 0.075;
10
11 m_EngineStartOK = "offroad_engine_start_SoundSet";
12 m_EngineStartBattery = "offroad_engine_failed_start_battery_SoundSet";
13 m_EngineStartPlug = "offroad_engine_failed_start_sparkplugs_SoundSet";
14 m_EngineStartFuel = "offroad_engine_failed_start_fuel_SoundSet";
15 m_EngineStopFuel = "offroad_engine_stop_fuel_SoundSet";
16
17 m_CarDoorOpenSound = "offroad_door_open_SoundSet";
18 m_CarDoorCloseSound = "offroad_door_close_SoundSet";
19 m_CarSeatShiftInSound = "Offroad_SeatShiftIn_SoundSet";
20 m_CarSeatShiftOutSound = "Offroad_SeatShiftOut_SoundSet";
21
22 m_CarHornShortSoundName = "Offroad_Horn_Short_SoundSet";
23 m_CarHornLongSoundName = "Offroad_Horn_SoundSet";
24
25 SetEnginePos("0 0.7 1.2");
26 }
27
28 override void EEInit()
29 {
30 super.EEInit();
31
32 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
33 {
35 m_UTSSettings.m_ManualUpdate = true;
36 m_UTSSettings.m_TemperatureMin = 0;
37 m_UTSSettings.m_TemperatureMax = 30;
38 m_UTSSettings.m_RangeFull = 0.5;
39 m_UTSSettings.m_RangeMax = 2;
40 m_UTSSettings.m_TemperatureCap = 25;
41
44 }
45 }
46
47 override void OnEngineStart()
48 {
49 super.OnEngineStart();
50
51 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
52 m_UTSource.SetDefferedActive(true, 20.0);
53 }
54
55 override void OnEngineStop()
56 {
57 super.OnEngineStop();
58
59 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
60 m_UTSource.SetDefferedActive(false, 10.0);
61 }
62
63 override void EOnPostSimulate(IEntity other, float timeSlice)
64 {
65 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
66 {
67 if (m_UTSource.IsActive())
69 }
70 }
71
72 override int GetAnimInstance()
73 {
74 return VehicleAnimInstances.HATCHBACK;
75 }
76
78 {
79 return 3.5;
80 }
81
82 override int GetSeatAnimationType(int posIdx)
83 {
84 switch (posIdx)
85 {
86 case 0:
87 return DayZPlayerConstants.VEHICLESEAT_DRIVER;
88 case 1:
89 return DayZPlayerConstants.VEHICLESEAT_CODRIVER;
90 case 2:
91 return DayZPlayerConstants.VEHICLESEAT_PASSENGER_L;
92 case 3:
93 return DayZPlayerConstants.VEHICLESEAT_PASSENGER_R;
94 }
95
96 return 0;
97
98 }
99
100
102 {
103 return CarRearLightBase.Cast(ScriptedLightBase.CreateLight(OffroadHatchbackRearLight));
104 }
105
107 {
108 return CarLightBase.Cast(ScriptedLightBase.CreateLight(OffroadHatchbackFrontLight));
109 }
110
112 {
113 if (!super.CanReleaseAttachment(attachment))
114 return false;
115
116 if (EngineIsOn() || GetCarDoorsState("NivaHood") == CarDoorState.DOORS_CLOSED)
117 {
118 string attType = attachment.GetType();
119 if (attType == "CarRadiator" || attType == "CarBattery" || attType == "SparkPlug")
120 return false;
121 }
122
123 return true;
124 }
125
126 override protected bool CanManipulateSpareWheel(string slotSelectionName)
127 {
128 return GetCarDoorsState("NivaHood") != CarDoorState.DOORS_CLOSED;
129 }
130
132 {
133 if (!super.CanDisplayAttachmentCategory(category_name))
134 return false;
135
136 category_name.ToLower();
137 if (category_name.Contains("engine"))
138 {
139 if (GetCarDoorsState("NivaHood") == CarDoorState.DOORS_CLOSED)
140 return false;
141 }
142
143 return true;
144 }
145
146 override bool CanDisplayCargo()
147 {
148 if (!super.CanDisplayCargo())
149 return false;
150
151 if (GetCarDoorsState("NivaTrunk") == CarDoorState.DOORS_CLOSED)
152 return false;
153
154 return true;
155 }
156
157 override int GetCarDoorsState(string slotType)
158 {
160
161 Class.CastTo(carDoor, FindAttachmentBySlotName(slotType));
162 if (!carDoor)
163 return CarDoorState.DOORS_MISSING;
164
165 switch (slotType)
166 {
167 case "NivaDriverDoors":
168 return TranslateAnimationPhaseToCarDoorState("DoorsDriver");
169
170 case "NivaCoDriverDoors":
171 return TranslateAnimationPhaseToCarDoorState("DoorsCoDriver");
172
173 case "NivaHood":
174 return TranslateAnimationPhaseToCarDoorState("DoorsHood");
175
176 case "NivaTrunk":
177 return TranslateAnimationPhaseToCarDoorState("DoorsTrunk");
178 }
179
180 return CarDoorState.DOORS_MISSING;
181 }
182
183 override bool CrewCanGetThrough(int posIdx)
184 {
186 switch (posIdx)
187 {
188 case 0:
189 if (GetCarDoorsState("NivaDriverDoors") == CarDoorState.DOORS_CLOSED)
190 return false;
191 else if (GetAnimationPhase("SeatDriver") > 0.5)
192 return false;
193
194 return true;
195
196 case 1:
197 if (GetCarDoorsState("NivaCoDriverDoors") == CarDoorState.DOORS_CLOSED)
198 return false;
199 else if (GetAnimationPhase("SeatCoDriver") > 0.5)
200 return false;
201
202 return true;
203
204 case 2:
205 if (GetCarDoorsState("NivaDriverDoors") == CarDoorState.DOORS_CLOSED)
206 return false;
207 else if (GetAnimationPhase("SeatDriver") <= 0.5)
208 return false;
209
210 return true;
211
212 case 3:
213 if (GetCarDoorsState("NivaCoDriverDoors") == CarDoorState.DOORS_CLOSED)
214 return false;
215 else if (GetAnimationPhase("SeatCoDriver") <= 0.5)
216 return false;
217
218 return true;
219 }
220
221 return false;
222 }
223
225 {
226 switch (posIdx)
227 {
228 case 0:
229 case 2:
230 return "doors_driver";
231 case 1:
232 case 3:
233 return "doors_codriver";
234 }
235
236 return super.GetDoorSelectionNameFromSeatPos(posIdx);
237 }
238
240 {
241 switch (posIdx)
242 {
243 case 0:
244 case 2:
245 return "NivaDriverDoors";
246 case 1:
247 case 3:
248 return "NivaCoDriverDoors";
249 }
250
251 return super.GetDoorInvSlotNameFromSeatPos(posIdx);
252 }
253
254 // 0 full ambient and engine sound
255 // 1 zero ambient and engine sound
256 override float OnSound(CarSoundCtrl ctrl, float oldValue)
257 {
258 float tempCap = 0.0;
259
260 switch (ctrl)
261 {
262 case CarSoundCtrl.DOORS:
263 float newValue = 0;
264 if (GetCarDoorsState("NivaDriverDoors") == CarDoorState.DOORS_CLOSED)
265 newValue += 0.5;
266
267 if (GetCarDoorsState("NivaCoDriverDoors") == CarDoorState.DOORS_CLOSED)
268 newValue += 0.5;
269
270 if (GetCarDoorsState("NivaTrunk") == CarDoorState.DOORS_CLOSED)
271 newValue += 0.3;
272
273 if (GetHealthLevel("WindowFront") == GameConstants.STATE_RUINED)
274 newValue -= 0.6;
275
276 if (GetHealthLevel("WindowLR") == GameConstants.STATE_RUINED)
277 newValue -= 0.2;
278
279 if (GetHealthLevel("WindowRR") == GameConstants.STATE_RUINED)
280 newValue -= 0.2;
281
282 return Math.Clamp(newValue, 0, 1);
283 break;
284 }
285
286 return super.OnSound(ctrl, oldValue);
287 }
288
289 override string GetAnimSourceFromSelection(string selection)
290 {
291 switch (selection)
292 {
293 case "doors_driver":
294 return "DoorsDriver";
295 case "doors_codriver":
296 return "DoorsCoDriver";
297 case "doors_hood":
298 return "DoorsHood";
299 case "doors_trunk":
300 return "DoorsTrunk";
301 case "seatback_driver":
302 return "SeatDriver";
303 case "seatback_codriver":
304 return "SeatCoDriver";
305 }
306
307 return "";
308 }
309
310 override string GetDoorConditionPointFromSelection(string selection)
311 {
312 switch (selection)
313 {
314 case "seat_driver":
315 case "seatback_driver":
316 case "seat_cargo1":
317 return "seat_con_1_1";
318 case "seat_codriver":
319 case "seatback_codriver":
320 case "seat_cargo2":
321 return "seat_con_2_1";
322 }
323
324 return "";
325 }
326
327 override int GetCrewIndex(string selection)
328 {
329 switch (selection)
330 {
331 case "seatback_driver":
332 return 0;
333 case "seatback_codriver":
334 return 1;
335 }
336
337 return -1;
338 }
339
340 override bool IsVitalTruckBattery()
341 {
342 return false;
343 }
344
345 override bool IsVitalGlowPlug()
346 {
347 return false;
348 }
349
351 {
352 if (nextSeat == 0 && GetAnimationPhase("SeatDriver") > 0.5)
353 return false;
354
355 if (nextSeat == 1 && GetAnimationPhase("SeatCoDriver") > 0.5)
356 return false;
357
358 switch (currentSeat)
359 {
360 case 0:
361 return nextSeat == 1;
362
363 case 1:
364 return nextSeat == 0;
365
366 case 2:
367 return nextSeat == 3;
368
369 case 3:
370 return nextSeat == 2;
371 }
372
373 return false;
374 }
375
377 {
378 switch (pCurrentSeat)
379 {
380 case 0:
381 return pDoorsSelection == "DoorsDriver";
382
383 case 1:
384 return pDoorsSelection == "DoorsCoDriver";
385
386 case 2:
387 return pDoorsSelection == "DoorsDriver";
388
389 case 3:
390 return pDoorsSelection == "DoorsCoDriver";
391 }
392
393 return false;
394 }
395
397 {
398 switch (pDoorSelection)
399 {
400 case "DoorsDriver":
401 return 0;
402 case "DoorsCoDriver":
403 return 1;
404 }
405
406 return -1;
407 }
408
409 override void SetActions()
410 {
411 super.SetActions();
412
414 }
415
416 override void OnDebugSpawn()
417 {
421
422 GetInventory().CreateInInventory("HatchbackWheel");
423 GetInventory().CreateInInventory("HatchbackWheel");
424 GetInventory().CreateInInventory("HatchbackWheel");
425 GetInventory().CreateInInventory("HatchbackWheel");
426
427 GetInventory().CreateInInventory("HatchbackDoors_Driver");
428 GetInventory().CreateInInventory("HatchbackDoors_CoDriver");
429 GetInventory().CreateInInventory("HatchbackHood");
430 GetInventory().CreateInInventory("HatchbackTrunk");
431
432 //-----IN CAR CARGO
433 GetInventory().CreateInInventory("HatchbackWheel");
434 GetInventory().CreateInInventory("HatchbackWheel");
435 }
436}
437
439{
440 override void OnDebugSpawn()
446 GetInventory().CreateInInventory("HatchbackWheel");
447 GetInventory().CreateInInventory("HatchbackWheel");
448 GetInventory().CreateInInventory("HatchbackWheel");
449 GetInventory().CreateInInventory("HatchbackWheel");
450
451 GetInventory().CreateInInventory("HatchbackDoors_Driver_White");
452 GetInventory().CreateInInventory("HatchbackDoors_CoDriver_White");
453 GetInventory().CreateInInventory("HatchbackHood_White");
454 GetInventory().CreateInInventory("HatchbackTrunk_White");
455
456 //-----IN CAR CARGO
457 GetInventory().CreateInInventory("HatchbackWheel");
458 GetInventory().CreateInInventory("HatchbackWheel");
459 }
460}
461
463{
464 override void OnDebugSpawn()
465 {
469
470 GetInventory().CreateInInventory("HatchbackWheel");
471 GetInventory().CreateInInventory("HatchbackWheel");
472 GetInventory().CreateInInventory("HatchbackWheel");
473 GetInventory().CreateInInventory("HatchbackWheel");
474
475 GetInventory().CreateInInventory("HatchbackDoors_Driver_Blue");
476 GetInventory().CreateInInventory("HatchbackDoors_CoDriver_Blue");
477 GetInventory().CreateInInventory("HatchbackHood_Blue");
478 GetInventory().CreateInInventory("HatchbackTrunk_Blue");
479
480 //-----IN CAR CARGO
481 GetInventory().CreateInInventory("HatchbackWheel");
482 GetInventory().CreateInInventory("HatchbackWheel");
483 }
484}
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
string m_CarSeatShiftInSound
Definition CarScript.c:215
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
string m_CarHornLongSoundName
Definition CarScript.c:219
string m_EngineStopFuel
Definition CarScript.c:211
string m_CarSeatShiftOutSound
Definition CarScript.c:216
string m_CarDoorOpenSound
Definition CarScript.c:213
class Hatchback_02_Blue extends Hatchback_02 OnDebugSpawn
ref UniversalTemperatureSourceSettings m_UTSSettings
ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
ref UniversalTemperatureSource m_UTSource
override int GetCarDoorsState(string slotType)
VehicleAnimInstances
override float OnSound(CarSoundCtrl ctrl, float oldValue)
override float GetTransportCameraDistance()
override string GetDoorSelectionNameFromSeatPos(int posIdx)
override int GetAnimInstance()
override int GetCrewIndex(string selection)
void OffroadHatchback()
override CarRearLightBase CreateRearLight()
override void OnDebugSpawn()
override int GetSeatIndexFromDoor(string pDoorSelection)
override string GetDoorInvSlotNameFromSeatPos(int posIdx)
override string GetDoorConditionPointFromSelection(string selection)
override CarLightBase CreateFrontLight()
override bool IsVitalGlowPlug()
override int GetCarDoorsState(string slotType)
override bool IsVitalTruckBattery()
override string GetAnimSourceFromSelection(string selection)
override bool CanDisplayCargo()
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 CrewCanGetThrough(int posIdx)
override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
bool CanManipulateSpareWheel(string slotSelectionName)
override void OnEngineStop()
override bool CanDisplayAttachmentCategory(string category_name)
override int GetSeatAnimationType(int posIdx)
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition EnMath.c:7
override void OnDebugSpawn()
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.
const int STATE_RUINED
Definition constants.c:757
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'.