Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
inventoryitem.c
Go to the documentation of this file.
2//-----------------------------------------------------------------------------
4{
5};
6
8
9//-----------------------------------------------------------------------------
10class 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//-----------------------------------------------------------------------------
36class ItemRadio extends InventoryItemSuper
37{
38 proto native void TuneNext();
39 proto native void TunePrev();
40};
41
42//-----------------------------------------------------------------------------
43class ItemBarrel extends InventoryItemSuper
44{
45};
46
47//-----------------------------------------------------------------------------
48class UnderSlugLauncher extends Weapon
49{
50};
51
52//-----------------------------------------------------------------------------
53class 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//-----------------------------------------------------------------------------
116class 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//-----------------------------------------------------------------------------
194class 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())
257 UnlockFromParent();
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())
374 UnlockFromParent();
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
413class Hatchback_02_Wheel extends CarWheel {};
414class Hatchback_02_Wheel_Ruined extends CarWheel_Ruined {};
415
416class Sedan_02_Wheel extends CarWheel {};
417class Sedan_02_Wheel_Ruined extends CarWheel_Ruined {};
418
419class HatchbackWheel extends CarWheel {};
420class HatchbackWheel_Ruined extends CarWheel_Ruined {};
421
422class CivSedanWheel extends CarWheel {};
423class CivSedanWheel_Ruined extends CarWheel_Ruined {};
424
425class Truck_01_Wheel extends CarWheel {};
426class Truck_01_Wheel_Ruined extends CarWheel_Ruined {};
427
428class Truck_01_WheelDouble extends CarWheel {};
429class Truck_01_WheelDouble_Ruined extends CarWheel_Ruined {};
430
431class Offroad_02_Wheel extends CarWheel {};
432class Offroad_02_Wheel_Ruined extends CarWheel_Ruined {};
433
434class 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//-------------------------------------
497class Hatchback_02_Door_1_2 extends CarDoor {};
498class Hatchback_02_Door_2_1 extends CarDoor {};
499class Hatchback_02_Door_2_2 extends CarDoor {};
500class Hatchback_02_Hood extends CarDoor {};
501class Hatchback_02_Trunk extends CarDoor {};
502
503class Hatchback_02_Door_1_1_Black extends Hatchback_02_Door_1_1 {};
504class Hatchback_02_Door_1_2_Black extends Hatchback_02_Door_1_2 {};
505class Hatchback_02_Door_2_1_Black extends Hatchback_02_Door_2_1 {};
506class Hatchback_02_Door_2_2_Black extends Hatchback_02_Door_2_2 {};
507class Hatchback_02_Hood_Black extends Hatchback_02_Hood {};
508class Hatchback_02_Trunk_Black extends Hatchback_02_Trunk {};
509
510class Hatchback_02_Door_1_1_Blue extends Hatchback_02_Door_1_1 {};
511class Hatchback_02_Door_1_2_Blue extends Hatchback_02_Door_1_2 {};
512class Hatchback_02_Door_2_1_Blue extends Hatchback_02_Door_2_1 {};
513class Hatchback_02_Door_2_2_Blue extends Hatchback_02_Door_2_2 {};
514class Hatchback_02_Hood_Blue extends Hatchback_02_Hood {};
515class Hatchback_02_Trunk_Blue extends Hatchback_02_Trunk {};
516
517//-------------------------------------
518class Sedan_02_Door_1_1 extends CarDoor {};
519class Sedan_02_Door_1_2 extends CarDoor {};
520class Sedan_02_Door_2_1 extends CarDoor {};
521class Sedan_02_Door_2_2 extends CarDoor {};
522class Sedan_02_Hood extends CarDoor {};
523class Sedan_02_Trunk extends CarDoor {};
524
525class Sedan_02_Door_1_1_YellowRust extends CarDoor {};
526class Sedan_02_Door_1_2_YellowRust extends CarDoor {};
527class Sedan_02_Door_2_1_YellowRust extends CarDoor {};
528class Sedan_02_Door_2_2_YellowRust extends CarDoor {};
529class Sedan_02_Hood_YellowRust extends CarDoor {};
530class Sedan_02_Trunk_YellowRust extends CarDoor {};
531
532class Sedan_02_Door_1_1_Red extends Sedan_02_Door_1_1 {};
533class Sedan_02_Door_1_2_Red extends Sedan_02_Door_1_2 {};
534class Sedan_02_Door_2_1_Red extends Sedan_02_Door_2_1 {};
535class Sedan_02_Door_2_2_Red extends Sedan_02_Door_2_2 {};
536class Sedan_02_Hood_Red extends Sedan_02_Hood {};
537class Sedan_02_Trunk_Red extends Sedan_02_Trunk {};
538
539class Sedan_02_Door_1_1_RedRust extends Sedan_02_Door_1_1 {};
540class Sedan_02_Door_1_2_RedRust extends Sedan_02_Door_1_2 {};
541class Sedan_02_Door_2_1_RedRust extends Sedan_02_Door_2_1 {};
542class Sedan_02_Door_2_2_RedRust extends Sedan_02_Door_2_2 {};
543class Sedan_02_Hood_RedRust extends Sedan_02_Hood {};
544class Sedan_02_Trunk_RedRust extends Sedan_02_Trunk {};
545
546class Sedan_02_Door_1_1_Grey extends Sedan_02_Door_1_1 {};
547class Sedan_02_Door_1_2_Grey extends Sedan_02_Door_1_2 {};
548class Sedan_02_Door_2_1_Grey extends Sedan_02_Door_2_1 {};
549class Sedan_02_Door_2_2_Grey extends Sedan_02_Door_2_2 {};
550class Sedan_02_Hood_Grey extends Sedan_02_Hood {};
551class Sedan_02_Trunk_Grey extends Sedan_02_Trunk {};
552
553class Sedan_02_Door_1_1_GreyRust extends Sedan_02_Door_1_1 {};
554class Sedan_02_Door_1_2_GreyRust extends Sedan_02_Door_1_2 {};
555class Sedan_02_Door_2_1_GreyRust extends Sedan_02_Door_2_1 {};
556class Sedan_02_Door_2_2_GreyRust extends Sedan_02_Door_2_2 {};
557class Sedan_02_Hood_GreyRust extends Sedan_02_Hood {};
558class Sedan_02_Trunk_GreyRust extends Sedan_02_Trunk {};
559
560//-------------------------------------
561class HatchbackDoors_Driver extends CarDoor {};
562class HatchbackDoors_CoDriver extends CarDoor {};
563class HatchbackHood extends CarDoor {};
564class HatchbackTrunk extends CarDoor {};
565
566class HatchbackDoors_Driver_White extends HatchbackDoors_Driver {};
567class HatchbackDoors_CoDriver_White extends HatchbackDoors_CoDriver {};
568class HatchbackHood_White extends HatchbackHood {};
569class HatchbackTrunk_White extends HatchbackTrunk {};
570
571class HatchbackDoors_Driver_Blue extends HatchbackDoors_Driver {};
572class HatchbackDoors_CoDriver_Blue extends HatchbackDoors_CoDriver {};
573class HatchbackHood_Blue extends HatchbackHood {};
574class HatchbackTrunk_Blue extends HatchbackTrunk {};
575
576class HatchbackDoors_Driver_GreenRust extends HatchbackDoors_Driver {};
577class HatchbackDoors_CoDriver_GreenRust extends HatchbackDoors_CoDriver {};
578class HatchbackHood_GreenRust extends HatchbackHood {};
579class HatchbackTrunk_GreenRust extends HatchbackTrunk {};
580
581class HatchbackDoors_Driver_WhiteRust extends HatchbackDoors_Driver {};
582class HatchbackDoors_CoDriver_WhiteRust extends HatchbackDoors_CoDriver {};
583class HatchbackHood_WhiteRust extends HatchbackHood {};
584class HatchbackTrunk_WhiteRust extends HatchbackTrunk {};
585
586class HatchbackDoors_Driver_BlueRust extends HatchbackDoors_Driver {};
587class HatchbackDoors_CoDriver_BlueRust extends HatchbackDoors_CoDriver {};
588class HatchbackHood_BlueRust extends HatchbackHood {};
589class HatchbackTrunk_BlueRust extends HatchbackTrunk {};
590
591//-------------------------------------
592class CivSedanDoors_Driver extends CarDoor {};
593class CivSedanDoors_CoDriver extends CarDoor {};
594class CivSedanDoors_BackLeft extends CarDoor {};
595class CivSedanDoors_BackRight extends CarDoor {};
596class CivSedanHood extends CarDoor {};
597class CivSedanTrunk extends CarDoor {};
598
599class CivSedanDoors_Driver_Black extends CivSedanDoors_Driver {};
600class CivSedanDoors_CoDriver_Black extends CivSedanDoors_CoDriver {};
601class CivSedanDoors_BackLeft_Black extends CivSedanDoors_BackLeft {};
602class CivSedanDoors_BackRight_Black extends CivSedanDoors_BackRight {};
603class CivSedanHood_Black extends CivSedanHood {};
604class CivSedanTrunk_Black extends CivSedanTrunk {};
605
606class CivSedanDoors_Driver_Wine extends CivSedanDoors_Driver {};
607class CivSedanDoors_CoDriver_Wine extends CivSedanDoors_CoDriver {};
608class CivSedanDoors_BackLeft_Wine extends CivSedanDoors_BackLeft {};
609class CivSedanDoors_BackRight_Wine extends CivSedanDoors_BackRight {};
610class CivSedanHood_Wine extends CivSedanHood {};
611class CivSedanTrunk_Wine extends CivSedanTrunk {};
612
613
614class CivSedanDoors_Driver_WhiteRust extends CivSedanDoors_Driver {};
615class CivSedanDoors_CoDriver_WhiteRust extends CivSedanDoors_CoDriver {};
616class CivSedanDoors_BackLeft_WhiteRust extends CivSedanDoors_BackLeft {};
617class CivSedanDoors_BackRight_WhiteRust extends CivSedanDoors_BackRight {};
618class CivSedanHood_WhiteRust extends CivSedanHood {};
619class CivSedanTrunk_WhiteRust extends CivSedanTrunk {};
620
621class CivSedanDoors_Driver_WineRust extends CivSedanDoors_Driver {};
622class CivSedanDoors_CoDriver_WineRust extends CivSedanDoors_CoDriver {};
623class CivSedanDoors_BackLeft_WineRust extends CivSedanDoors_BackLeft {};
624class CivSedanDoors_BackRight_WineRust extends CivSedanDoors_BackRight {};
625class CivSedanHood_WineRust extends CivSedanHood {};
626class CivSedanTrunk_WineRust extends CivSedanTrunk {};
627
628class CivSedanDoors_Driver_BlackRust extends CivSedanDoors_Driver {};
629class CivSedanDoors_CoDriver_BlackRust extends CivSedanDoors_CoDriver {};
630class CivSedanDoors_BackLeft_BlackRust extends CivSedanDoors_BackLeft {};
631class CivSedanDoors_BackRight_BlackRust extends CivSedanDoors_BackRight {};
632class CivSedanHood_BlackRust extends CivSedanHood {};
633class CivSedanTrunk_BlackRust extends CivSedanTrunk {};
634
635
636//-------------------------------------
637class Truck_01_Door_1_1 extends CarDoor {};
638class Truck_01_Door_2_1 extends CarDoor {};
639class Truck_01_Door_Hood extends CarDoor {};
640
641class Truck_01_Door_1_1_Blue extends Truck_01_Door_1_1 {};
642class Truck_01_Door_2_1_Blue extends Truck_01_Door_2_1 {};
643class Truck_01_Door_Hood_Blue extends Truck_01_Door_Hood {};
644
645class Truck_01_Door_1_1_Orange extends Truck_01_Door_1_1 {};
646class Truck_01_Door_2_1_Orange extends Truck_01_Door_2_1 {};
647class Truck_01_Door_Hood_Orange extends Truck_01_Door_Hood {};
648
649class Truck_01_Door_1_1_GreenRust extends Truck_01_Door_1_1 {};
650class Truck_01_Door_2_1_GreenRust extends Truck_01_Door_2_1 {};
651class Truck_01_Hood_GreenRust extends Truck_01_Door_Hood {};
652
653class Truck_01_Door_1_1_BlueRust extends Truck_01_Door_1_1 {};
654class Truck_01_Door_2_1_BlueRust extends Truck_01_Door_2_1 {};
655class Truck_01_Hood_BlueRust extends Truck_01_Door_Hood {};
656
657class Truck_01_Door_1_1_OrangeRust extends Truck_01_Door_1_1 {};
658class Truck_01_Door_2_1_OrangeRust extends Truck_01_Door_2_1 {};
659class Truck_01_Hood_OrangeRust extends Truck_01_Door_Hood {};
660
661
662//-------------------------------------
663class Offroad_02_Door_1_1 extends CarDoor {};
664class Offroad_02_Door_1_2 extends CarDoor {};
665class Offroad_02_Door_2_1 extends CarDoor {};
666class Offroad_02_Door_2_2 extends CarDoor {};
667class Offroad_02_Trunk extends CarDoor {};
668
669class Offroad_02_Hood extends CarDoor
670{
671 override void SetActions()
672 {
673 super.SetActions();
674
677 }
678};
679
680class Offroad_02_Door_1_1_Rust extends CarDoor {};
681class Offroad_02_Door_1_2_Rust extends CarDoor {};
682class Offroad_02_Door_2_1_Rust extends CarDoor {};
683class Offroad_02_Door_2_2_Rust extends CarDoor {};
684class Offroad_02_Trunk_Rust extends CarDoor {};
685
686//-------------------------------------
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
728class TruckRadiator extends CarRadiator {};
729
730class TruckExhaust extends ItemBase
731{
732 override void SetActions()
733 {
734 super.SetActions();
735
736 AddAction(ActionAttach);
737 }
738};
739
740class EngineBelt extends ItemBase
741{
742 override void SetActions()
743 {
744 super.SetActions();
745
746 AddAction(ActionAttach);
747 }
748};
749
750class BrakeFluid extends ItemBase {};
751
752class EngineOil extends ItemBase
753{
754 override void SetActions()
755 {
756 super.SetActions();
757
759 }
760};
761
762class TireRepairKit extends ItemBase
763{
764 override void SetActions()
765 {
766 super.SetActions();
767
769 }
770};
771
772class HeadlightH7 extends ItemBase
773{
774 override bool DisplayNameRuinAttach()
775 {
776 return true;
777 }
778
779 override void SetActions()
780 {
781 super.SetActions();
782
785 }
786};
787
788class HeadlightH7_Box extends Box_Base {};
789
790class WindscreenBox extends ItemBase {};
791
792class GlowPlug extends ItemBase
793{
794 override void SetActions()
795 {
796 super.SetActions();
797
799 AddAction(ActionAttach);
800 }
801};
802
803class SparkPlug extends ItemBase
804{
805 override bool DisplayNameRuinAttach()
806 {
807 return true;
808 }
809
810 override bool ShowZonesHealth()
811 {
812 return true;
813 }
814
815 override void SetActions()
816 {
817 super.SetActions();
818
821 }
822};
823
824
825//-----------------------------------------------------------------------------
826class Clothing_Base extends ItemBase
827{
828 float m_ItemVisibilityModifier;
829
830 void Clothing_Base()
831 {
832 m_ItemVisibilityModifier = ConfigGetFloat("visibilityModifier");
833 }
834
835 void ~Clothing_Base()
836 {
837 HandleVoiceEffect(false, PlayerBase.Cast(GetHierarchyRootPlayer()));
838 }
839
840 override bool IsClothing()
841 {
842 return true;
843 }
844
845 float GetItemVisibility()
846 {
847 return m_ItemVisibilityModifier;
848 }
849
850 void UpdateNVGStatus(PlayerBase player, bool attaching = false, bool force_disable = false)
851 {
852 bool hasNVGSlot;
853 for (int i = 0; i < GetInventory().GetAttachmentSlotsCount(); ++i)
854 {
855 hasNVGSlot = GetInventory().GetAttachmentSlotId(i) == InventorySlots.GetSlotIdFromString("NVG");
856 if (hasNVGSlot)
857 break;
858 }
859
860 if (player && hasNVGSlot)
861 {
862 NVGoggles nvgAttachment;
863 nvgAttachment = NVGoggles.Cast(FindAttachmentBySlotName("NVG"));
864 if (nvgAttachment)
865 {
866 if (attaching)
867 {
868 if (nvgAttachment.m_Strap && nvgAttachment.m_IsLowered)
869 {
870 nvgAttachment.SetPlayer(player);
871 player.SetNVGLowered(true);
872
873 if (player.IsControlledPlayer())
874 {
875 player.RemoveActiveNV(NVTypes.NV_GOGGLES);
876 player.RemoveActiveNV(NVTypes.NV_GOGGLES_2D);
877 player.RemoveActiveNV(NVTypes.NV_GOGGLES_OFF);
878
879 player.AddActiveNV(nvgAttachment.GetCurrentNVType());
880 }
881 }
882 }
883 else if (force_disable)
884 {
885 nvgAttachment.SetPlayer(null);
886 player.SetNVGLowered(false);
887
888 if (player.IsControlledPlayer())
889 {
890 player.RemoveActiveNV(NVTypes.NV_GOGGLES);
891 player.RemoveActiveNV(NVTypes.NV_GOGGLES_2D);
892 player.RemoveActiveNV(NVTypes.NV_GOGGLES_OFF);
893 }
894 }
895 else // common case during operational state
896 {
897 if (nvgAttachment.m_Strap && nvgAttachment.m_IsLowered)
898 {
899 nvgAttachment.SetPlayer(player);
900 player.SetNVGLowered(true);
901
902 if (player.IsControlledPlayer())
903 {
904 player.RemoveActiveNV(NVTypes.NV_GOGGLES);
905 player.RemoveActiveNV(NVTypes.NV_GOGGLES_2D);
906 player.RemoveActiveNV(NVTypes.NV_GOGGLES_OFF);
907
908 player.AddActiveNV(nvgAttachment.GetCurrentNVType());
909 }
910 }
911 else
912 {
913 player.SetNVGLowered(false);
914 if (player.IsControlledPlayer())
915 {
916 player.RemoveActiveNV(NVTypes.NV_GOGGLES);
917 player.RemoveActiveNV(NVTypes.NV_GOGGLES_2D);
918 player.RemoveActiveNV(NVTypes.NV_GOGGLES_OFF);
919 }
920 }
921 }
922 }
923 else
924 {
925 player.SetNVGLowered(false);
926
927 if (player.IsControlledPlayer())
928 {
929 player.RemoveActiveNV(NVTypes.NV_GOGGLES);
930 player.RemoveActiveNV(NVTypes.NV_GOGGLES_2D);
931 player.RemoveActiveNV(NVTypes.NV_GOGGLES_OFF);
932 }
933 }
934 }
935 }
936
937 override void OnWasAttached(EntityAI parent, int slot_id)
938 {
939 super.OnWasAttached(parent, slot_id);
940
941 if ( slot_id == InventorySlots.HEADGEAR || slot_id == InventorySlots.MASK )
942 HandleVoiceEffect(true, PlayerBase.Cast(GetHierarchyRootPlayer()));
943 }
944
945 override void OnWasDetached(EntityAI parent, int slot_id)
946 {
947 super.OnWasDetached(parent, slot_id);
948
949 HandleVoiceEffect(false, PlayerBase.Cast(parent));
950 }
951
953 bool IsObstructingVoice()
954 {
955 return false;
956 }
957
959 // Better name for this would have been "MufflePlayer" or "ChangeVoiceEffect" (Too late to change in case a mod already uses this)
960 void MutePlayer(PlayerBase player, bool state)
961 {
962 #ifdef SERVER
963 if (GetGame() && player.GetIdentity() != null)
964 {
965 GetGame().SetVoiceEffect(player, GetVoiceEffect(), state);
966 }
967 #endif
968 }
969
971 void HandleVoiceEffect(bool enable, PlayerBase player)
972 {
973 if ( IsObstructingVoice() && player )
974 MutePlayer(player, enable);
975 }
976
978 // Options: (VoiceEffectMumbling = 1, VoiceEffectExtortion = 2, VoiceEffectObstruction = 4)
979 int GetVoiceEffect()
980 {
981 return 0;
982 }
983
984 bool IsGasMask()
985 {
986 return false;
987 }
988};
989
990//-----------------------------------------------------------------------------
991class Box_Base extends InventoryItemSuper
992{
993 override void SetActions()
994 {
995 super.SetActions();
997 }
998};
999
1000//-----------------------------------------------------------------------------
1001class ItemGrenade extends InventoryItemSuper
1002{
1007 proto native bool SetPinned ();
1012 proto native bool SetUnpinned ();
1017 proto native bool SetIgnited ();
1021 proto native bool IsPinned ();
1025 proto native bool IsActivated ();
1026};
1027
1028typedef ItemGrenade GrenadeBase;
1029
1030//-----------------------------------------------------------------------------
1031class ItemMap extends InventoryItemSuper
1032{
1033 //protected ref array<vector,int,int,string> m_MarkerArray;
1035
1041
1042 void ItemMap()
1043 {
1044 InitMapState();
1045 }
1046
1048 {
1049 string path = "CfgWorlds " + GetGame().GetWorldName();
1050
1051 GetGame().ConfigGetText(path + " mapDisplayNameKey",m_DisplayName);
1052 GetGame().ConfigGetText(path + " mapDescriptionKey",m_Description);
1053 GetGame().ConfigGetText(path + " mapTextureClosed",m_TextureClosed);
1054 GetGame().ConfigGetText(path + " mapTextureOpened",m_TextureOpened);
1055 GetGame().ConfigGetText(path + " mapTextureLegend",m_TextureLegend);
1056
1057 SetObjectTexture(0,m_TextureClosed);
1058 SetObjectTexture(1,m_TextureOpened);
1059 SetObjectTexture(2,m_TextureLegend);
1060
1061 //m_MarkerArray = new array<vector,int,int,string>;
1062 m_MapMarkerArray = new array<ref MapMarker>;
1063 if (GetGame().IsMultiplayer() && GetGame().IsServer())
1064 {
1065 SyncMapMarkers();
1066 }
1067 }
1068
1069 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
1070 {
1071 super.OnItemLocationChanged(old_owner,new_owner);
1072
1073 SetMapStateOpen(false, PlayerBase.Cast(old_owner));
1074 }
1075
1077 void SetMapStateOpen(bool state, PlayerBase player)
1078 {
1079 if (player)
1080 {
1081 player.SetMapOpen(state);
1082 if (state)
1083 player.OnItemInHandsChanged();
1084 }
1085
1086 if (state)
1087 {
1088 ShowSelection("map_opened");
1089 HideSelection("map_closed");
1090 }
1091 else
1092 {
1093 ShowSelection("map_closed");
1094 HideSelection("map_opened");
1095 }
1096 }
1097
1099 {
1100 if (GetAnimationPhase("map_opened") == 0)
1101 return true;
1102 return false;
1103 }
1104
1106 {
1107 if (m_MapMarkerArray.Count() <= 0)
1108 return;
1109
1110 PlayerIdentity pid;
1111 //Param1<ref array<vector,int,int,string>> params = new Param1<ref array<vector,int,int,string>>( m_MarkerArray );
1112 Param1<ref array<ref MapMarker>> params = new Param1<ref array<ref MapMarker>>( m_MapMarkerArray );
1113
1114 if (GetGame().IsServer() && GetHierarchyRootPlayer()) //TODO do we need PlayerIdentity here?
1115 {
1116 pid = GetHierarchyRootPlayer().GetIdentity();
1117 RPCSingleParam(ERPCs.RPC_SEND_MAP_MARKERS,params,true,pid);
1118 }
1119 else
1120 {
1121 RPCSingleParam(ERPCs.RPC_SEND_MAP_MARKERS,params,true);
1122 }
1123 }
1124
1125 override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
1126 {
1127 super.OnRPC(sender, rpc_type, ctx);
1128
1129 //array<vector,int,int,string> tmp_array = new array<vector,int,int,string>;
1130 //Param1<ref array<vector,int,int,string>> param = new Param1<ref array<vector,int,int,string>>(m_MarkerArray);
1131 Param1<ref array<ref MapMarker>> params = new Param1<ref array<ref MapMarker>>( m_MapMarkerArray );
1132
1133 if (rpc_type == ERPCs.RPC_SEND_MAP_MARKERS)
1134 {
1135 if (ctx.Read(params))
1136 {
1137 //Print("Map | OnRPC | m_MapMarkerArray_new count: " + m_MapMarkerArray_new.Count());
1138 }
1139 }
1140 }
1141
1142 override bool OnStoreLoad(ParamsReadContext ctx, int version)
1143 {
1144 if ( !super.OnStoreLoad(ctx, version) )
1145 return false;
1146
1147 if (version >= 108 && !ctx.Read(m_MapMarkerArray))
1148 {
1149 return false;
1150 }
1151 return true;
1152 }
1153
1155 {
1156 super.OnStoreSave(ctx);
1157
1158 ctx.Write(m_MapMarkerArray);
1159 }
1160
1161 override bool NameOverride(out string output)
1162 {
1163 output = m_DisplayName;
1164
1165 return true;
1166 }
1167
1168 override bool DescriptionOverride(out string output)
1169 {
1170 output = m_Description;
1171
1172 return true;
1173 }
1174
1175 void InsertMarker(vector pos, string text, int color, int idx)
1176 {
1177 ref MapMarker marker = MapMarker(pos,text,color,idx);
1178 m_MapMarkerArray.Insert(marker);
1179 }
1180
1182 {
1183 return m_MapMarkerArray;
1184 }
1185};
1186
1188{
1190 protected int m_Color;
1191 protected int m_IconIdx;
1192 protected string m_Text;
1193
1194 void MapMarker(vector pos, string text, int color, int idx)
1195 {
1196 m_Position = pos;
1197 m_Text = text;
1198 m_Color = color;
1199 m_IconIdx = idx;
1200 }
1201
1203 {
1204 return m_Position;
1205 }
1206
1208 {
1209 return m_Text;
1210 }
1211
1213 {
1214 return m_Color;
1215 }
1216
1218 {
1219 return m_IconIdx;
1220 }
1221};
bool m_Initialized
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition inventory.c:22
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()
ItemSuppressor SuppressorBase
bool CanExecuteLambda()
proto native void TunePrev()
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
override int GetCarDoorsState(string slotType)
Super root of all classes in Enforce script.
Definition enscript.c:11
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
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.
provides access to slot configuration
vector GetMarkerPos()
int GetMarkerColor()
void MapMarker(vector pos, string text, int color, int idx)
vector m_Position
string GetMarkerText()
int GetMarkerIcon()
Definition enmath.c:7
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.
Serialization general interface. Serializer API works with:
Definition serializer.c:56
Native class for boats - handles physics simulation.
Definition boat.c:28
script counterpart to engine's class Weapon
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
EMeleeTargetType
ERPCs
Definition erpcs.c:2
override void EEKilled(Object killer)
proto native CGame GetGame()
string m_Description
class purpose description
Definition enentity.c:847
class JsonUndergroundAreaTriggerData GetPosition
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:8708
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:8721
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Definition itembase.c:6900
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
override void OnWasDetached(EntityAI parent, int slot_id)