Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
offroad_02.c
Go to the documentation of this file.
1class Offroad_02 extends CarScript
2{
3 protected ref UniversalTemperatureSource m_UTSource;
4 protected ref UniversalTemperatureSourceSettings m_UTSSettings;
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_EngineStop = "Offroad_02_engine_stop_SoundSet";
16 m_EngineStopFuel = "offroad_engine_stop_fuel_SoundSet";
17
18 m_CarDoorOpenSound = "offroad_02_door_open_SoundSet";
19 m_CarDoorCloseSound = "offroad_02_door_close_SoundSet";
20
21 m_CarHornShortSoundName = "Offroad_02_Horn_Short_SoundSet";
22 m_CarHornLongSoundName = "Offroad_02_Horn_SoundSet";
23
24 SetEnginePos("0 0.7 1.7");
25 }
26
28 {
29 m_UTSource = null;
30 m_UTSSettings = null;
31 m_UTSLEngine = null;
32 }
33
34 override void EEInit()
35 {
36 super.EEInit();
37
38 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
39 {
41 m_UTSSettings.m_ManualUpdate = true;
43 m_UTSSettings.m_TemperatureCap = 0;
44 m_UTSSettings.m_RangeFull = 0.5;
45 m_UTSSettings.m_RangeMax = 2;
46
49 }
50 }
51
52 override void OnEngineStart()
53 {
54 super.OnEngineStart();
55
56 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
57 {
58 if (m_UTSource)
59 m_UTSource.SetDefferedActive(true, 20.0);
60 }
61 }
62
63 override void OnEngineStop()
64 {
65 super.OnEngineStop();
66
67 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
68 {
69 if (m_UTSource)
70 m_UTSource.SetDefferedActive(false, 10.0);
71 }
72 }
73
74 override void EOnPostSimulate(IEntity other, float timeSlice)
75 {
76 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
77 {
78 if (m_UTSource && m_UTSource.IsActive())
79 {
81 }
82 }
83 }
84
85 override int GetAnimInstance()
86 {
87 return VehicleAnimInstances.HMMWV;
88 }
89
91 {
92 return 5.1;
93 }
94
95 override int GetSeatAnimationType(int posIdx)
96 {
97 switch (posIdx)
98 {
99 case 0:
100 return DayZPlayerConstants.VEHICLESEAT_DRIVER;
101 case 1:
102 return DayZPlayerConstants.VEHICLESEAT_CODRIVER;
103 case 2:
104 return DayZPlayerConstants.VEHICLESEAT_PASSENGER_L;
105 case 3:
106 return DayZPlayerConstants.VEHICLESEAT_PASSENGER_R;
107 }
108
109 return 0;
110 }
111
112 // Override for car-specific light type
114 {
115 return CarLightBase.Cast(ScriptedLightBase.CreateLight(Offroad_02FrontLight));
116 }
117
118 // Override for car-specific light type
120 {
121 return CarRearLightBase.Cast(ScriptedLightBase.CreateLight(Offroad_02RearLight));
122 }
123
124 override bool CanReleaseAttachment( EntityAI attachment )
125 {
126 if (!super.CanReleaseAttachment(attachment))
127 {
128 return false;
129 }
130
131 string attType = attachment.GetType();
132 switch (attType)
133 {
134 case "CarBattery":
135 if (GetCarDoorsState("Offroad_02_Hood") == CarDoorState.DOORS_CLOSED || EngineIsOn())
136 {
137 return false;
138 }
139 break;
140
141 case "GlowPlug":
142 if (GetCarDoorsState("Offroad_02_Hood") == CarDoorState.DOORS_CLOSED || EngineIsOn())
143 {
144 return false;
145 }
146 break;
147 }
148
149 return true;
150 }
151
152 override protected bool CanManipulateSpareWheel(string slotSelectionName)
153 {
154 return GetCarDoorsState("Offroad_02_Trunk") != CarDoorState.DOORS_CLOSED;
155 }
156
157 override bool CanDisplayAttachmentCategory(string category_name)
158 {
159 if ( !super.CanDisplayAttachmentCategory(category_name))
160 {
161 return false;
162 }
163
164 category_name.ToLower();
165 if (category_name.Contains("engine"))
166 {
167 if (GetCarDoorsState("Offroad_02_Hood") == CarDoorState.DOORS_CLOSED)
168 {
169 return false;
170 }
171 }
172
173 return true;
174 }
175
176 override bool CanDisplayCargo()
177 {
178 if ( !super.CanDisplayCargo() )
179 return false;
180
181 if ( GetCarDoorsState("Offroad_02_Trunk") == CarDoorState.DOORS_CLOSED )
182 return false;
183
184 return true;
185 }
186
187 override int GetCarDoorsState(string slotType)
188 {
189 CarDoor carDoor;
190
191 Class.CastTo( carDoor, FindAttachmentBySlotName( slotType ) );
192 if (!carDoor)
193 {
194 return CarDoorState.DOORS_MISSING;
195 }
196
197 switch (slotType)
198 {
199 case "Offroad_02_Door_1_1":
200 return TranslateAnimationPhaseToCarDoorState("DoorsDriver");
201
202 case "Offroad_02_Door_2_1":
203 return TranslateAnimationPhaseToCarDoorState("DoorsCoDriver");
204
205 case "Offroad_02_Door_1_2":
206 return TranslateAnimationPhaseToCarDoorState("DoorsCargo1");
207
208 case "Offroad_02_Door_2_2":
209 return TranslateAnimationPhaseToCarDoorState("DoorsCargo2");
210
211 case "Offroad_02_Hood":
212 return TranslateAnimationPhaseToCarDoorState("DoorsHood");
213
214 case "Offroad_02_Trunk":
215 return TranslateAnimationPhaseToCarDoorState("DoorsTrunk");
216 }
217
218 return CarDoorState.DOORS_MISSING;
219 }
220
221
222 override bool CrewCanGetThrough( int posIdx )
223 {
224 switch( posIdx )
225 {
226 case 0:
227 if ( GetCarDoorsState("Offroad_02_Door_1_1") == CarDoorState.DOORS_CLOSED )
228 return false;
229
230 return true;
231 break;
232
233 case 1:
234 if ( GetCarDoorsState("Offroad_02_Door_2_1") == CarDoorState.DOORS_CLOSED )
235 return false;
236
237 return true;
238 break;
239
240 case 2:
241 if ( GetCarDoorsState("Offroad_02_Door_1_2") == CarDoorState.DOORS_CLOSED )
242 return false;
243
244 return true;
245 break;
246
247 case 3:
248 if ( GetCarDoorsState("Offroad_02_Door_2_2") == CarDoorState.DOORS_CLOSED )
249 return false;
250
251 return true;
252 break;
253 }
254
255 return false;
256 }
257
258 override string GetDoorSelectionNameFromSeatPos(int posIdx)
259 {
260 switch( posIdx )
261 {
262 case 0:
263 return "doors_driver";
264 break;
265 case 1:
266 return "doors_codriver";
267 break;
268 case 2:
269 return "doors_cargo1";
270 break;
271 case 3:
272 return "doors_cargo2";
273 break;
274 }
275
276 return super.GetDoorSelectionNameFromSeatPos(posIdx);
277 }
278
279 override string GetDoorInvSlotNameFromSeatPos(int posIdx)
280 {
281 switch (posIdx)
282 {
283 case 0:
284 return "Offroad_02_Door_1_1";
285 case 1:
286 return "Offroad_02_Door_2_1";
287 case 2:
288 return "Offroad_02_Door_1_2";
289 case 3:
290 return "Offroad_02_Door_2_2";
291 }
292
293 return super.GetDoorInvSlotNameFromSeatPos(posIdx);
294 }
295
296 override float OnSound(CarSoundCtrl ctrl, float oldValue)
297 {
298 switch ( ctrl )
299 {
300 case CarSoundCtrl.DOORS:
301 float newValue = 0;
302 if (GetCarDoorsState("Offroad_02_Door_1_1") == CarDoorState.DOORS_CLOSED)
303 {
304 newValue += 0.25;
305 }
306
307 if (GetCarDoorsState("Offroad_02_Door_2_1") == CarDoorState.DOORS_CLOSED)
308 {
309 newValue += 0.25;
310 }
311
312 if (GetCarDoorsState("Offroad_02_Door_1_2") == CarDoorState.DOORS_CLOSED)
313 {
314 newValue += 0.25;
315 }
316
317 if (GetCarDoorsState("Offroad_02_Door_2_2") == CarDoorState.DOORS_CLOSED)
318 {
319 newValue += 0.25;
320 }
321
322 return Math.Clamp(newValue, 0, 1);
323 break;
324 }
325
326 return super.OnSound(ctrl, oldValue);
327 }
328
329 override string GetAnimSourceFromSelection(string selection)
330 {
331 switch (selection)
332 {
333 case "doors_driver":
334 return "DoorsDriver";
335 case "doors_codriver":
336 return "DoorsCoDriver";
337 case "doors_cargo1":
338 return "DoorsCargo1";
339 case "doors_cargo2":
340 return "DoorsCargo2";
341 case "doors_hood":
342 return "DoorsHood";
343 case "doors_trunk":
344 return "DoorsTrunk";
345 }
346
347 return "";
348 }
349
350 override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
351 {
352 switch (currentSeat)
353 {
354 case 0:
355 return nextSeat == 1;
356 case 1:
357 return nextSeat == 0;
358 case 2:
359 return nextSeat == 3;
360 case 3:
361 return nextSeat == 2;
362 }
363
364 return false;
365 }
366
367 override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
368 {
369 switch (pCurrentSeat)
370 {
371 case 0:
372 return pDoorsSelection == "DoorsDriver";
373 case 1:
374 return pDoorsSelection == "DoorsCoDriver";
375 case 2:
376 return pDoorsSelection == "DoorsCargo1";
377 case 3:
378 return pDoorsSelection == "DoorsCargo2";
379 }
380
381 return false;
382 }
383
384 override bool IsVitalTruckBattery()
385 {
386 return false;
387 }
388
389 override bool IsVitalSparkPlug()
390 {
391 return false;
392 }
393
394 override bool IsVitalRadiator()
395 {
396 return false;
397 }
398
399 override void OnDebugSpawn()
400 {
401 SpawnUniversalParts();
402 SpawnAdditionalItems();
403 FillUpCarFluids();
404
405 GameInventory inventory = GetInventory();
406 inventory.CreateInInventory("Offroad_02_Wheel");
407 inventory.CreateInInventory("Offroad_02_Wheel");
408 inventory.CreateInInventory("Offroad_02_Wheel");
409 inventory.CreateInInventory("Offroad_02_Wheel");
410
411 inventory.CreateInInventory("Offroad_02_Door_1_1");
412 inventory.CreateInInventory("Offroad_02_Door_1_2");
413 inventory.CreateInInventory("Offroad_02_Door_2_1");
414 inventory.CreateInInventory("Offroad_02_Door_2_2");
415 inventory.CreateInInventory("Offroad_02_Hood");
416 inventory.CreateInInventory("Offroad_02_Trunk");
417
418 //-----IN CAR CARGO
419 inventory.CreateInInventory("Offroad_02_Wheel");
420 inventory.CreateInInventory("Offroad_02_Wheel");
421 }
422}
CarSoundCtrl
Car's sound controller list. (native, do not change or extend).
Definition car.c:4
CarDoorState
Definition carscript.c:2
override int GetCarDoorsState(string slotType)
ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
void ~Offroad_02()
Definition offroad_02.c:27
override int GetCarDoorsState(string slotType)
Definition offroad_02.c:187
override void OnDebugSpawn()
Definition offroad_02.c:399
override bool CanDisplayAttachmentCategory(string category_name)
Definition offroad_02.c:157
override void EOnPostSimulate(IEntity other, float timeSlice)
Definition offroad_02.c:74
ref UniversalTemperatureSourceSettings m_UTSSettings
override float GetTransportCameraDistance()
Definition offroad_02.c:90
override bool IsVitalRadiator()
Definition offroad_02.c:394
override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
Definition offroad_02.c:367
override bool CanDisplayCargo()
Definition offroad_02.c:176
override int GetAnimInstance()
Definition offroad_02.c:85
override bool CrewCanGetThrough(int posIdx)
Definition offroad_02.c:222
override CarLightBase CreateFrontLight()
Definition offroad_02.c:113
override CarRearLightBase CreateRearLight()
Definition offroad_02.c:119
override void EEInit()
Definition offroad_02.c:34
ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
override float OnSound(CarSoundCtrl ctrl, float oldValue)
Definition offroad_02.c:296
override bool IsVitalTruckBattery()
Definition offroad_02.c:384
void Offroad_02()
Definition offroad_02.c:7
override bool CanReleaseAttachment(EntityAI attachment)
Definition offroad_02.c:124
override void OnEngineStart()
Definition offroad_02.c:52
override string GetAnimSourceFromSelection(string selection)
Definition offroad_02.c:329
override bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
Definition offroad_02.c:350
override bool IsVitalSparkPlug()
Definition offroad_02.c:389
override string GetDoorSelectionNameFromSeatPos(int posIdx)
Definition offroad_02.c:258
override int GetSeatAnimationType(int posIdx)
Definition offroad_02.c:95
ref UniversalTemperatureSource m_UTSource
override string GetDoorInvSlotNameFromSeatPos(int posIdx)
Definition offroad_02.c:279
bool CanManipulateSpareWheel(string slotSelectionName)
Definition offroad_02.c:152
override void OnEngineStop()
Definition offroad_02.c:63
Super root of all classes in Enforce script.
Definition enscript.c:11
script counterpart to engine's class Inventory
Definition inventory.c:81
EntityAI CreateInInventory(string type)
Definition inventory.c:876
Internal ancestor of all Entity implementations.
Definition enentity.c:165
Definition enmath.c:7
original Timer deletes m_params which is unwanted
DayZGame g_Game
Definition dayzgame.c:3942
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
ref UniversalTemperatureSourceSettings m_UTSSettings
ref UniversalTemperatureSource m_UTSource
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Definition constants.c:811
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.
UniversalTemperatureSourceLambdaBaseImpl UniversalTemperatureSourceLambdaBase UniversalTemperatureSourceLambdaEngine()
VehicleAnimInstances