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