DayZ 1.24
Loading...
Searching...
No Matches
Hatchback_02.c
Go to the documentation of this file.
2{
6
8 {
9 //m_dmgContactCoef = 0.070;
10
11 m_EngineStartOK = "Hatchback_02_engine_start_SoundSet";
12 m_EngineStartBattery = "Hatchback_02_engine_failed_start_battery_SoundSet";
13 m_EngineStartPlug = "Hatchback_02_engine_failed_start_sparkplugs_SoundSet";
14 m_EngineStartFuel = "Hatchback_02_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
20 m_CarHornShortSoundName = "Hatchback_02_Horn_Short_SoundSet";
21 m_CarHornLongSoundName = "Hatchback_02_Horn_SoundSet";
22
23 SetEnginePos("0 0.7 1.4");
24 }
25
26 override void EEInit()
27 {
28 super.EEInit();
29
30 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
31 {
33 m_UTSSettings.m_ManualUpdate = true;
34 m_UTSSettings.m_TemperatureMin = 0;
35 m_UTSSettings.m_TemperatureMax = 30;
36 m_UTSSettings.m_RangeFull = 0.5;
37 m_UTSSettings.m_RangeMax = 2;
38 m_UTSSettings.m_TemperatureCap = 25;
39
42 }
43 }
44
45 override void OnEngineStart()
46 {
47 super.OnEngineStart();
48
49 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
50 m_UTSource.SetDefferedActive(true, 20.0);
51 }
52
53 override void OnEngineStop()
54 {
55 super.OnEngineStop();
56
57 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
58 m_UTSource.SetDefferedActive(false, 10.0);
59 }
60
61 override void EOnPostSimulate(IEntity other, float timeSlice)
62 {
63 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
64 {
65 if (m_UTSource.IsActive())
67 }
68 }
69
70 override int GetAnimInstance()
71 {
72 return VehicleAnimInstances.GOLF;
73 }
74
75 override int GetSeatAnimationType(int posIdx)
76 {
77 switch (posIdx)
78 {
79 case 0:
80 return DayZPlayerConstants.VEHICLESEAT_DRIVER;
81 case 1:
82 return DayZPlayerConstants.VEHICLESEAT_CODRIVER;
83 case 2:
84 return DayZPlayerConstants.VEHICLESEAT_PASSENGER_L;
85 case 3:
86 return DayZPlayerConstants.VEHICLESEAT_PASSENGER_R;
87 }
88
89 return 0;
90 }
91
92 // Override for car-specific light type
94 {
95 return CarRearLightBase.Cast(ScriptedLightBase.CreateLight(Hatchback_02RearLight));
96 }
97
98 // Override for car-specific light type
100 {
101 return CarLightBase.Cast(ScriptedLightBase.CreateLight(Hatchback_02FrontLight));
102 }
103
105 {
106 if (!super.CanReleaseAttachment(attachment))
107 return false;
108
109 if (EngineIsOn() || GetCarDoorsState("Hatchback_02_Hood") == CarDoorState.DOORS_CLOSED)
110 {
111 string attType = attachment.GetType();
112 if (attType == "CarRadiator" || attType == "CarBattery" || attType == "SparkPlug")
113 return false;
114 }
115
116 return true;
117 }
118
119 override protected bool CanManipulateSpareWheel(string slotSelectionName)
120 {
121 return GetCarDoorsState("Hatchback_02_Trunk") != CarDoorState.DOORS_CLOSED;
122 }
123
125 {
126 //super
127 if (!super.CanDisplayAttachmentCategory(category_name))
128 return false;
129 //
130
131 category_name.ToLower();
132 if (category_name.Contains("engine"))
133 {
134 if (GetCarDoorsState("Hatchback_02_Hood") == CarDoorState.DOORS_CLOSED)
135 return false;
136 }
137
138 return true;
139 }
140
141 override bool CanDisplayCargo()
142 {
143 if (!super.CanDisplayCargo())
144 return false;
145
146 if (GetCarDoorsState("Hatchback_02_Trunk") == CarDoorState.DOORS_CLOSED)
147 return false;
148
149 return true;
150 }
151
152 override int GetCarDoorsState(string slotType)
153 {
155
156 Class.CastTo(carDoor, FindAttachmentBySlotName(slotType));
157 if (!carDoor)
158 return CarDoorState.DOORS_MISSING;
159
160 switch (slotType)
161 {
162 case "Hatchback_02_Door_1_1":
163 return TranslateAnimationPhaseToCarDoorState("DoorsDriver");
164
165 case "Hatchback_02_Door_2_1":
166 return TranslateAnimationPhaseToCarDoorState("DoorsCoDriver");
167
168 case "Hatchback_02_Door_1_2":
169 return TranslateAnimationPhaseToCarDoorState("DoorsCargo1");
170
171 case "Hatchback_02_Door_2_2":
172 return TranslateAnimationPhaseToCarDoorState("DoorsCargo2");
173
174 case "Hatchback_02_Hood":
175 return TranslateAnimationPhaseToCarDoorState("DoorsHood");
176
177 case "Hatchback_02_Trunk":
178 return TranslateAnimationPhaseToCarDoorState("DoorsTrunk");
179 }
180
181 return CarDoorState.DOORS_MISSING;
182 }
183
184
185 override bool CrewCanGetThrough(int posIdx)
186 {
187 switch (posIdx)
188 {
189 case 0:
190 if (GetCarDoorsState("Hatchback_02_Door_1_1") == CarDoorState.DOORS_CLOSED)
191 return false;
192
193 return true;
194
195 case 1:
196 if (GetCarDoorsState("Hatchback_02_Door_2_1") == CarDoorState.DOORS_CLOSED)
197 return false;
198
199 return true;
200
201 case 2:
202 if (GetCarDoorsState("Hatchback_02_Door_1_2") == CarDoorState.DOORS_CLOSED)
203 return false;
204
205 return true;
206
207 case 3:
208 if (GetCarDoorsState("Hatchback_02_Door_2_2") == CarDoorState.DOORS_CLOSED)
209 return false;
210
211 return true;
212 }
213
214 return false;
215 }
216
218 {
219 switch (posIdx)
220 {
221 case 0:
222 return "doors_driver";
223 break;
224 case 1:
225 return "doors_codriver";
226 break;
227 case 2:
228 return "doors_cargo1";
229 break;
230 case 3:
231 return "doors_cargo2";
232 break;
233 }
234
235 return super.GetDoorSelectionNameFromSeatPos(posIdx);
236 }
237
239 {
240 switch (posIdx)
241 {
242 case 0:
243 return "Hatchback_02_Door_1_1";
244 break;
245 case 1:
246 return "Hatchback_02_Door_2_1";
247 break;
248 case 2:
249 return "Hatchback_02_Door_1_2";
250 break;
251 case 3:
252 return "Hatchback_02_Door_2_2";
253 break;
254 }
255
256 return super.GetDoorInvSlotNameFromSeatPos(posIdx);
257 }
258
259 override float OnSound(CarSoundCtrl ctrl, float oldValue)
260 {
261 switch (ctrl)
262 {
263 case CarSoundCtrl.DOORS:
264 float newValue = 0;
265 if (GetCarDoorsState("Hatchback_02_Door_1_1") == CarDoorState.DOORS_CLOSED)
266 newValue += 0.25;
267
268 if (GetCarDoorsState("Hatchback_02_Door_2_1") == CarDoorState.DOORS_CLOSED)
269 newValue += 0.25;
270
271 if (GetCarDoorsState("Hatchback_02_Door_1_2") == CarDoorState.DOORS_CLOSED)
272 newValue += 0.25;
273
274 if (GetCarDoorsState("Hatchback_02_Door_2_2") == CarDoorState.DOORS_CLOSED)
275 newValue += 0.25;
276
277 return Math.Clamp(newValue, 0, 1);
278 break;
279 }
280
281 return super.OnSound(ctrl, oldValue);
282 }
283
284 override string GetAnimSourceFromSelection(string selection)
285 {
286 switch (selection)
287 {
288 case "doors_driver":
289 return "DoorsDriver";
290 case "doors_codriver":
291 return "DoorsCoDriver";
292 case "doors_cargo1":
293 return "DoorsCargo1";
294 case "doors_cargo2":
295 return "DoorsCargo2";
296 case "doors_hood":
297 return "DoorsHood";
298 case "doors_trunk":
299 return "DoorsTrunk";
300 }
301
302 return "";
303 }
304
305
306 override bool IsVitalTruckBattery()
307 {
308 return false;
309 }
310
311 override bool IsVitalGlowPlug()
312 {
313 return false;
314 }
315
317 {
318 switch (currentSeat)
319 {
320 case 0:
321 return nextSeat == 1;
322 case 1:
323 return nextSeat == 0;
324 case 2:
325 return nextSeat == 3;
326 case 3:
327 return nextSeat == 2;
328 }
329
330 return false;
331 }
332
334 {
335 switch (pCurrentSeat)
336 {
337 case 0:
338 return pDoorsSelection == "DoorsDriver";
339 case 1:
340 return pDoorsSelection == "DoorsCoDriver";
341 case 2:
342 return pDoorsSelection == "DoorsCargo1";
343 case 3:
344 return pDoorsSelection == "DoorsCargo2";
345 }
346
347 return false;
348 }
349
350 override void OnDebugSpawn()
351 {
355
356 GetInventory().CreateInInventory("Hatchback_02_Wheel");
357 GetInventory().CreateInInventory("Hatchback_02_Wheel");
358 GetInventory().CreateInInventory("Hatchback_02_Wheel");
359 GetInventory().CreateInInventory("Hatchback_02_Wheel");
360
361 GetInventory().CreateInInventory("Hatchback_02_Door_1_1");
362 GetInventory().CreateInInventory("Hatchback_02_Door_1_2");
363 GetInventory().CreateInInventory("Hatchback_02_Door_2_1");
364 GetInventory().CreateInInventory("Hatchback_02_Door_2_2");
365 GetInventory().CreateInInventory("Hatchback_02_Hood");
366 GetInventory().CreateInInventory("Hatchback_02_Trunk");
367
368 //-----IN CAR CARGO
369 GetInventory().CreateInInventory("Hatchback_02_Wheel");
370 GetInventory().CreateInInventory("Hatchback_02_Wheel");
371 }
372}
373
375{
376 override void OnDebugSpawn()
382 GetInventory().CreateInInventory("Hatchback_02_Wheel");
383 GetInventory().CreateInInventory("Hatchback_02_Wheel");
384 GetInventory().CreateInInventory("Hatchback_02_Wheel");
385 GetInventory().CreateInInventory("Hatchback_02_Wheel");
386
387 GetInventory().CreateInInventory("Hatchback_02_Door_1_1_Black");
388 GetInventory().CreateInInventory("Hatchback_02_Door_1_2_Black");
389 GetInventory().CreateInInventory("Hatchback_02_Door_2_1_Black");
390 GetInventory().CreateInInventory("Hatchback_02_Door_2_2_Black");
391 GetInventory().CreateInInventory("Hatchback_02_Hood_Black");
392 GetInventory().CreateInInventory("Hatchback_02_Trunk_Black");
393
394 //-----IN CAR CARGO
395 GetInventory().CreateInInventory("Hatchback_02_Wheel");
396 GetInventory().CreateInInventory("Hatchback_02_Wheel");
397 }
398};
399
401{
402 override void OnDebugSpawn()
403 {
407
408 GetInventory().CreateInInventory("Hatchback_02_Wheel");
409 GetInventory().CreateInInventory("Hatchback_02_Wheel");
410 GetInventory().CreateInInventory("Hatchback_02_Wheel");
411 GetInventory().CreateInInventory("Hatchback_02_Wheel");
412
413 GetInventory().CreateInInventory("Hatchback_02_Door_1_1_Blue");
414 GetInventory().CreateInInventory("Hatchback_02_Door_1_2_Blue");
415 GetInventory().CreateInInventory("Hatchback_02_Door_2_1_Blue");
416 GetInventory().CreateInInventory("Hatchback_02_Door_2_2_Blue");
417 GetInventory().CreateInInventory("Hatchback_02_Hood_Blue");
418 GetInventory().CreateInInventory("Hatchback_02_Trunk_Blue");
420 //-----IN CAR CARGO
421 GetInventory().CreateInInventory("Hatchback_02_Wheel");
422 GetInventory().CreateInInventory("Hatchback_02_Wheel");
423 }
424};
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
string m_CarHornLongSoundName
Definition CarScript.c:219
string m_EngineStopFuel
Definition CarScript.c:211
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 string GetDoorSelectionNameFromSeatPos(int posIdx)
override int GetAnimInstance()
override CarRearLightBase CreateRearLight()
override void OnDebugSpawn()
override string GetDoorInvSlotNameFromSeatPos(int posIdx)
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 EEInit()
override bool CrewCanGetThrough(int posIdx)
void Hatchback_02()
Definition Hatchback_02.c:7
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
override void OnDebugSpawn()
Definition EnMath.c:7
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'.