DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
CivilianSedan.c
Go to the documentation of this file.
2{
6
8 {
9 //m_dmgContactCoef = 0.065;
10
11 m_EngineStartOK = "CivilianSedan_engine_start_SoundSet";
12 m_EngineStartBattery = "CivilianSedan_engine_failed_start_battery_SoundSet";
13 m_EngineStartPlug = "CivilianSedan_engine_failed_start_sparkplugs_SoundSet";
14 m_EngineStartFuel = "CivilianSedan_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 = "CivilianSedan_Horn_Short_SoundSet";
21 m_CarHornLongSoundName = "CivilianSedan_Horn_SoundSet";
22
23 SetEnginePos("0 0.7 1.6");
24 }
25
26 override void EEInit()
27 {
28 super.EEInit();
29
30 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
31 {
39
42 }
43 }
44
45 override void OnEngineStart()
46 {
47 super.OnEngineStart();
48
49 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
50 {
51 m_UTSource.SetDefferedActive(true, 20.0);
52 }
53 }
54
55 override void OnEngineStop()
56 {
57 super.OnEngineStop();
58
59 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
60 {
61 m_UTSource.SetDefferedActive(false, 10.0);
62 }
63 }
64
65 override void EOnPostSimulate(IEntity other, float timeSlice)
66 {
67 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
68 {
69 if (m_UTSource.IsActive())
70 {
72 }
73 }
74 }
75
76 override int GetAnimInstance()
77 {
78 return VehicleAnimInstances.SEDAN;
79 }
80
82 {
83 return 4.5;
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 case 2:
95 return DayZPlayerConstants.VEHICLESEAT_PASSENGER_L;
96 case 3:
97 return DayZPlayerConstants.VEHICLESEAT_PASSENGER_R;
98 }
99
100 return 0;
101 }
102
103 // Override for car-specific light type
105 {
106 return CarLightBase.Cast( ScriptedLightBase.CreateLight(CivilianSedanFrontLight) );
107 }
108
109 // Override for car-specific light type
111 {
112 return CarRearLightBase.Cast( ScriptedLightBase.CreateLight(CivilianSedanRearLight) );
113 }
114
115 override bool CanReleaseAttachment( EntityAI attachment )
116 {
117 if( !super.CanReleaseAttachment( attachment ) )
118 return false;
119
120 string attType = attachment.GetType();
121
122 if ( EngineIsOn() || GetCarDoorsState("CivSedanHood") == CarDoorState.DOORS_CLOSED )
123 {
124 if ( attType == "CarRadiator" || attType == "CarBattery" || attType == "SparkPlug")
125 return false;
126 }
127
128 return true;
129 }
130
131 override protected bool CanManipulateSpareWheel(string slotSelectionName)
132 {
133 return GetCarDoorsState("CivSedanTrunk") != CarDoorState.DOORS_CLOSED;
134 }
135
136 override bool CanDisplayAttachmentCategory(string category_name)
137 {
138 //super
139 if (!super.CanDisplayAttachmentCategory(category_name))
140 return false;
141 //
142
143 category_name.ToLower();
144 if (category_name.Contains("engine"))
145 {
146 if (GetCarDoorsState("CivSedanHood") == CarDoorState.DOORS_CLOSED)
147 return false;
148 }
149
150 return true;
151 }
152
153 override bool CanDisplayCargo()
154 {
155 if ( !super.CanDisplayCargo() )
156 return false;
157
158 if ( GetCarDoorsState("CivSedanTrunk") == CarDoorState.DOORS_CLOSED )
159 return false;
160
161 return true;
162 }
163
164 override int GetCarDoorsState( string slotType )
165 {
166 CarDoor carDoor;
167
168 Class.CastTo( carDoor, FindAttachmentBySlotName( slotType ) );
169 if (!carDoor)
170 {
171 return CarDoorState.DOORS_MISSING;
172 }
173
174 switch (slotType)
175 {
176 case "CivSedanDriverDoors":
177 return TranslateAnimationPhaseToCarDoorState("DoorsDriver");
178 break;
179
180 case "CivSedanCoDriverDoors":
181 return TranslateAnimationPhaseToCarDoorState("DoorsCoDriver");
182 break;
183
184 case "CivSedanCargo1Doors":
185 return TranslateAnimationPhaseToCarDoorState("DoorsCargo1");
186 break;
187
188 case "CivSedanCargo2Doors":
189 return TranslateAnimationPhaseToCarDoorState("DoorsCargo2");
190 break;
191
192 case "CivSedanTrunk":
193 return TranslateAnimationPhaseToCarDoorState("DoorsTrunk");
194 break;
195
196 case "CivSedanHood":
197 return TranslateAnimationPhaseToCarDoorState("DoorsHood");
198 break;
199 }
200
201 return CarDoorState.DOORS_MISSING;
202 }
203
204
205 override bool CrewCanGetThrough( int posIdx )
206 {
207 switch( posIdx )
208 {
209 case 0:
210 if ( GetCarDoorsState("CivSedanDriverDoors") == CarDoorState.DOORS_CLOSED )
211 return false;
212
213 return true;
214 break;
215
216 case 1:
217 if ( GetCarDoorsState("CivSedanCoDriverDoors") == CarDoorState.DOORS_CLOSED )
218 return false;
219
220 return true;
221 break;
222
223 case 2:
224 if ( GetCarDoorsState("CivSedanCargo1Doors") == CarDoorState.DOORS_CLOSED )
225 return false;
226
227 return true;
228 break;
229
230 case 3:
231 if ( GetCarDoorsState("CivSedanCargo2Doors") == CarDoorState.DOORS_CLOSED )
232 return false;
233
234 return true;
235 break;
236 }
237
238 return false;
239 }
240
241 override string GetDoorSelectionNameFromSeatPos(int posIdx)
242 {
243 switch( posIdx )
244 {
245 case 0:
246 return "doors_driver";
247 break;
248 case 1:
249 return "doors_codriver";
250 break;
251 case 2:
252 return "doors_cargo1";
253 break;
254 case 3:
255 return "doors_cargo2";
256 break;
257 }
258
259 return super.GetDoorSelectionNameFromSeatPos(posIdx);
260 }
261
262 override string GetDoorInvSlotNameFromSeatPos(int posIdx)
263 {
264 switch( posIdx )
265 {
266 case 0:
267 return "CivSedanDriverDoors";
268 break;
269 case 1:
270 return "CivSedanCoDriverDoors";
271 break;
272 case 2:
273 return "CivSedanCargo1Doors";
274 break;
275 case 3:
276 return "CivSedanCargo2Doors";
277 break;
278 }
279
280 return super.GetDoorInvSlotNameFromSeatPos(posIdx);
281 }
282
283 // 0 full ambient and engine sound
284 // 1 zero ambient and engine sound
285 override float OnSound(CarSoundCtrl ctrl, float oldValue)
286 {
287 switch (ctrl)
288 {
289 case CarSoundCtrl.DOORS:
290 float newValue = 0;
291 if (GetCarDoorsState("CivSedanDriverDoors") == CarDoorState.DOORS_CLOSED)
292 {
293 newValue += 0.25;
294 }
295
296 if (GetCarDoorsState("CivSedanCoDriverDoors") == CarDoorState.DOORS_CLOSED)
297 {
298 newValue += 0.25;
299 }
300
301 if (GetCarDoorsState("CivSedanCargo1Doors") == CarDoorState.DOORS_CLOSED)
302 {
303 newValue += 0.25;
304 }
305
306 if (GetCarDoorsState("CivSedanCargo2Doors") == CarDoorState.DOORS_CLOSED)
307 {
308 newValue += 0.25;
309 }
310
311 if (GetHealthLevel("WindowFront") == GameConstants.STATE_RUINED)
312 {
313 newValue -= 0.6;
314 }
315
316 if (GetHealthLevel("WindowBack") == GameConstants.STATE_RUINED)
317 {
318 newValue -= 0.6;
319 }
320
321 return Math.Clamp(newValue, 0, 1);
322 break;
323 }
324
325 return super.OnSound(ctrl, oldValue);
326 }
327
328 override string GetAnimSourceFromSelection(string selection)
329 {
330 switch (selection)
331 {
332 case "doors_driver":
333 return "DoorsDriver";
334 case "doors_codriver":
335 return "DoorsCoDriver";
336 case "doors_cargo1":
337 return "DoorsCargo1";
338 case "doors_cargo2":
339 return "DoorsCargo2";
340 case "doors_hood":
341 return "DoorsHood";
342 case "doors_trunk":
343 return "DoorsTrunk";
344 }
345
346 return "";
347 }
348
349 override bool IsVitalTruckBattery()
350 {
351 return false;
352 }
353
354 override bool IsVitalGlowPlug()
355 {
356 return false;
357 }
358
359 override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
360 {
361 switch (currentSeat)
362 {
363 case 0:
364 return nextSeat == 1;
365
366 case 1:
367 return nextSeat == 0;
368
369 case 2:
370 return nextSeat == 3;
371
372 case 3:
373 return nextSeat == 2;
374 }
375
376 return false;
377 }
378
379 override bool CanReachDoorsFromSeat( string pDoorsSelection, int pCurrentSeat )
380 {
381 switch (pCurrentSeat)
382 {
383 case 0:
384 return pDoorsSelection == "DoorsDriver";
385
386 case 1:
387 return pDoorsSelection == "DoorsCoDriver";
388
389 case 2:
390 return pDoorsSelection == "DoorsCargo1";
391
392 case 3:
393 return pDoorsSelection == "DoorsCargo2";
394 }
395
396 return false;
397 }
398
399 override void OnDebugSpawn()
400 {
404
405 GetInventory().CreateInInventory("CivSedanWheel");
406 GetInventory().CreateInInventory("CivSedanWheel");
407 GetInventory().CreateInInventory("CivSedanWheel");
408 GetInventory().CreateInInventory("CivSedanWheel");
409
410 GetInventory().CreateInInventory("CivSedanDoors_Driver");
411 GetInventory().CreateInInventory("CivSedanDoors_CoDriver");
412 GetInventory().CreateInInventory("CivSedanDoors_BackLeft");
413 GetInventory().CreateInInventory("CivSedanDoors_BackRight");
414 GetInventory().CreateInInventory("CivSedanHood");
415 GetInventory().CreateInInventory("CivSedanTrunk");
416
417 //-----IN CAR CARGO
418 GetInventory().CreateInInventory("CivSedanWheel");
419 GetInventory().CreateInInventory("CivSedanWheel");
420 }
421}
422
423class CivilianSedan_Wine extends CivilianSedan
424{
425 override void OnDebugSpawn()
431 GetInventory().CreateInInventory("CivSedanWheel");
432 GetInventory().CreateInInventory("CivSedanWheel");
433 GetInventory().CreateInInventory("CivSedanWheel");
434 GetInventory().CreateInInventory("CivSedanWheel");
435
436 GetInventory().CreateInInventory("CivSedanDoors_Driver_Wine");
437 GetInventory().CreateInInventory("CivSedanDoors_CoDriver_Wine");
438 GetInventory().CreateInInventory("CivSedanDoors_BackLeft_Wine");
439 GetInventory().CreateInInventory("CivSedanDoors_BackRight_Wine");
440 GetInventory().CreateInInventory("CivSedanHood_Wine");
441 GetInventory().CreateInInventory("CivSedanTrunk_Wine");
442
443 //-----IN CAR CARGO
444 GetInventory().CreateInInventory("CivSedanWheel");
445 GetInventory().CreateInInventory("CivSedanWheel");
446 }
447}
448
449class CivilianSedan_Black extends CivilianSedan
450{
451 override void OnDebugSpawn()
452 {
456
457 GetInventory().CreateInInventory("CivSedanWheel");
458 GetInventory().CreateInInventory("CivSedanWheel");
459 GetInventory().CreateInInventory("CivSedanWheel");
460 GetInventory().CreateInInventory("CivSedanWheel");
461
462 GetInventory().CreateInInventory("CivSedanDoors_Driver_Black");
463 GetInventory().CreateInInventory("CivSedanDoors_CoDriver_Black");
464 GetInventory().CreateInInventory("CivSedanDoors_BackLeft_Black");
465 GetInventory().CreateInInventory("CivSedanDoors_BackRight_Black");
466 GetInventory().CreateInInventory("CivSedanHood_Black");
467 GetInventory().CreateInInventory("CivSedanTrunk_Black");
469 //-----IN CAR CARGO
470 GetInventory().CreateInInventory("CivSedanWheel");
471 GetInventory().CreateInInventory("CivSedanWheel");
472 }
473}
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
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
string m_CarHornLongSoundName
Definition CarScript.c:220
string m_EngineStopFuel
Definition CarScript.c:212
string m_CarDoorOpenSound
Definition CarScript.c:214
protected ref UniversalTemperatureSourceSettings m_UTSSettings
override int GetCarDoorsState(string slotType)
protected ref UniversalTemperatureSource m_UTSource
protected ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
VehicleAnimInstances
protected ref UniversalTemperatureSourceSettings m_UTSSettings
override int GetCarDoorsState(string slotType)
override void OnDebugSpawn()
override bool CanDisplayAttachmentCategory(string category_name)
override void EOnPostSimulate(IEntity other, float timeSlice)
override float GetTransportCameraDistance()
override bool IsVitalGlowPlug()
override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
override bool CanDisplayCargo()
override int GetAnimInstance()
override bool CrewCanGetThrough(int posIdx)
override CarLightBase CreateFrontLight()
override CarRearLightBase CreateRearLight()
override void EEInit()
override float OnSound(CarSoundCtrl ctrl, float oldValue)
override bool IsVitalTruckBattery()
override bool CanReleaseAttachment(EntityAI attachment)
override void OnEngineStart()
override string GetAnimSourceFromSelection(string selection)
override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
protected ref UniversalTemperatureSource m_UTSource
override protected bool CanManipulateSpareWheel(string slotSelectionName)
override string GetDoorSelectionNameFromSeatPos(int posIdx)
override int GetSeatAnimationType(int posIdx)
override string GetDoorInvSlotNameFromSeatPos(int posIdx)
protected ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
override void OnEngineStop()
void CivilianSedan()
override void OnDebugSpawn()
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition EnMath.c:7
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.
const int STATE_RUINED
Definition constants.c:742
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'.
bool Contains(string sample)
Returns true if sample is substring of string.
Definition EnString.c:286
proto int ToLower()
Changes string to lowercase. Returns length.