Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
inventoryitem.c
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
3{
4};
5
7
8//-----------------------------------------------------------------------------
9class ItemWatch extends InventoryItemSuper
10{
11};
12
13//-----------------------------------------------------------------------------
15{
16 proto native void SetNextChannel();
17 proto native void SetPrevChannel();
18 proto native float GetTunedFrequency();
19 proto native void EnableBroadcast(bool state);
20 proto native void EnableReceive(bool state);
21 proto native bool IsBroadcasting();
22 proto native bool IsReceiving();
23 proto native int GetTunedFrequencyIndex();
24 proto native void SetFrequencyByIndex(int index);
25};
26
27//-----------------------------------------------------------------------------
29{
30 proto native bool CanSpeak();
31 proto native void SetCanSpeak(bool onOff);
32}
33
34//-----------------------------------------------------------------------------
35class ItemRadio extends InventoryItemSuper
36{
37 proto native void TuneNext();
38 proto native void TunePrev();
39};
40
41//-----------------------------------------------------------------------------
42class ItemBarrel extends InventoryItemSuper
43{
44};
45
46//-----------------------------------------------------------------------------
47class UnderSlugLauncher extends Weapon
48{
49};
50
51//-----------------------------------------------------------------------------
52class ItemGPS extends InventoryItemSuper
53{
54 bool IsTurnedOn()
55 {
56 return true;
57 }
58
59 override void OnInventoryEnter(Man player)
60 {
61 super.OnInventoryEnter(player);
62
63 PlayerBase pb = PlayerBase.Cast(player);
64 if ( pb && IsTurnedOn() )
65 {
66 pb.MapNavigationItemInPossession(this);
67 }
68 }
69
70 override void OnInventoryExit(Man player)
71 {
72 super.OnInventoryExit(player);
73
74 PlayerBase pb = PlayerBase.Cast(player);
75 if ( pb )
76 {
77 pb.MapNavigationItemNotInPossession(this);
78 }
79 }
80
81 override void OnWasAttached(EntityAI parent, int slot_id)
82 {
83 super.OnWasAttached(parent, slot_id);
84
85 PlayerBase player = PlayerBase.Cast(parent);
86 if ( parent.GetHierarchyRoot() )
87 {
88 player = PlayerBase.Cast(parent.GetHierarchyRoot());
89 }
90
91 if ( player && IsTurnedOn() )
92 {
93 player.MapNavigationItemInPossession(this);
94 }
95 }
96
97 override void OnWasDetached(EntityAI parent, int slot_id)
98 {
99 super.OnWasDetached(parent, slot_id);
100
101 PlayerBase player = PlayerBase.Cast(parent);
102 if ( parent.GetHierarchyRoot() )
103 {
104 player = PlayerBase.Cast(parent.GetHierarchyRoot());
105 }
106
107 if ( player )
108 {
109 player.MapNavigationItemNotInPossession(this);
110 }
111 }
112};
113
114//-----------------------------------------------------------------------------
115class ItemCompass extends InventoryItemSuper
116{
117 override void OnInventoryEnter(Man player)
118 {
119 super.OnInventoryEnter(player);
120
121 if ( IsRuined() )
122 {
123 return;
124 }
125
126 PlayerBase pb = PlayerBase.Cast(player);
127 if ( pb )
128 {
129 pb.MapNavigationItemInPossession(this);
130 }
131 }
132
133 override void OnInventoryExit(Man player)
134 {
135 super.OnInventoryExit(player);
136
137 if ( IsRuined() )
138 {
139 return;
140 }
141
142 PlayerBase pb = PlayerBase.Cast(player);
143 if ( pb )
144 {
145 pb.MapNavigationItemNotInPossession(this);
146 }
147 }
148
149 override void OnWasAttached(EntityAI parent, int slot_id)
150 {
151 super.OnWasAttached(parent, slot_id);
152
153 if ( IsRuined() )
154 {
155 return;
156 }
157
158 PlayerBase player = PlayerBase.Cast(parent);
159 if ( parent.GetHierarchyParent() )
160 {
161 player = PlayerBase.Cast(parent.GetHierarchyParent());
162 }
163
164 if ( player )
165 {
166 player.MapNavigationItemInPossession(this);
167 }
168 }
169
170 override void OnWasDetached(EntityAI parent, int slot_id)
171 {
172 super.OnWasDetached(parent, slot_id);
173
174 if ( IsRuined() )
175 {
176 return;
177 }
178
179 PlayerBase player = PlayerBase.Cast(parent);
180 if ( parent.GetHierarchyParent() )
181 {
182 player = PlayerBase.Cast(parent.GetHierarchyParent());
183 }
184
185 if ( player )
186 {
187 player.MapNavigationItemNotInPossession(this);
188 }
189 }
190};
191
192//-----------------------------------------------------------------------------
193class CarWheel extends InventoryItemSuper
194{
195 protected string m_AttachSound = "Offroad_Wheel_Attach_SoundSet";
196 protected string m_DetachSound = "Offroad_Wheel_Remove_SoundSet";
197
199 proto native float GetRadius();
200
202 proto native float GetWidth();
203
204 override bool DisplayNameRuinAttach()
205 {
206 return true;
207 }
208
209 override bool ShowZonesHealth()
210 {
211 return true;
212 }
213
215 {
216 string newWheel = "";
217 switch (GetType())
218 {
219 case "HatchbackWheel":
220 newWheel = "HatchbackWheel_Ruined";
221 break;
222
223 case "CivSedanWheel":
224 newWheel = "CivSedanWheel_Ruined";
225 break;
226
227 case "Hatchback_02_Wheel":
228 newWheel = "Hatchback_02_Wheel_Ruined";
229 break;
230
231 case "Sedan_02_Wheel":
232 newWheel = "Sedan_02_Wheel_Ruined";
233 break;
234
235 case "Truck_01_Wheel":
236 newWheel = "Truck_01_Wheel_Ruined";
237 break;
238
239 case "Truck_01_WheelDouble":
240 newWheel = "Truck_01_WheelDouble_Ruined";
241 break;
242
243 case "Offroad_02_Wheel":
244 newWheel = "Offroad_02_Wheel_Ruined";
245 break;
246 }
247 return newWheel;
248 }
249
250 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
251 {
252 super.EEHealthLevelChanged(oldLevel, newLevel, zone);
253
254 if (newLevel == GameConstants.STATE_RUINED)
255 {
256 string newWheel = GetRuinedReplacement();
257
258 if (newWheel != "")
259 {
260 //Unlock to allow creating a new item
261 if (IsLockedInSlot())
262 UnlockFromParent();
263
264 IEntity child = GetChildren();
265 while (child)
266 {
267 RemoveChild(child, false);
268 vector matrix[4];
269 GetTransform(matrix);
270 GetInventory().DropEntityWithTransform(InventoryMode.SERVER, this, EntityAI.Cast(child), matrix);
271 child = GetSibling();
272 }
273
274 ReplaceWheelLambda lambda = new ReplaceWheelLambda(this, newWheel, null);
275 lambda.SetTransferParams(true, true, true);
276 GetInventory().ReplaceItemWithNew(InventoryMode.SERVER, lambda);
277 }
278 }
279 }
280
281 override int GetMeleeTargetType()
282 {
283 return EMeleeTargetType.NONALIGNABLE;
284 }
285
286 override void SetActions()
287 {
288 super.SetActions();
291 }
292
293 override void OnWasAttached(EntityAI parent, int slot_id)
294 {
295 super.OnWasAttached(parent, slot_id);
296
297 #ifndef SERVER
299 effect.SetAutodestroy(true);
300 #endif
301 }
302
303 override void OnWasDetached(EntityAI parent, int slot_id)
304 {
305 super.OnWasDetached(parent, slot_id);
306
307 #ifndef SERVER
309 effect.SetAutodestroy(true);
310 #endif
311 }
312};
313
315{
316 override bool CanPutAsAttachment(EntityAI parent)
317 {
318 // So that the lambda can always put it to the Transport
319 if (parent.IsInherited(Transport) && parent.IsRuined())
320 {
322 if (GetInventory().GetCurrentInventoryLocation(loc))
323 {
324 return loc.GetType() == InventoryLocationType.UNKNOWN;
325 }
326
327 return false;
328 }
329
330 if (!super.CanPutAsAttachment(parent))
331 return false;
332
333 return true;
334 }
335
336 string GetReplacement()
337 {
338 string newWheel = "";
339 switch (GetType())
340 {
341 case "HatchbackWheel_Ruined":
342 newWheel = "HatchbackWheel";
343 break;
344
345 case "CivSedanWheel_Ruined":
346 newWheel = "CivSedanWheel";
347 break;
348
349 case "Hatchback_02_Wheel_Ruined":
350 newWheel = "Hatchback_02_Wheel";
351 break;
352
353 case "Sedan_02_Wheel_Ruined":
354 newWheel = "Sedan_02_Wheel";
355 break;
356
357 case "Truck_01_Wheel_Ruined":
358 newWheel = "Truck_01_Wheel";
359 break;
360
361 case "Truck_01_WheelDouble_Ruined":
362 newWheel = "Truck_01_WheelDouble";
363 break;
364
365 case "Offroad_02_Wheel_Ruined":
366 newWheel = "Offroad_02_Wheel";
367 break;
368 }
369 return newWheel;
370 }
371
372 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
373 {
374 super.EEHealthLevelChanged( oldLevel, newLevel, zone );
375#ifdef DIAG_DEVELOPER
376 // used when fixing the whole car through debug
377 if (newLevel == GameConstants.STATE_PRISTINE)
378 {
379 string newWheel = GetReplacement();
380
381 if (newWheel != "")
382 {
383 //Unlock to allow creating a new item
384 if (IsLockedInSlot())
385 UnlockFromParent();
386
387 ReplaceWheelLambda lambda = new ReplaceWheelLambda(this, newWheel, null);
388 lambda.SetTransferParams(true, true, true);
389 GetInventory().ReplaceItemWithNew(InventoryMode.SERVER, lambda);
390 }
391 }
392#endif
393 }
394
395}
396
398{
400
401 void ReplaceWheelLambda(EntityAI old_item, string new_item_type, PlayerBase player);
402
403 // No super, because we want to skip the LocationCanRemove check...
404 override protected bool CanExecuteLambda()
405 {
406 return m_OldItem != null;
407 }
408
409 override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
410 {
411 super.CopyOldPropertiesToNew(old_item, new_item);
412 m_oldOri = old_item.GetOrientation();
413 }
414
415 override protected void OnSuccess(EntityAI new_item)
416 {
417 super.OnSuccess(new_item);
418
419 if (new_item)
420 new_item.SetOrientation(m_oldOri);
421 }
422}
423
424class Hatchback_02_Wheel extends CarWheel {};
425class Hatchback_02_Wheel_Ruined extends CarWheel_Ruined {};
426
427class Sedan_02_Wheel extends CarWheel {};
428class Sedan_02_Wheel_Ruined extends CarWheel_Ruined {};
429
430class HatchbackWheel extends CarWheel {};
431class HatchbackWheel_Ruined extends CarWheel_Ruined {};
432
433class CivSedanWheel extends CarWheel {};
434class CivSedanWheel_Ruined extends CarWheel_Ruined {};
435
436class Truck_01_Wheel extends CarWheel {};
437class Truck_01_Wheel_Ruined extends CarWheel_Ruined {};
438
439class Truck_01_WheelDouble extends CarWheel {};
440class Truck_01_WheelDouble_Ruined extends CarWheel_Ruined {};
441
442class Offroad_02_Wheel extends CarWheel {};
443class Offroad_02_Wheel_Ruined extends CarWheel_Ruined {};
444
445class CarDoor extends InventoryItemSuper
446{
447
448 override bool CanDetachAttachment(EntityAI parent)
449 {
450 InventoryLocation loc = new InventoryLocation();
451
452 bool isPresent = GetInventory().GetCurrentInventoryLocation( loc );
453
454 if ( !isPresent || loc.GetSlot() == -1 )
455 return false;
456
457 string slotName = InventorySlots.GetSlotName( loc.GetSlot() );
458
459 if ( slotName && CarScript.Cast( parent ).GetCarDoorsState( slotName ) == CarDoorState.DOORS_OPEN )
460 return true;
461
462 return false;
463 }
464
465 override int GetMeleeTargetType()
466 {
467 return EMeleeTargetType.NONALIGNABLE;
468 }
469
470 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
471 {
472 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
473
474 if ( newLevel == GameConstants.STATE_RUINED && m_Initialized )
475 {
476 EffectSound sound_plug;
477 switch ( zone )
478 {
479 case "Window":
480 PlaySoundSet( sound_plug, "offroad_hit_window_small_SoundSet", 0, 0 );
481 break;
482 }
483 }
484 }
485
486 override bool DisplayNameRuinAttach()
487 {
488 return true;
489 }
490
491 override bool ShowZonesHealth()
492 {
493 return true;
494 }
495
496 override void SetActions()
497 {
498 super.SetActions();
499
500 AddAction(ActionAttachOnSelection);
502 }
503
504};
505
506//-------------------------------------
508class Hatchback_02_Door_1_2 extends CarDoor {};
509class Hatchback_02_Door_2_1 extends CarDoor {};
510class Hatchback_02_Door_2_2 extends CarDoor {};
511class Hatchback_02_Hood extends CarDoor {};
512class Hatchback_02_Trunk extends CarDoor {};
513
514class Hatchback_02_Door_1_1_Black extends Hatchback_02_Door_1_1 {};
515class Hatchback_02_Door_1_2_Black extends Hatchback_02_Door_1_2 {};
516class Hatchback_02_Door_2_1_Black extends Hatchback_02_Door_2_1 {};
517class Hatchback_02_Door_2_2_Black extends Hatchback_02_Door_2_2 {};
518class Hatchback_02_Hood_Black extends Hatchback_02_Hood {};
519class Hatchback_02_Trunk_Black extends Hatchback_02_Trunk {};
520
521class Hatchback_02_Door_1_1_Blue extends Hatchback_02_Door_1_1 {};
522class Hatchback_02_Door_1_2_Blue extends Hatchback_02_Door_1_2 {};
523class Hatchback_02_Door_2_1_Blue extends Hatchback_02_Door_2_1 {};
524class Hatchback_02_Door_2_2_Blue extends Hatchback_02_Door_2_2 {};
525class Hatchback_02_Hood_Blue extends Hatchback_02_Hood {};
526class Hatchback_02_Trunk_Blue extends Hatchback_02_Trunk {};
527
528//-------------------------------------
529class Sedan_02_Door_1_1 extends CarDoor {};
530class Sedan_02_Door_1_2 extends CarDoor {};
531class Sedan_02_Door_2_1 extends CarDoor {};
532class Sedan_02_Door_2_2 extends CarDoor {};
533class Sedan_02_Hood extends CarDoor {};
534class Sedan_02_Trunk extends CarDoor {};
535
536class Sedan_02_Door_1_1_YellowRust extends CarDoor {};
537class Sedan_02_Door_1_2_YellowRust extends CarDoor {};
538class Sedan_02_Door_2_1_YellowRust extends CarDoor {};
539class Sedan_02_Door_2_2_YellowRust extends CarDoor {};
540class Sedan_02_Hood_YellowRust extends CarDoor {};
541class Sedan_02_Trunk_YellowRust extends CarDoor {};
542
543class Sedan_02_Door_1_1_Red extends Sedan_02_Door_1_1 {};
544class Sedan_02_Door_1_2_Red extends Sedan_02_Door_1_2 {};
545class Sedan_02_Door_2_1_Red extends Sedan_02_Door_2_1 {};
546class Sedan_02_Door_2_2_Red extends Sedan_02_Door_2_2 {};
547class Sedan_02_Hood_Red extends Sedan_02_Hood {};
548class Sedan_02_Trunk_Red extends Sedan_02_Trunk {};
549
550class Sedan_02_Door_1_1_RedRust extends Sedan_02_Door_1_1 {};
551class Sedan_02_Door_1_2_RedRust extends Sedan_02_Door_1_2 {};
552class Sedan_02_Door_2_1_RedRust extends Sedan_02_Door_2_1 {};
553class Sedan_02_Door_2_2_RedRust extends Sedan_02_Door_2_2 {};
554class Sedan_02_Hood_RedRust extends Sedan_02_Hood {};
555class Sedan_02_Trunk_RedRust extends Sedan_02_Trunk {};
556
557class Sedan_02_Door_1_1_Grey extends Sedan_02_Door_1_1 {};
558class Sedan_02_Door_1_2_Grey extends Sedan_02_Door_1_2 {};
559class Sedan_02_Door_2_1_Grey extends Sedan_02_Door_2_1 {};
560class Sedan_02_Door_2_2_Grey extends Sedan_02_Door_2_2 {};
561class Sedan_02_Hood_Grey extends Sedan_02_Hood {};
562class Sedan_02_Trunk_Grey extends Sedan_02_Trunk {};
563
564class Sedan_02_Door_1_1_GreyRust extends Sedan_02_Door_1_1 {};
565class Sedan_02_Door_1_2_GreyRust extends Sedan_02_Door_1_2 {};
566class Sedan_02_Door_2_1_GreyRust extends Sedan_02_Door_2_1 {};
567class Sedan_02_Door_2_2_GreyRust extends Sedan_02_Door_2_2 {};
568class Sedan_02_Hood_GreyRust extends Sedan_02_Hood {};
569class Sedan_02_Trunk_GreyRust extends Sedan_02_Trunk {};
570
571//-------------------------------------
572class HatchbackDoors_Driver extends CarDoor {};
573class HatchbackDoors_CoDriver extends CarDoor {};
574class HatchbackHood extends CarDoor {};
575class HatchbackTrunk extends CarDoor {};
576
577class HatchbackDoors_Driver_White extends HatchbackDoors_Driver {};
578class HatchbackDoors_CoDriver_White extends HatchbackDoors_CoDriver {};
579class HatchbackHood_White extends HatchbackHood {};
580class HatchbackTrunk_White extends HatchbackTrunk {};
581
582class HatchbackDoors_Driver_Blue extends HatchbackDoors_Driver {};
583class HatchbackDoors_CoDriver_Blue extends HatchbackDoors_CoDriver {};
584class HatchbackHood_Blue extends HatchbackHood {};
585class HatchbackTrunk_Blue extends HatchbackTrunk {};
586
587class HatchbackDoors_Driver_GreenRust extends HatchbackDoors_Driver {};
588class HatchbackDoors_CoDriver_GreenRust extends HatchbackDoors_CoDriver {};
589class HatchbackHood_GreenRust extends HatchbackHood {};
590class HatchbackTrunk_GreenRust extends HatchbackTrunk {};
591
592class HatchbackDoors_Driver_WhiteRust extends HatchbackDoors_Driver {};
593class HatchbackDoors_CoDriver_WhiteRust extends HatchbackDoors_CoDriver {};
594class HatchbackHood_WhiteRust extends HatchbackHood {};
595class HatchbackTrunk_WhiteRust extends HatchbackTrunk {};
596
597class HatchbackDoors_Driver_BlueRust extends HatchbackDoors_Driver {};
598class HatchbackDoors_CoDriver_BlueRust extends HatchbackDoors_CoDriver {};
599class HatchbackHood_BlueRust extends HatchbackHood {};
600class HatchbackTrunk_BlueRust extends HatchbackTrunk {};
601
602//-------------------------------------
603class CivSedanDoors_Driver extends CarDoor {};
604class CivSedanDoors_CoDriver extends CarDoor {};
605class CivSedanDoors_BackLeft extends CarDoor {};
606class CivSedanDoors_BackRight extends CarDoor {};
607class CivSedanHood extends CarDoor {};
608class CivSedanTrunk extends CarDoor {};
609
610class CivSedanDoors_Driver_Black extends CivSedanDoors_Driver {};
611class CivSedanDoors_CoDriver_Black extends CivSedanDoors_CoDriver {};
612class CivSedanDoors_BackLeft_Black extends CivSedanDoors_BackLeft {};
613class CivSedanDoors_BackRight_Black extends CivSedanDoors_BackRight {};
614class CivSedanHood_Black extends CivSedanHood {};
615class CivSedanTrunk_Black extends CivSedanTrunk {};
616
617class CivSedanDoors_Driver_Wine extends CivSedanDoors_Driver {};
618class CivSedanDoors_CoDriver_Wine extends CivSedanDoors_CoDriver {};
619class CivSedanDoors_BackLeft_Wine extends CivSedanDoors_BackLeft {};
620class CivSedanDoors_BackRight_Wine extends CivSedanDoors_BackRight {};
621class CivSedanHood_Wine extends CivSedanHood {};
622class CivSedanTrunk_Wine extends CivSedanTrunk {};
623
624
625class CivSedanDoors_Driver_WhiteRust extends CivSedanDoors_Driver {};
626class CivSedanDoors_CoDriver_WhiteRust extends CivSedanDoors_CoDriver {};
627class CivSedanDoors_BackLeft_WhiteRust extends CivSedanDoors_BackLeft {};
628class CivSedanDoors_BackRight_WhiteRust extends CivSedanDoors_BackRight {};
629class CivSedanHood_WhiteRust extends CivSedanHood {};
630class CivSedanTrunk_WhiteRust extends CivSedanTrunk {};
631
632class CivSedanDoors_Driver_WineRust extends CivSedanDoors_Driver {};
633class CivSedanDoors_CoDriver_WineRust extends CivSedanDoors_CoDriver {};
634class CivSedanDoors_BackLeft_WineRust extends CivSedanDoors_BackLeft {};
635class CivSedanDoors_BackRight_WineRust extends CivSedanDoors_BackRight {};
636class CivSedanHood_WineRust extends CivSedanHood {};
637class CivSedanTrunk_WineRust extends CivSedanTrunk {};
638
639class CivSedanDoors_Driver_BlackRust extends CivSedanDoors_Driver {};
640class CivSedanDoors_CoDriver_BlackRust extends CivSedanDoors_CoDriver {};
641class CivSedanDoors_BackLeft_BlackRust extends CivSedanDoors_BackLeft {};
642class CivSedanDoors_BackRight_BlackRust extends CivSedanDoors_BackRight {};
643class CivSedanHood_BlackRust extends CivSedanHood {};
644class CivSedanTrunk_BlackRust extends CivSedanTrunk {};
645
646
647//-------------------------------------
648class Truck_01_Door_1_1 extends CarDoor {};
649class Truck_01_Door_2_1 extends CarDoor {};
650class Truck_01_Door_Hood extends CarDoor {};
651
652class Truck_01_Door_1_1_Blue extends Truck_01_Door_1_1 {};
653class Truck_01_Door_2_1_Blue extends Truck_01_Door_2_1 {};
654class Truck_01_Door_Hood_Blue extends Truck_01_Door_Hood {};
655
656class Truck_01_Door_1_1_Orange extends Truck_01_Door_1_1 {};
657class Truck_01_Door_2_1_Orange extends Truck_01_Door_2_1 {};
658class Truck_01_Door_Hood_Orange extends Truck_01_Door_Hood {};
659
660class Truck_01_Door_1_1_GreenRust extends Truck_01_Door_1_1 {};
661class Truck_01_Door_2_1_GreenRust extends Truck_01_Door_2_1 {};
662class Truck_01_Hood_GreenRust extends Truck_01_Door_Hood {};
663
664class Truck_01_Door_1_1_BlueRust extends Truck_01_Door_1_1 {};
665class Truck_01_Door_2_1_BlueRust extends Truck_01_Door_2_1 {};
666class Truck_01_Hood_BlueRust extends Truck_01_Door_Hood {};
667
668class Truck_01_Door_1_1_OrangeRust extends Truck_01_Door_1_1 {};
669class Truck_01_Door_2_1_OrangeRust extends Truck_01_Door_2_1 {};
670class Truck_01_Hood_OrangeRust extends Truck_01_Door_Hood {};
671
672
673//-------------------------------------
674class Offroad_02_Door_1_1 extends CarDoor {};
675class Offroad_02_Door_1_2 extends CarDoor {};
676class Offroad_02_Door_2_1 extends CarDoor {};
677class Offroad_02_Door_2_2 extends CarDoor {};
678class Offroad_02_Trunk extends CarDoor {};
679
680class Offroad_02_Hood extends CarDoor
681{
682 override void SetActions()
683 {
684 super.SetActions();
685
687 RemoveAction(ActionAttachOnSelection);
688 }
689};
690
691class Offroad_02_Door_1_1_Rust extends CarDoor {};
692class Offroad_02_Door_1_2_Rust extends CarDoor {};
693class Offroad_02_Door_2_1_Rust extends CarDoor {};
694class Offroad_02_Door_2_2_Rust extends CarDoor {};
695class Offroad_02_Trunk_Rust extends CarDoor {};
696
697//-------------------------------------
699{
700 override bool DisplayNameRuinAttach()
701 {
702 return true;
703 }
704
705 override bool ShowZonesHealth()
706 {
707 return true;
708 }
709
710 override void EEKilled(Object killer)
711 {
712 if ( g_Game.IsServer() )
713 {
714 Car car;
715 EntityAI parent = GetHierarchyParent();
716
717 Class.CastTo( car, parent );
718
719
720 if ( car )
721 {
722 float amount = car.GetFluidFraction( CarFluid.COOLANT );
723 float newAmount = Math.RandomFloat( amount * 0.2, amount * 0.75 );
724
725 car.Leak( CarFluid.COOLANT, newAmount );
726 }
727 }
728 }
729
730 override void SetActions()
731 {
732 super.SetActions();
733
734 AddAction(ActionAttachOnSelection);
736 }
737};
738
739class TruckRadiator extends CarRadiator {};
740
741class TruckExhaust extends ItemBase
742{
743 override void SetActions()
744 {
745 super.SetActions();
746
748 }
749};
750
751class EngineBelt extends ItemBase
752{
753 override void SetActions()
754 {
755 super.SetActions();
756
758 }
759};
760
761class BrakeFluid extends ItemBase {};
762
763class EngineOil extends ItemBase
764{
765 override void SetActions()
766 {
767 super.SetActions();
768
769 AddAction(ActionFillOil);
770 }
771};
772
773class TireRepairKit extends ItemBase
774{
775 override void SetActions()
776 {
777 super.SetActions();
778
779 AddAction(ActionRepairBoatChassis);
780 }
781};
782
783class HeadlightH7 extends ItemBase
784{
785 override bool DisplayNameRuinAttach()
786 {
787 return true;
788 }
789
790 override void SetActions()
791 {
792 super.SetActions();
793
794 AddAction(ActionAttachOnSelection);
796 }
797};
798
799class HeadlightH7_Box extends Box_Base {};
800
801class WindscreenBox extends ItemBase {};
802
803class GlowPlug extends ItemBase
804{
805 override void SetActions()
806 {
807 super.SetActions();
808
811 }
812};
813
814class SparkPlug extends ItemBase
815{
816 override bool DisplayNameRuinAttach()
817 {
818 return true;
819 }
820
821 override bool ShowZonesHealth()
822 {
823 return true;
824 }
825
826 override void SetActions()
827 {
828 super.SetActions();
829
830 AddAction(ActionAttachOnSelection);
832 }
833};
834
835
836//-----------------------------------------------------------------------------
837class Clothing_Base extends ItemBase
838{
839 float m_ItemVisibilityModifier;
840
841 void Clothing_Base()
842 {
843 m_ItemVisibilityModifier = ConfigGetFloat("visibilityModifier");
844 }
845
846 void ~Clothing_Base()
847 {
848 HandleVoiceEffect(false, PlayerBase.Cast(GetHierarchyRootPlayer()));
849 }
850
851 override bool IsClothing()
852 {
853 return true;
854 }
855
856 float GetItemVisibility()
857 {
858 return m_ItemVisibilityModifier;
859 }
860
861 void UpdateNVGStatus(PlayerBase player, bool attaching = false, bool force_disable = false)
862 {
863 bool hasNVGSlot;
864 for (int i = 0; i < GetInventory().GetAttachmentSlotsCount(); ++i)
865 {
866 hasNVGSlot = GetInventory().GetAttachmentSlotId(i) == InventorySlots.GetSlotIdFromString("NVG");
867 if (hasNVGSlot)
868 break;
869 }
870
871 if (player && hasNVGSlot)
872 {
873 NVGoggles nvgAttachment;
874 nvgAttachment = NVGoggles.Cast(FindAttachmentBySlotName("NVG"));
875 if (nvgAttachment)
876 {
877 if (attaching)
878 {
879 if (nvgAttachment.m_Strap && nvgAttachment.m_IsLowered)
880 {
881 nvgAttachment.SetPlayer(player);
882 player.SetNVGLowered(true);
883
884 if (player.IsControlledPlayer())
885 {
886 player.RemoveActiveNV(NVTypes.NV_GOGGLES);
887 player.RemoveActiveNV(NVTypes.NV_GOGGLES_2D);
888 player.RemoveActiveNV(NVTypes.NV_GOGGLES_OFF);
889
890 player.AddActiveNV(nvgAttachment.GetCurrentNVType());
891 }
892 }
893 }
894 else if (force_disable)
895 {
896 nvgAttachment.SetPlayer(null);
897 player.SetNVGLowered(false);
898
899 if (player.IsControlledPlayer())
900 {
901 player.RemoveActiveNV(NVTypes.NV_GOGGLES);
902 player.RemoveActiveNV(NVTypes.NV_GOGGLES_2D);
903 player.RemoveActiveNV(NVTypes.NV_GOGGLES_OFF);
904 }
905 }
906 else // common case during operational state
907 {
908 if (nvgAttachment.m_Strap && nvgAttachment.m_IsLowered)
909 {
910 nvgAttachment.SetPlayer(player);
911 player.SetNVGLowered(true);
912
913 if (player.IsControlledPlayer())
914 {
915 player.RemoveActiveNV(NVTypes.NV_GOGGLES);
916 player.RemoveActiveNV(NVTypes.NV_GOGGLES_2D);
917 player.RemoveActiveNV(NVTypes.NV_GOGGLES_OFF);
918
919 player.AddActiveNV(nvgAttachment.GetCurrentNVType());
920 }
921 }
922 else
923 {
924 player.SetNVGLowered(false);
925 if (player.IsControlledPlayer())
926 {
927 player.RemoveActiveNV(NVTypes.NV_GOGGLES);
928 player.RemoveActiveNV(NVTypes.NV_GOGGLES_2D);
929 player.RemoveActiveNV(NVTypes.NV_GOGGLES_OFF);
930 }
931 }
932 }
933 }
934 else
935 {
936 player.SetNVGLowered(false);
937
938 if (player.IsControlledPlayer())
939 {
940 player.RemoveActiveNV(NVTypes.NV_GOGGLES);
941 player.RemoveActiveNV(NVTypes.NV_GOGGLES_2D);
942 player.RemoveActiveNV(NVTypes.NV_GOGGLES_OFF);
943 }
944 }
945 }
946 }
947
948 override void OnWasAttached(EntityAI parent, int slot_id)
949 {
950 super.OnWasAttached(parent, slot_id);
951
952 if ( slot_id == InventorySlots.HEADGEAR || slot_id == InventorySlots.MASK )
953 HandleVoiceEffect(true, PlayerBase.Cast(GetHierarchyRootPlayer()));
954 }
955
956 override void OnWasDetached(EntityAI parent, int slot_id)
957 {
958 super.OnWasDetached(parent, slot_id);
959
960 HandleVoiceEffect(false, PlayerBase.Cast(parent));
961 }
962
964 bool IsObstructingVoice()
965 {
966 return false;
967 }
968
970 // Better name for this would have been "MufflePlayer" or "ChangeVoiceEffect" (Too late to change in case a mod already uses this)
971 void MutePlayer(PlayerBase player, bool state)
972 {
973 #ifdef SERVER
974 if (g_Game && player.GetIdentity() != null)
975 {
976 g_Game.SetVoiceEffect(player, GetVoiceEffect(), state);
977 }
978 #endif
979 }
980
982 void HandleVoiceEffect(bool enable, PlayerBase player)
983 {
984 if ( IsObstructingVoice() && player )
985 MutePlayer(player, enable);
986 }
987
989 // Options: (VoiceEffectMumbling = 1, VoiceEffectExtortion = 2, VoiceEffectObstruction = 4)
990 int GetVoiceEffect()
991 {
992 return 0;
993 }
994
995 bool IsGasMask()
996 {
997 return false;
998 }
999};
1000
1001//-----------------------------------------------------------------------------
1002class Box_Base extends InventoryItemSuper
1003{
1004 override void SetActions()
1005 {
1006 super.SetActions();
1007 AddAction(ActionUnpackBox);
1008 }
1009};
1010
1011//-----------------------------------------------------------------------------
1012class ItemGrenade extends InventoryItemSuper
1013{
1018 proto native bool SetPinned ();
1023 proto native bool SetUnpinned ();
1028 proto native bool SetIgnited ();
1032 proto native bool IsPinned ();
1036 proto native bool IsActivated ();
1037};
1038
1039typedef ItemGrenade GrenadeBase;
1040
1041//-----------------------------------------------------------------------------
1042class ItemMap extends InventoryItemSuper
1043{
1044 //protected ref array<vector,int,int,string> m_MarkerArray;
1046
1052
1053 void ItemMap()
1054 {
1055 InitMapState();
1056 }
1057
1059 {
1060 string path = "CfgWorlds " + g_Game.GetWorldName();
1061
1062 g_Game.ConfigGetText(path + " mapDisplayNameKey",m_DisplayName);
1063 g_Game.ConfigGetText(path + " mapDescriptionKey",m_Description);
1064 g_Game.ConfigGetText(path + " mapTextureClosed",m_TextureClosed);
1065 g_Game.ConfigGetText(path + " mapTextureOpened",m_TextureOpened);
1066 g_Game.ConfigGetText(path + " mapTextureLegend",m_TextureLegend);
1067
1068 SetObjectTexture(0,m_TextureClosed);
1069 SetObjectTexture(1,m_TextureOpened);
1070 SetObjectTexture(2,m_TextureLegend);
1071
1072 //m_MarkerArray = new array<vector,int,int,string>;
1074 if (g_Game.IsMultiplayer() && g_Game.IsServer())
1075 {
1077 }
1078 }
1079
1080 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
1081 {
1082 super.OnItemLocationChanged(old_owner,new_owner);
1083
1084 SetMapStateOpen(false, PlayerBase.Cast(old_owner));
1085 }
1086
1088 void SetMapStateOpen(bool state, PlayerBase player)
1089 {
1090 if (player)
1091 {
1092 player.SetMapOpen(state);
1093 if (state)
1094 player.OnItemInHandsChanged();
1095 }
1096
1097 if (state)
1098 {
1099 ShowSelection("map_opened");
1100 HideSelection("map_closed");
1101 }
1102 else
1103 {
1104 ShowSelection("map_closed");
1105 HideSelection("map_opened");
1106 }
1107 }
1108
1110 {
1111 if (GetAnimationPhase("map_opened") == 0)
1112 return true;
1113 return false;
1114 }
1115
1117 {
1118 if (m_MapMarkerArray.Count() <= 0)
1119 return;
1120
1121 PlayerIdentity pid;
1122 //Param1<ref array<vector,int,int,string>> params = new Param1<ref array<vector,int,int,string>>( m_MarkerArray );
1123 Param1<ref array<ref MapMarker>> params = new Param1<ref array<ref MapMarker>>( m_MapMarkerArray );
1124
1125 if (g_Game.IsServer() && GetHierarchyRootPlayer()) //TODO do we need PlayerIdentity here?
1126 {
1127 pid = GetHierarchyRootPlayer().GetIdentity();
1128 RPCSingleParam(ERPCs.RPC_SEND_MAP_MARKERS,params,true,pid);
1129 }
1130 else
1131 {
1132 RPCSingleParam(ERPCs.RPC_SEND_MAP_MARKERS,params,true);
1133 }
1134 }
1135
1136 override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
1137 {
1138 super.OnRPC(sender, rpc_type, ctx);
1139
1140 //array<vector,int,int,string> tmp_array = new array<vector,int,int,string>;
1141 //Param1<ref array<vector,int,int,string>> param = new Param1<ref array<vector,int,int,string>>(m_MarkerArray);
1142 Param1<ref array<ref MapMarker>> params = new Param1<ref array<ref MapMarker>>( m_MapMarkerArray );
1143
1144 if (rpc_type == ERPCs.RPC_SEND_MAP_MARKERS)
1145 {
1146 if (ctx.Read(params))
1147 {
1148 //Print("Map | OnRPC | m_MapMarkerArray_new count: " + m_MapMarkerArray_new.Count());
1149 }
1150 }
1151 }
1152
1153 override bool OnStoreLoad(ParamsReadContext ctx, int version)
1154 {
1155 if ( !super.OnStoreLoad(ctx, version) )
1156 return false;
1157
1158 if (version >= 108 && !ctx.Read(m_MapMarkerArray))
1159 {
1160 return false;
1161 }
1162 return true;
1163 }
1164
1166 {
1167 super.OnStoreSave(ctx);
1168
1169 ctx.Write(m_MapMarkerArray);
1170 }
1171
1172 override bool NameOverride(out string output)
1173 {
1174 output = m_DisplayName;
1175
1176 return true;
1177 }
1178
1179 override bool DescriptionOverride(out string output)
1180 {
1181 output = m_Description;
1182
1183 return true;
1184 }
1185
1186 void InsertMarker(vector pos, string text, int color, int idx)
1187 {
1188 ref MapMarker marker = MapMarker(pos,text,color,idx);
1189 m_MapMarkerArray.Insert(marker);
1190 }
1191
1196};
1197
1199{
1201 protected int m_Color;
1202 protected int m_IconIdx;
1203 protected string m_Text;
1204
1205 void MapMarker(vector pos, string text, int color, int idx)
1206 {
1207 m_Position = pos;
1208 m_Text = text;
1209 m_Color = color;
1210 m_IconIdx = idx;
1211 }
1212
1214 {
1215 return m_Position;
1216 }
1217
1219 {
1220 return m_Text;
1221 }
1222
1224 {
1225 return m_Color;
1226 }
1227
1229 {
1230 return m_IconIdx;
1231 }
1232};
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition inventory.c:22
class LogManager EntityAI
eBleedingSourceType GetType()
proto native void SetCanSpeak(bool onOff)
void ReplaceWheelLambda(EntityAI old_item, string new_item_type, PlayerBase player)
CarWheel_Ruined m_oldOri
ItemGrenade GrenadeBase
class ItemBarrel extends InventoryItemSuper TuneNext
proto native bool CanSpeak()
bool CanExecuteLambda()
proto native void TunePrev()
AttachActionData ActionData ActionAttach()
Definition actionattach.c:9
void ActionDetach()
override void OnSuccess(EntityAI new_item)
void AddAction(typename actionName)
void RemoveAction(typename actionName)
void SetActions()
override bool ShowZonesHealth()
CarFluid
Type of vehicle's fluid. (native, do not change or extend).
Definition car.c:19
CarDoorState
Definition carscript.c:2
PlayerSpawnPreset slotName
Wrapper class for managing sound through SEffectManager.
Definition effectsound.c:5
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
array< ref MapMarker > GetMarkerArray()
override void OnWasAttached(EntityAI parent, int slot_id)
proto native float GetWidth()
Returns wheel width.
override int GetMeleeTargetType()
override void OnWasDetached(EntityAI parent, int slot_id)
override void OnStoreSave(ParamsWriteContext ctx)
ref array< ref MapMarker > m_MapMarkerArray
void InsertMarker(vector pos, string text, int color, int idx)
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
void SetMapStateOpen(bool state, PlayerBase player)
displays open/closed selections; 1 == opened
string GetRuinedReplacement()
override bool DisplayNameRuinAttach()
override bool OnStoreLoad(ParamsReadContext ctx, int version)
override bool DescriptionOverride(out string output)
override bool NameOverride(out string output)
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
override bool ShowZonesHealth()
override void SetActions()
proto native float GetRadius()
Returns current wheel radius.
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
InventoryLocation.
override void SetActions()
Definition barbedwire.c:402
override bool ShowZonesHealth()
vector GetMarkerPos()
int GetMarkerColor()
void MapMarker(vector pos, string text, int color, int idx)
vector m_Position
string GetMarkerText()
int GetMarkerIcon()
The class that will be instanced (moddable).
Definition gameplay.c:389
Manager class for managing Effect (EffectParticle, EffectSound).
static EffectSound PlaySound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound.
Native class for boats - handles physics simulation.
Definition boat.c:32
script counterpart to engine's class Weapon
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZGame g_Game
Definition dayzgame.c:3942
EMeleeTargetType
ERPCs
Definition erpcs.c:2
override void EEKilled(Object killer)
Serializer ParamsReadContext
Definition gameplay.c:15
class LOD Object
Serializer ParamsWriteContext
Definition gameplay.c:16
vector GetPosition()
Get the world position of the Effect.
Definition effect.c:473
InventoryLocationType
types of Inventory Location
void OnInventoryEnter(Man player)
Event called on item when it is placed in the player(Man) inventory, passes the owner as a parameter.
Definition itembase.c:8813
void OnInventoryExit(Man player)
Event called on item when it is removed from the player(Man) inventory, passes the old owner as a par...
Definition itembase.c:8825
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Definition itembase.c:6976
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
override void OnWasDetached(EntityAI parent, int slot_id)
bool m_Initialized