DayZ 1.24
Loading...
Searching...
No Matches
Sedan_02.c
Go to the documentation of this file.
1class Sedan_02 extends CarScript
2{
6
7 void Sedan_02()
8 {
9 m_dmgContactCoef = 0.0790;
10
11 m_EngineStartOK = "Sedan_02_engine_start_SoundSet";
12 m_EngineStartBattery = "Sedan_02_engine_failed_start_battery_SoundSet";
13 m_EngineStartPlug = "Sedan_02_engine_failed_start_sparkplugs_SoundSet";
14 m_EngineStartFuel = "Sedan_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 = "Sedan_02_Horn_Short_SoundSet";
21 m_CarHornLongSoundName = "Sedan_02_Horn_SoundSet";
22
23 SetEnginePos("0 0.7 -1.7");
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.S120;
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 CarLightBase.Cast(ScriptedLightBase.CreateLight(Sedan_02FrontLight));
96 }
97
98 // Override for car-specific light type
100 {
101 return CarRearLightBase.Cast(ScriptedLightBase.CreateLight(Sedan_02RearLight));
102 }
103
105 {
106 if (!super.CanReleaseAttachment(attachment))
107 return false;
108
109 string attType = attachment.GetType();
110 switch (attType)
111 {
112 case "CarBattery":
113 if (GetCarDoorsState("Sedan_02_Trunk") == CarDoorState.DOORS_CLOSED || EngineIsOn())
114 return false;
115 break;
116
117 case "SparkPlug":
118 if (GetCarDoorsState("Sedan_02_Trunk") == CarDoorState.DOORS_CLOSED || EngineIsOn())
119 return false;
120 break;
121
122 case "CarRadiator":
123 if (GetCarDoorsState("Sedan_02_Hood") == CarDoorState.DOORS_CLOSED || EngineIsOn())
124 return false;
125 break;
126 }
127
128 return true;
129 }
130
131 override protected bool CanManipulateSpareWheel(string slotSelectionName)
132 {
133 return GetCarDoorsState("Sedan_02_Hood") != CarDoorState.DOORS_CLOSED;
134 }
135
137 {
138 if (!super.CanDisplayAttachmentCategory(category_name))
139 return false;
140
141 category_name.ToLower();
142 if (category_name.Contains("engine"))
143 {
144 if (GetCarDoorsState("Sedan_02_Trunk") == CarDoorState.DOORS_CLOSED)
145 return false;
146 }
147
148 if (category_name.Contains("trunk"))
149 {
150 if (GetCarDoorsState("Sedan_02_Hood") == CarDoorState.DOORS_CLOSED)
151 return false;
152 }
153
154 return true;
155 }
156
157 override bool CanDisplayCargo()
158 {
159 if (!super.CanDisplayCargo())
160 return false;
161
162 if (GetCarDoorsState("Sedan_02_Hood") == CarDoorState.DOORS_CLOSED)
163 return false;
164
165 return true;
166 }
167
168 override int GetCarDoorsState(string slotType)
169 {
171
172 Class.CastTo(carDoor, FindAttachmentBySlotName(slotType));
173 if (!carDoor)
174 return CarDoorState.DOORS_MISSING;
175
176 switch (slotType)
177 {
178 case "Sedan_02_Door_1_1":
179 return TranslateAnimationPhaseToCarDoorState("DoorsDriver");
180
181 case "Sedan_02_Door_2_1":
182 return TranslateAnimationPhaseToCarDoorState("DoorsCoDriver");
183
184 case "Sedan_02_Door_1_2":
185 return TranslateAnimationPhaseToCarDoorState("DoorsCargo1");
186
187 case "Sedan_02_Door_2_2":
188 return TranslateAnimationPhaseToCarDoorState("DoorsCargo2");
189
190 case "Sedan_02_Hood":
191 return TranslateAnimationPhaseToCarDoorState("DoorsHood");
192
193 case "Sedan_02_Trunk":
194 return TranslateAnimationPhaseToCarDoorState("DoorsTrunk");
195 }
196
197 return CarDoorState.DOORS_MISSING;
198 }
199
200
201 override bool CrewCanGetThrough(int posIdx)
202 {
203 switch (posIdx)
204 {
205 case 0:
206 if (GetCarDoorsState("Sedan_02_Door_1_1") == CarDoorState.DOORS_CLOSED)
207 return false;
208
209 return true;
210 break;
211
212 case 1:
213 if (GetCarDoorsState("Sedan_02_Door_2_1") == CarDoorState.DOORS_CLOSED)
214 return false;
215
216 return true;
217 break;
218
219 case 2:
220 if (GetCarDoorsState("Sedan_02_Door_1_2") == CarDoorState.DOORS_CLOSED)
221 return false;
222
223 return true;
224 break;
225
226 case 3:
227 if (GetCarDoorsState("Sedan_02_Door_2_2") == CarDoorState.DOORS_CLOSED)
228 return false;
229
230 return true;
231 break;
232 }
233
234 return false;
235 }
236
238 {
239 switch (posIdx)
240 {
241 case 0:
242 return "doors_driver";
243 break;
244 case 1:
245 return "doors_codriver";
246 break;
247 case 2:
248 return "doors_cargo1";
249 break;
250 case 3:
251 return "doors_cargo2";
252 break;
253 }
254
255 return super.GetDoorSelectionNameFromSeatPos(posIdx);
256 }
257
259 {
260 switch (posIdx)
261 {
262 case 0:
263 return "Sedan_02_Door_1_1";
264 break;
265 case 1:
266 return "Sedan_02_Door_2_1";
267 break;
268 case 2:
269 return "Sedan_02_Door_1_2";
270 break;
271 case 3:
272 return "Sedan_02_Door_2_2";
273 break;
274 }
275
276 return super.GetDoorInvSlotNameFromSeatPos(posIdx);
277 }
278
279 override float OnSound(CarSoundCtrl ctrl, float oldValue)
280 {
281 switch (ctrl)
282 {
283 case CarSoundCtrl.DOORS:
284 float newValue = 0;
285 if (GetCarDoorsState("Sedan_02_Door_1_1") == CarDoorState.DOORS_CLOSED)
286 newValue += 0.25;
287
288 if (GetCarDoorsState("Sedan_02_Door_2_1") == CarDoorState.DOORS_CLOSED)
289 newValue += 0.25;
290
291 if (GetCarDoorsState("Sedan_02_Door_1_2") == CarDoorState.DOORS_CLOSED)
292 newValue += 0.25;
293
294 if (GetCarDoorsState("Sedan_02_Door_2_2") == CarDoorState.DOORS_CLOSED)
295 newValue += 0.25;
296
297 return Math.Clamp(newValue, 0, 1);
298 break;
299 }
300
301 return super.OnSound(ctrl, oldValue);
302 }
303
304 override string GetAnimSourceFromSelection(string selection)
305 {
306 switch (selection)
307 {
308 case "doors_driver":
309 return "DoorsDriver";
310 case "doors_codriver":
311 return "DoorsCoDriver";
312 case "doors_cargo1":
313 return "DoorsCargo1";
314 case "doors_cargo2":
315 return "DoorsCargo2";
316 case "doors_hood":
317 return "DoorsHood";
318 case "doors_trunk":
319 return "DoorsTrunk";
320 }
321
322 return "";
323 }
324
325
326 override bool IsVitalTruckBattery()
327 {
328 return false;
329 }
330
331 override bool IsVitalGlowPlug()
332 {
333 return false;
334 }
335
337 {
338 switch (currentSeat)
339 {
340 case 0:
341 return nextSeat == 1;
342
343 case 1:
344 return nextSeat == 0;
345
346 case 2:
347 return nextSeat == 3;
348
349 case 3:
350 return nextSeat == 2;
351 }
352
353 return false;
354 }
355
357 {
358 switch (pCurrentSeat)
359 {
360 case 0:
361 return pDoorsSelection == "DoorsDriver";
362
363 case 1:
364 return pDoorsSelection == "DoorsCoDriver";
365
366 case 2:
367 return pDoorsSelection == "DoorsCargo1";
368
369 case 3:
370 return pDoorsSelection == "DoorsCargo2";
371 }
372
373 return false;
374 }
375
376 override void OnDebugSpawn()
377 {
381
382 GetInventory().CreateInInventory("Sedan_02_Wheel");
383 GetInventory().CreateInInventory("Sedan_02_Wheel");
384 GetInventory().CreateInInventory("Sedan_02_Wheel");
385 GetInventory().CreateInInventory("Sedan_02_Wheel");
386 GetInventory().CreateInInventory("Sedan_02_Wheel");
387
388 GetInventory().CreateInInventory("Sedan_02_Door_1_1");
389 GetInventory().CreateInInventory("Sedan_02_Door_1_2");
390 GetInventory().CreateInInventory("Sedan_02_Door_2_1");
391 GetInventory().CreateInInventory("Sedan_02_Door_2_2");
392 GetInventory().CreateInInventory("Sedan_02_Hood");
393 GetInventory().CreateInInventory("Sedan_02_Trunk");
394
395 //-----IN CAR CARGO
396 GetInventory().CreateInInventory("Sedan_02_Wheel");
397 GetInventory().CreateInInventory("Sedan_02_Wheel");
398 }
399}
400
401class Sedan_02_Red extends Sedan_02
402{
403 override void OnDebugSpawn()
409 GetInventory().CreateInInventory("Sedan_02_Wheel");
410 GetInventory().CreateInInventory("Sedan_02_Wheel");
411 GetInventory().CreateInInventory("Sedan_02_Wheel");
412 GetInventory().CreateInInventory("Sedan_02_Wheel");
413
414 GetInventory().CreateInInventory("Sedan_02_Door_1_1_Red");
415 GetInventory().CreateInInventory("Sedan_02_Door_1_2_Red");
416 GetInventory().CreateInInventory("Sedan_02_Door_2_1_Red");
417 GetInventory().CreateInInventory("Sedan_02_Door_2_2_Red");
418 GetInventory().CreateInInventory("Sedan_02_Hood_Red");
419 GetInventory().CreateInInventory("Sedan_02_Trunk_Red");
420
421 //-----IN CAR CARGO
422 GetInventory().CreateInInventory("Sedan_02_Wheel");
423 GetInventory().CreateInInventory("Sedan_02_Wheel");
424 }
425}
426
428{
429 override void OnDebugSpawn()
430 {
434
435 GetInventory().CreateInInventory("Sedan_02_Wheel");
436 GetInventory().CreateInInventory("Sedan_02_Wheel");
437 GetInventory().CreateInInventory("Sedan_02_Wheel");
438 GetInventory().CreateInInventory("Sedan_02_Wheel");
439
440 GetInventory().CreateInInventory("Sedan_02_Door_1_1_Grey");
441 GetInventory().CreateInInventory("Sedan_02_Door_1_2_Grey");
442 GetInventory().CreateInInventory("Sedan_02_Door_2_1_Grey");
443 GetInventory().CreateInInventory("Sedan_02_Door_2_2_Grey");
444 GetInventory().CreateInInventory("Sedan_02_Hood_Grey");
445 GetInventory().CreateInInventory("Sedan_02_Trunk_Grey");
447 //-----IN CAR CARGO
448 GetInventory().CreateInInventory("Sedan_02_Wheel");
449 GetInventory().CreateInInventory("Sedan_02_Wheel");
450 }
451}
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
float m_dmgContactCoef
Definition CarScript.c:159
string m_CarDoorOpenSound
Definition CarScript.c:213
class Hatchback_02_Blue extends Hatchback_02 OnDebugSpawn
ref UniversalTemperatureSourceSettings m_UTSSettings
Definition Sedan_02.c:405
ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
Definition Sedan_02.c:406
ref UniversalTemperatureSource m_UTSource
Definition Sedan_02.c:404
override int GetCarDoorsState(string slotType)
Definition Sedan_02.c:569
VehicleAnimInstances
override float OnSound(CarSoundCtrl ctrl, float oldValue)
Definition Sedan_02.c:279
override string GetDoorSelectionNameFromSeatPos(int posIdx)
Definition Sedan_02.c:237
override int GetAnimInstance()
Definition Sedan_02.c:70
override CarRearLightBase CreateRearLight()
Definition Sedan_02.c:99
override void OnDebugSpawn()
Definition Sedan_02.c:376
override string GetDoorInvSlotNameFromSeatPos(int posIdx)
Definition Sedan_02.c:258
override CarLightBase CreateFrontLight()
Definition Sedan_02.c:93
override bool IsVitalGlowPlug()
Definition Sedan_02.c:331
override int GetCarDoorsState(string slotType)
Definition Sedan_02.c:168
override bool IsVitalTruckBattery()
Definition Sedan_02.c:326
void Sedan_02()
Definition Sedan_02.c:7
override string GetAnimSourceFromSelection(string selection)
Definition Sedan_02.c:304
override bool CanDisplayCargo()
Definition Sedan_02.c:157
override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
Definition Sedan_02.c:356
override void EOnPostSimulate(IEntity other, float timeSlice)
Definition Sedan_02.c:61
override void OnEngineStart()
Definition Sedan_02.c:45
override bool CanReleaseAttachment(EntityAI attachment)
Definition Sedan_02.c:104
override void EEInit()
Definition Sedan_02.c:26
override bool CrewCanGetThrough(int posIdx)
Definition Sedan_02.c:201
override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
Definition Sedan_02.c:336
bool CanManipulateSpareWheel(string slotSelectionName)
Definition Sedan_02.c:131
override void OnEngineStop()
Definition Sedan_02.c:53
override bool CanDisplayAttachmentCategory(string category_name)
Definition Sedan_02.c:136
override int GetSeatAnimationType(int posIdx)
Definition Sedan_02.c:75
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition EnMath.c:7
override void OnDebugSpawn()
Definition Sedan_02.c:429
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'.