DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
Offroad_02.c
Go to the documentation of this file.
1class Offroad_02 extends CarScript
2{
6
7 void Offroad_02()
8 {
9 //m_dmgContactCoef = 0.0365;
10
11 m_EngineStartOK = "Offroad_02_engine_start_SoundSet";
12 m_EngineStartBattery = "Offroad_02_engine_failed_start_battery_SoundSet";
13 m_EngineStartPlug = "Offroad_02_engine_failed_start_sparkplugs_SoundSet";
14 m_EngineStartFuel = "Offroad_02_engine_failed_start_fuel_SoundSet";
15 m_EngineStopFuel = "offroad_engine_stop_fuel_SoundSet";
16
17 m_CarDoorOpenSound = "offroad_02_door_open_SoundSet";
18 m_CarDoorCloseSound = "offroad_02_door_close_SoundSet";
19
20 m_CarHornShortSoundName = "Offroad_02_Horn_Short_SoundSet";
21 m_CarHornLongSoundName = "Offroad_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 {
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.HMMWV;
79 }
80
82 {
83 return 5.1;
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(Offroad_02FrontLight));
107 }
108
109 // Override for car-specific light type
111 {
112 return CarRearLightBase.Cast(ScriptedLightBase.CreateLight(Offroad_02RearLight));
113 }
114
115 override bool CanReleaseAttachment( EntityAI attachment )
116 {
117 if (!super.CanReleaseAttachment(attachment))
118 {
119 return false;
120 }
121
122 string attType = attachment.GetType();
123 switch (attType)
124 {
125 case "CarBattery":
126 if (GetCarDoorsState("Offroad_02_Hood") == CarDoorState.DOORS_CLOSED || EngineIsOn())
127 {
128 return false;
129 }
130 break;
131
132 case "GlowPlug":
133 if (GetCarDoorsState("Offroad_02_Hood") == CarDoorState.DOORS_CLOSED || EngineIsOn())
134 {
135 return false;
136 }
137 break;
138 }
139
140 return true;
141 }
142
143 override protected bool CanManipulateSpareWheel(string slotSelectionName)
144 {
145 return GetCarDoorsState("Offroad_02_Trunk") != CarDoorState.DOORS_CLOSED;
146 }
147
148 override bool CanDisplayAttachmentCategory(string category_name)
149 {
150 if ( !super.CanDisplayAttachmentCategory(category_name))
151 {
152 return false;
153 }
154
155 category_name.ToLower();
156 if (category_name.Contains("engine"))
157 {
158 if (GetCarDoorsState("Offroad_02_Hood") == CarDoorState.DOORS_CLOSED)
159 {
160 return false;
161 }
162 }
163
164 return true;
165 }
166
167 override bool CanDisplayCargo()
168 {
169 if ( !super.CanDisplayCargo() )
170 return false;
171
172 if ( GetCarDoorsState("Offroad_02_Trunk") == CarDoorState.DOORS_CLOSED )
173 return false;
174
175 return true;
176 }
177
178 override int GetCarDoorsState(string slotType)
179 {
180 CarDoor carDoor;
181
182 Class.CastTo( carDoor, FindAttachmentBySlotName( slotType ) );
183 if (!carDoor)
184 {
185 return CarDoorState.DOORS_MISSING;
186 }
187
188 switch (slotType)
189 {
190 case "Offroad_02_Door_1_1":
191 return TranslateAnimationPhaseToCarDoorState("DoorsDriver");
192
193 case "Offroad_02_Door_2_1":
194 return TranslateAnimationPhaseToCarDoorState("DoorsCoDriver");
195
196 case "Offroad_02_Door_1_2":
197 return TranslateAnimationPhaseToCarDoorState("DoorsCargo1");
198
199 case "Offroad_02_Door_2_2":
200 return TranslateAnimationPhaseToCarDoorState("DoorsCargo2");
201
202 case "Offroad_02_Hood":
203 return TranslateAnimationPhaseToCarDoorState("DoorsHood");
204
205 case "Offroad_02_Trunk":
206 return TranslateAnimationPhaseToCarDoorState("DoorsTrunk");
207 }
208
209 return CarDoorState.DOORS_MISSING;
210 }
211
212
213 override bool CrewCanGetThrough( int posIdx )
214 {
215 switch( posIdx )
216 {
217 case 0:
218 if ( GetCarDoorsState("Offroad_02_Door_1_1") == CarDoorState.DOORS_CLOSED )
219 return false;
220
221 return true;
222 break;
223
224 case 1:
225 if ( GetCarDoorsState("Offroad_02_Door_2_1") == CarDoorState.DOORS_CLOSED )
226 return false;
227
228 return true;
229 break;
230
231 case 2:
232 if ( GetCarDoorsState("Offroad_02_Door_1_2") == CarDoorState.DOORS_CLOSED )
233 return false;
234
235 return true;
236 break;
237
238 case 3:
239 if ( GetCarDoorsState("Offroad_02_Door_2_2") == CarDoorState.DOORS_CLOSED )
240 return false;
241
242 return true;
243 break;
244 }
245
246 return false;
247 }
248
249 override string GetDoorSelectionNameFromSeatPos(int posIdx)
250 {
251 switch( posIdx )
252 {
253 case 0:
254 return "doors_driver";
255 break;
256 case 1:
257 return "doors_codriver";
258 break;
259 case 2:
260 return "doors_cargo1";
261 break;
262 case 3:
263 return "doors_cargo2";
264 break;
265 }
266
267 return super.GetDoorSelectionNameFromSeatPos(posIdx);
268 }
269
270 override string GetDoorInvSlotNameFromSeatPos(int posIdx)
271 {
272 switch (posIdx)
273 {
274 case 0:
275 return "Offroad_02_Door_1_1";
276 case 1:
277 return "Offroad_02_Door_2_1";
278 case 2:
279 return "Offroad_02_Door_1_2";
280 case 3:
281 return "Offroad_02_Door_2_2";
282 }
283
284 return super.GetDoorInvSlotNameFromSeatPos(posIdx);
285 }
286
287 override float OnSound(CarSoundCtrl ctrl, float oldValue)
288 {
289 switch ( ctrl )
290 {
291 case CarSoundCtrl.DOORS:
292 float newValue = 0;
293 if (GetCarDoorsState("Offroad_02_Door_1_1") == CarDoorState.DOORS_CLOSED)
294 {
295 newValue += 0.25;
296 }
297
298 if (GetCarDoorsState("Offroad_02_Door_2_1") == CarDoorState.DOORS_CLOSED)
299 {
300 newValue += 0.25;
301 }
302
303 if (GetCarDoorsState("Offroad_02_Door_1_2") == CarDoorState.DOORS_CLOSED)
304 {
305 newValue += 0.25;
306 }
307
308 if (GetCarDoorsState("Offroad_02_Door_2_2") == CarDoorState.DOORS_CLOSED)
309 {
310 newValue += 0.25;
311 }
312
313 return Math.Clamp(newValue, 0, 1);
314 break;
315 }
316
317 return super.OnSound(ctrl, oldValue);
318 }
319
320 override string GetAnimSourceFromSelection(string selection)
321 {
322 switch (selection)
323 {
324 case "doors_driver":
325 return "DoorsDriver";
326 case "doors_codriver":
327 return "DoorsCoDriver";
328 case "doors_cargo1":
329 return "DoorsCargo1";
330 case "doors_cargo2":
331 return "DoorsCargo2";
332 case "doors_hood":
333 return "DoorsHood";
334 case "doors_trunk":
335 return "DoorsTrunk";
336 }
337
338 return "";
339 }
340
341 override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
342 {
343 switch (currentSeat)
344 {
345 case 0:
346 return nextSeat == 1;
347 case 1:
348 return nextSeat == 0;
349 case 2:
350 return nextSeat == 3;
351 case 3:
352 return nextSeat == 2;
353 }
354
355 return false;
356 }
357
358 override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
359 {
360 switch (pCurrentSeat)
361 {
362 case 0:
363 return pDoorsSelection == "DoorsDriver";
364 case 1:
365 return pDoorsSelection == "DoorsCoDriver";
366 case 2:
367 return pDoorsSelection == "DoorsCargo1";
368 case 3:
369 return pDoorsSelection == "DoorsCargo2";
370 }
371
372 return false;
373 }
374
375 override bool IsVitalTruckBattery()
376 {
377 return false;
378 }
379
380 override bool IsVitalSparkPlug()
381 {
382 return false;
383 }
384
385 override bool IsVitalRadiator()
386 {
387 return false;
388 }
389
390 override void OnDebugSpawn()
391 {
395
396 GetInventory().CreateInInventory("Offroad_02_Wheel");
397 GetInventory().CreateInInventory("Offroad_02_Wheel");
398 GetInventory().CreateInInventory("Offroad_02_Wheel");
399 GetInventory().CreateInInventory("Offroad_02_Wheel");
400
401 GetInventory().CreateInInventory("Offroad_02_Door_1_1");
402 GetInventory().CreateInInventory("Offroad_02_Door_1_2");
403 GetInventory().CreateInInventory("Offroad_02_Door_2_1");
404 GetInventory().CreateInInventory("Offroad_02_Door_2_2");
405 GetInventory().CreateInInventory("Offroad_02_Hood");
406 GetInventory().CreateInInventory("Offroad_02_Trunk");
407
408 //-----IN CAR CARGO
409 GetInventory().CreateInInventory("Offroad_02_Wheel");
410 GetInventory().CreateInInventory("Offroad_02_Wheel");
411 }
412}
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 UniversalTemperatureSourceLambdaEngine m_UTSLEngine
protected ref UniversalTemperatureSourceSettings m_UTSSettings
protected ref UniversalTemperatureSource m_UTSource
VehicleAnimInstances
protected ref UniversalTemperatureSourceSettings m_UTSSettings
override int GetCarDoorsState(string slotType)
override void OnDebugSpawn()
Definition Offroad_02.c:390
override bool CanDisplayAttachmentCategory(string category_name)
Definition Offroad_02.c:148
override void EOnPostSimulate(IEntity other, float timeSlice)
Definition Offroad_02.c:65
override float GetTransportCameraDistance()
Definition Offroad_02.c:81
override bool IsVitalRadiator()
Definition Offroad_02.c:385
override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
Definition Offroad_02.c:358
override bool CanDisplayCargo()
Definition Offroad_02.c:167
override int GetAnimInstance()
Definition Offroad_02.c:76
override bool CrewCanGetThrough(int posIdx)
Definition Offroad_02.c:213
override CarLightBase CreateFrontLight()
Definition Offroad_02.c:104
override CarRearLightBase CreateRearLight()
Definition Offroad_02.c:110
override void EEInit()
Definition Offroad_02.c:26
override float OnSound(CarSoundCtrl ctrl, float oldValue)
Definition Offroad_02.c:287
override bool IsVitalTruckBattery()
Definition Offroad_02.c:375
void Offroad_02()
Definition Offroad_02.c:7
override bool CanReleaseAttachment(EntityAI attachment)
Definition Offroad_02.c:115
override void OnEngineStart()
Definition Offroad_02.c:45
override string GetAnimSourceFromSelection(string selection)
Definition Offroad_02.c:320
override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
Definition Offroad_02.c:341
protected ref UniversalTemperatureSource m_UTSource
override protected bool CanManipulateSpareWheel(string slotSelectionName)
Definition Offroad_02.c:143
override bool IsVitalSparkPlug()
Definition Offroad_02.c:380
override string GetDoorSelectionNameFromSeatPos(int posIdx)
Definition Offroad_02.c:249
override int GetSeatAnimationType(int posIdx)
Definition Offroad_02.c:86
override string GetDoorInvSlotNameFromSeatPos(int posIdx)
Definition Offroad_02.c:270
protected ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
override void OnEngineStop()
Definition Offroad_02.c:55
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.
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.