DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
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{
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())
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
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 {
439 //parent.FindAtt
441
442 bool isPresent = GetInventory().GetCurrentInventoryLocation( loc );
443
444 if ( !isPresent || loc.GetSlot() == -1 )
445 return false;
446
447 string slotName = InventorySlots.GetSlotName( loc.GetSlot() );
448
449 if ( slotName && CarScript.Cast( parent ).GetCarDoorsState( slotName ) == CarDoorState.DOORS_OPEN )
450 return true;
451
452 return false;
453 }
454
455 override int GetMeleeTargetType()
456 {
457 return EMeleeTargetType.NONALIGNABLE;
458 }
459
460 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
461 {
462 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
463
464 if ( newLevel == GameConstants.STATE_RUINED && m_Initialized )
465 {
466 EffectSound sound_plug;
467 switch ( zone )
468 {
469 case "Window":
470 PlaySoundSet( sound_plug, "offroad_hit_window_small_SoundSet", 0, 0 );
471 break;
472 }
473 }
474 }
475
476 override bool DisplayNameRuinAttach()
477 {
478 return true;
479 }
480
481 override bool ShowZonesHealth()
482 {
483 return true;
484 }
485
486 override void SetActions()
487 {
488 super.SetActions();
489
492 }
493
494};
495
496//-------------------------------------
498class Hatchback_02_Door_1_2 extends CarDoor {};
499class Hatchback_02_Door_2_1 extends CarDoor {};
500class Hatchback_02_Door_2_2 extends CarDoor {};
501class Hatchback_02_Hood extends CarDoor {};
502class Hatchback_02_Trunk extends CarDoor {};
503
504class Hatchback_02_Door_1_1_Black extends Hatchback_02_Door_1_1 {};
505class Hatchback_02_Door_1_2_Black extends Hatchback_02_Door_1_2 {};
506class Hatchback_02_Door_2_1_Black extends Hatchback_02_Door_2_1 {};
507class Hatchback_02_Door_2_2_Black extends Hatchback_02_Door_2_2 {};
508class Hatchback_02_Hood_Black extends Hatchback_02_Hood {};
509class Hatchback_02_Trunk_Black extends Hatchback_02_Trunk {};
510
511class Hatchback_02_Door_1_1_Blue extends Hatchback_02_Door_1_1 {};
512class Hatchback_02_Door_1_2_Blue extends Hatchback_02_Door_1_2 {};
513class Hatchback_02_Door_2_1_Blue extends Hatchback_02_Door_2_1 {};
514class Hatchback_02_Door_2_2_Blue extends Hatchback_02_Door_2_2 {};
515class Hatchback_02_Hood_Blue extends Hatchback_02_Hood {};
516class Hatchback_02_Trunk_Blue extends Hatchback_02_Trunk {};
517
518//-------------------------------------
519class Sedan_02_Door_1_1 extends CarDoor {};
520class Sedan_02_Door_1_2 extends CarDoor {};
521class Sedan_02_Door_2_1 extends CarDoor {};
522class Sedan_02_Door_2_2 extends CarDoor {};
523class Sedan_02_Hood extends CarDoor {};
524class Sedan_02_Trunk extends CarDoor {};
525
526class Sedan_02_Door_1_1_YellowRust extends CarDoor {};
527class Sedan_02_Door_1_2_YellowRust extends CarDoor {};
528class Sedan_02_Door_2_1_YellowRust extends CarDoor {};
529class Sedan_02_Door_2_2_YellowRust extends CarDoor {};
530class Sedan_02_Hood_YellowRust extends CarDoor {};
531class Sedan_02_Trunk_YellowRust extends CarDoor {};
532
533class Sedan_02_Door_1_1_Red extends Sedan_02_Door_1_1 {};
534class Sedan_02_Door_1_2_Red extends Sedan_02_Door_1_2 {};
535class Sedan_02_Door_2_1_Red extends Sedan_02_Door_2_1 {};
536class Sedan_02_Door_2_2_Red extends Sedan_02_Door_2_2 {};
537class Sedan_02_Hood_Red extends Sedan_02_Hood {};
538class Sedan_02_Trunk_Red extends Sedan_02_Trunk {};
539
540class Sedan_02_Door_1_1_RedRust extends Sedan_02_Door_1_1 {};
541class Sedan_02_Door_1_2_RedRust extends Sedan_02_Door_1_2 {};
542class Sedan_02_Door_2_1_RedRust extends Sedan_02_Door_2_1 {};
543class Sedan_02_Door_2_2_RedRust extends Sedan_02_Door_2_2 {};
544class Sedan_02_Hood_RedRust extends Sedan_02_Hood {};
545class Sedan_02_Trunk_RedRust extends Sedan_02_Trunk {};
546
547class Sedan_02_Door_1_1_Grey extends Sedan_02_Door_1_1 {};
548class Sedan_02_Door_1_2_Grey extends Sedan_02_Door_1_2 {};
549class Sedan_02_Door_2_1_Grey extends Sedan_02_Door_2_1 {};
550class Sedan_02_Door_2_2_Grey extends Sedan_02_Door_2_2 {};
551class Sedan_02_Hood_Grey extends Sedan_02_Hood {};
552class Sedan_02_Trunk_Grey extends Sedan_02_Trunk {};
553
554class Sedan_02_Door_1_1_GreyRust extends Sedan_02_Door_1_1 {};
555class Sedan_02_Door_1_2_GreyRust extends Sedan_02_Door_1_2 {};
556class Sedan_02_Door_2_1_GreyRust extends Sedan_02_Door_2_1 {};
557class Sedan_02_Door_2_2_GreyRust extends Sedan_02_Door_2_2 {};
558class Sedan_02_Hood_GreyRust extends Sedan_02_Hood {};
559class Sedan_02_Trunk_GreyRust extends Sedan_02_Trunk {};
560
561//-------------------------------------
562class HatchbackDoors_Driver extends CarDoor {};
563class HatchbackDoors_CoDriver extends CarDoor {};
564class HatchbackHood extends CarDoor {};
565class HatchbackTrunk extends CarDoor {};
566
567class HatchbackDoors_Driver_White extends HatchbackDoors_Driver {};
568class HatchbackDoors_CoDriver_White extends HatchbackDoors_CoDriver {};
569class HatchbackHood_White extends HatchbackHood {};
570class HatchbackTrunk_White extends HatchbackTrunk {};
571
572class HatchbackDoors_Driver_Blue extends HatchbackDoors_Driver {};
573class HatchbackDoors_CoDriver_Blue extends HatchbackDoors_CoDriver {};
574class HatchbackHood_Blue extends HatchbackHood {};
575class HatchbackTrunk_Blue extends HatchbackTrunk {};
576
577class HatchbackDoors_Driver_GreenRust extends HatchbackDoors_Driver {};
578class HatchbackDoors_CoDriver_GreenRust extends HatchbackDoors_CoDriver {};
579class HatchbackHood_GreenRust extends HatchbackHood {};
580class HatchbackTrunk_GreenRust extends HatchbackTrunk {};
581
582class HatchbackDoors_Driver_WhiteRust extends HatchbackDoors_Driver {};
583class HatchbackDoors_CoDriver_WhiteRust extends HatchbackDoors_CoDriver {};
584class HatchbackHood_WhiteRust extends HatchbackHood {};
585class HatchbackTrunk_WhiteRust extends HatchbackTrunk {};
586
587class HatchbackDoors_Driver_BlueRust extends HatchbackDoors_Driver {};
588class HatchbackDoors_CoDriver_BlueRust extends HatchbackDoors_CoDriver {};
589class HatchbackHood_BlueRust extends HatchbackHood {};
590class HatchbackTrunk_BlueRust extends HatchbackTrunk {};
591
592//-------------------------------------
593class CivSedanDoors_Driver extends CarDoor {};
594class CivSedanDoors_CoDriver extends CarDoor {};
595class CivSedanDoors_BackLeft extends CarDoor {};
596class CivSedanDoors_BackRight extends CarDoor {};
597class CivSedanHood extends CarDoor {};
598class CivSedanTrunk extends CarDoor {};
599
600class CivSedanDoors_Driver_Black extends CivSedanDoors_Driver {};
601class CivSedanDoors_CoDriver_Black extends CivSedanDoors_CoDriver {};
602class CivSedanDoors_BackLeft_Black extends CivSedanDoors_BackLeft {};
603class CivSedanDoors_BackRight_Black extends CivSedanDoors_BackRight {};
604class CivSedanHood_Black extends CivSedanHood {};
605class CivSedanTrunk_Black extends CivSedanTrunk {};
606
607class CivSedanDoors_Driver_Wine extends CivSedanDoors_Driver {};
608class CivSedanDoors_CoDriver_Wine extends CivSedanDoors_CoDriver {};
609class CivSedanDoors_BackLeft_Wine extends CivSedanDoors_BackLeft {};
610class CivSedanDoors_BackRight_Wine extends CivSedanDoors_BackRight {};
611class CivSedanHood_Wine extends CivSedanHood {};
612class CivSedanTrunk_Wine extends CivSedanTrunk {};
613
614
615class CivSedanDoors_Driver_WhiteRust extends CivSedanDoors_Driver {};
616class CivSedanDoors_CoDriver_WhiteRust extends CivSedanDoors_CoDriver {};
617class CivSedanDoors_BackLeft_WhiteRust extends CivSedanDoors_BackLeft {};
618class CivSedanDoors_BackRight_WhiteRust extends CivSedanDoors_BackRight {};
619class CivSedanHood_WhiteRust extends CivSedanHood {};
620class CivSedanTrunk_WhiteRust extends CivSedanTrunk {};
621
622class CivSedanDoors_Driver_WineRust extends CivSedanDoors_Driver {};
623class CivSedanDoors_CoDriver_WineRust extends CivSedanDoors_CoDriver {};
624class CivSedanDoors_BackLeft_WineRust extends CivSedanDoors_BackLeft {};
625class CivSedanDoors_BackRight_WineRust extends CivSedanDoors_BackRight {};
626class CivSedanHood_WineRust extends CivSedanHood {};
627class CivSedanTrunk_WineRust extends CivSedanTrunk {};
628
629class CivSedanDoors_Driver_BlackRust extends CivSedanDoors_Driver {};
630class CivSedanDoors_CoDriver_BlackRust extends CivSedanDoors_CoDriver {};
631class CivSedanDoors_BackLeft_BlackRust extends CivSedanDoors_BackLeft {};
632class CivSedanDoors_BackRight_BlackRust extends CivSedanDoors_BackRight {};
633class CivSedanHood_BlackRust extends CivSedanHood {};
634class CivSedanTrunk_BlackRust extends CivSedanTrunk {};
635
636
637//-------------------------------------
638class Truck_01_Door_1_1 extends CarDoor {};
639class Truck_01_Door_2_1 extends CarDoor {};
640class Truck_01_Door_Hood extends CarDoor {};
641
642class Truck_01_Door_1_1_Blue extends Truck_01_Door_1_1 {};
643class Truck_01_Door_2_1_Blue extends Truck_01_Door_2_1 {};
644class Truck_01_Door_Hood_Blue extends Truck_01_Door_Hood {};
645
646class Truck_01_Door_1_1_Orange extends Truck_01_Door_1_1 {};
647class Truck_01_Door_2_1_Orange extends Truck_01_Door_2_1 {};
648class Truck_01_Door_Hood_Orange extends Truck_01_Door_Hood {};
649
650class Truck_01_Door_1_1_GreenRust extends Truck_01_Door_1_1 {};
651class Truck_01_Door_2_1_GreenRust extends Truck_01_Door_2_1 {};
652class Truck_01_Hood_GreenRust extends Truck_01_Door_Hood {};
653
654class Truck_01_Door_1_1_BlueRust extends Truck_01_Door_1_1 {};
655class Truck_01_Door_2_1_BlueRust extends Truck_01_Door_2_1 {};
656class Truck_01_Hood_BlueRust extends Truck_01_Door_Hood {};
657
658class Truck_01_Door_1_1_OrangeRust extends Truck_01_Door_1_1 {};
659class Truck_01_Door_2_1_OrangeRust extends Truck_01_Door_2_1 {};
660class Truck_01_Hood_OrangeRust extends Truck_01_Door_Hood {};
661
662
663//-------------------------------------
664class Offroad_02_Door_1_1 extends CarDoor {};
665class Offroad_02_Door_1_2 extends CarDoor {};
666class Offroad_02_Door_2_1 extends CarDoor {};
667class Offroad_02_Door_2_2 extends CarDoor {};
668class Offroad_02_Trunk extends CarDoor {};
669
670class Offroad_02_Hood extends CarDoor
671{
672 override void SetActions()
673 {
674 super.SetActions();
675
678 }
679};
680
681class Offroad_02_Door_1_1_Rust extends CarDoor {};
682class Offroad_02_Door_1_2_Rust extends CarDoor {};
683class Offroad_02_Door_2_1_Rust extends CarDoor {};
684class Offroad_02_Door_2_2_Rust extends CarDoor {};
685class Offroad_02_Trunk_Rust extends CarDoor {};
686
687//-------------------------------------
689{
690 override bool DisplayNameRuinAttach()
691 {
692 return true;
693 }
694
695 override bool ShowZonesHealth()
696 {
697 return true;
698 }
699
700 override void EEKilled(Object killer)
701 {
702 if ( GetGame().IsServer() )
703 {
704 Car car;
705 EntityAI parent = GetHierarchyParent();
706
707 Class.CastTo( car, parent );
708
709
710 if ( car )
711 {
712 float amount = car.GetFluidFraction( CarFluid.COOLANT );
713 float newAmount = Math.RandomFloat( amount * 0.2, amount * 0.75 );
714
715 car.Leak( CarFluid.COOLANT, newAmount );
716 }
717 }
718 }
719
720 override void SetActions()
721 {
722 super.SetActions();
723
726 }
727};
728
729class TruckRadiator extends CarRadiator {};
730
731class TruckExhaust extends ItemBase
732{
733 override void SetActions()
734 {
735 super.SetActions();
736
738 }
739};
740
741class EngineBelt extends ItemBase
742{
743 override void SetActions()
744 {
745 super.SetActions();
746
748 }
749};
750
751class BrakeFluid extends ItemBase {};
752
753class EngineOil extends ItemBase
754{
755 override void SetActions()
756 {
757 super.SetActions();
758
760 }
761};
762
763class TireRepairKit extends ItemBase {};
764
765class HeadlightH7 extends ItemBase
766{
767 override bool DisplayNameRuinAttach()
768 {
769 return true;
770 }
771
772 override void SetActions()
773 {
774 super.SetActions();
775
776 //AddAction(ActionAttach); //REMOVING DUPLICATE METHODS
779 }
780};
781
782class HeadlightH7_Box extends Box_Base {};
783
784class WindscreenBox extends ItemBase {};
785
786class GlowPlug extends ItemBase
787{
788 override void SetActions()
789 {
790 super.SetActions();
791
794 }
795};
796
797class SparkPlug extends ItemBase
798{
799 override bool DisplayNameRuinAttach()
800 {
801 return true;
802 }
803
804 override bool ShowZonesHealth()
805 {
806 return true;
807 }
808
809 override void SetActions()
810 {
811 super.SetActions();
812
813 //AddAction(ActionAttach); //REMOVING DUPLICATE METHODS
815 //AddAction(ActionInsertSparkplug); //DEPRECATED, not fully functionnal DO NOT USE
817 }
818};
819
820
821//-----------------------------------------------------------------------------
822class Clothing_Base extends ItemBase
823{
825
827 {
828 m_ItemVisibilityModifier = ConfigGetFloat("visibilityModifier");
829 }
830
832 {
833 HandleVoiceEffect(false, PlayerBase.Cast(GetHierarchyRootPlayer()));
834 }
835
836 override bool IsClothing()
837 {
838 return true;
839 }
840
842 {
843 return m_ItemVisibilityModifier;
844 }
845
846 void UpdateNVGStatus(PlayerBase player, bool attaching = false, bool force_disable = false)
847 {
848 NVGoggles NVGAttachment;
849 NVGAttachment = NVGoggles.Cast(FindAttachmentBySlotName("NVG"));
850 bool has_nvg_slot;
851 for (int i = 0; i < GetInventory().GetAttachmentSlotsCount(); i++)
852 {
853 has_nvg_slot = GetInventory().GetAttachmentSlotId(i) == InventorySlots.GetSlotIdFromString("NVG");
854 if (has_nvg_slot)
855 break;
856 }
857
858 if ( player && has_nvg_slot )
859 {
860 if ( NVGAttachment )
861 {
862 NVGAttachment.LoweredCheck();
863
864 if ( attaching && NVGAttachment.m_Strap && NVGAttachment.m_IsLowered )
865 {
866 NVGAttachment.SetPlayer(player);
867 player.SetNVGLowered(true);
868
869 if ( player.IsControlledPlayer() )
870 {
871 if ( NVGAttachment.IsWorking() )
872 {
873 player.AddActiveNV(NVTypes.NV_GOGGLES);
874 //player.RemoveActiveNV(NVTypes.NV_GOGGLES_OFF);
875 }
876 else
877 {
878 //player.AddActiveNV(NVTypes.NV_GOGGLES_OFF);
879 player.RemoveActiveNV(NVTypes.NV_GOGGLES);
880 }
881 }
882 }
883 else
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_OFF);
892 }
893 }
894 }
895 else if ( player.IsNVGWorking() && force_disable )
896 {
897 player.SetNVGLowered(false);
898
899 if ( player.IsControlledPlayer() )
900 {
901 player.RemoveActiveNV(NVTypes.NV_GOGGLES);
902 //player.RemoveActiveNV(NVTypes.NV_GOGGLES_OFF);
903 }
904 }
905 }
906 }
907
908 override void OnWasAttached(EntityAI parent, int slot_id)
909 {
910 super.OnWasAttached(parent, slot_id);
911
912 if ( slot_id == InventorySlots.HEADGEAR || slot_id == InventorySlots.MASK )
913 HandleVoiceEffect(true, PlayerBase.Cast(GetHierarchyRootPlayer()));
914 }
915
916 override void OnWasDetached(EntityAI parent, int slot_id)
917 {
918 super.OnWasDetached(parent, slot_id);
919
920 HandleVoiceEffect(false, PlayerBase.Cast(parent));
921 }
922
925 {
926 return false;
927 }
928
930 // Better name for this would have been "MufflePlayer" or "ChangeVoiceEffect" (Too late to change in case a mod already uses this)
931 void MutePlayer(PlayerBase player, bool state)
932 {
933 if ( GetGame() )
934 {
935 if (( GetGame().IsServer() && GetGame().IsMultiplayer() ) || ( GetGame().GetPlayer() == player ))
936 {
937 GetGame().SetVoiceEffect(player, GetVoiceEffect(), state);
938 }
939 }
940 }
941
943 void HandleVoiceEffect(bool enable, PlayerBase player)
944 {
945 if ( IsObstructingVoice() && player )
946 MutePlayer(player, enable);
947 }
948
950 // Options: (VoiceEffectMumbling = 1, VoiceEffectExtortion = 2, VoiceEffectObstruction = 4)
952 {
953 return 0;
954 }
955
957 {
958 return false;
959 }
960};
961
962//-----------------------------------------------------------------------------
963class Box_Base extends InventoryItemSuper
964{
965 override void SetActions()
966 {
967 super.SetActions();
969 }
970};
971
972//-----------------------------------------------------------------------------
973class ItemGrenade extends InventoryItemSuper
974{
979 proto native bool SetPinned ();
984 proto native bool SetUnpinned ();
989 proto native bool SetIgnited ();
993 proto native bool IsPinned ();
997 proto native bool IsActivated ();
998};
999
1000typedef ItemGrenade GrenadeBase;
1001
1002//-----------------------------------------------------------------------------
1003class ItemMap extends InventoryItemSuper
1004{
1005 //protected ref array<vector,int,int,string> m_MarkerArray;
1007
1013
1014 void ItemMap()
1015 {
1016 InitMapState();
1017 }
1018
1020 {
1021 string path = "CfgWorlds " + GetGame().GetWorldName();
1022
1023 GetGame().ConfigGetText(path + " mapDisplayNameKey",m_DisplayName);
1024 GetGame().ConfigGetText(path + " mapDescriptionKey",m_Description);
1025 GetGame().ConfigGetText(path + " mapTextureClosed",m_TextureClosed);
1026 GetGame().ConfigGetText(path + " mapTextureOpened",m_TextureOpened);
1027 GetGame().ConfigGetText(path + " mapTextureLegend",m_TextureLegend);
1028
1029 SetObjectTexture(0,m_TextureClosed);
1030 SetObjectTexture(1,m_TextureOpened);
1031 SetObjectTexture(2,m_TextureLegend);
1032
1033 //m_MarkerArray = new ref array<vector,int,int,string>;
1034 m_MapMarkerArray = new ref array<ref MapMarker>;
1035 if (GetGame().IsMultiplayer() && GetGame().IsServer())
1036 {
1037 SyncMapMarkers();
1038 }
1039 }
1040
1041 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
1042 {
1043 super.OnItemLocationChanged(old_owner,new_owner);
1044
1045 SetMapStateOpen(false, PlayerBase.Cast(old_owner));
1046 }
1047
1049 void SetMapStateOpen(bool state, PlayerBase player)
1050 {
1051 if (player)
1052 {
1053 player.SetMapOpen(state);
1054 if (state)
1055 player.OnItemInHandsChanged();
1056 }
1057
1058 if (state)
1059 {
1060 ShowSelection("map_opened");
1061 HideSelection("map_closed");
1062 }
1063 else
1064 {
1065 ShowSelection("map_closed");
1066 HideSelection("map_opened");
1067 }
1068 }
1069
1071 {
1072 if (GetAnimationPhase("map_opened") == 0)
1073 return true;
1074 return false;
1075 }
1076
1078 {
1079 if (m_MapMarkerArray.Count() <= 0)
1080 return;
1081
1082 PlayerIdentity pid;
1083 //Param1<ref array<vector,int,int,string>> params = new Param1<ref array<vector,int,int,string>>( m_MarkerArray );
1084 Param1<ref array<ref MapMarker>> params = new Param1<ref array<ref MapMarker>>( m_MapMarkerArray );
1085
1086 if (GetGame().IsServer() && GetHierarchyRootPlayer()) //TODO do we need PlayerIdentity here?
1087 {
1088 pid = GetHierarchyRootPlayer().GetIdentity();
1089 RPCSingleParam(ERPCs.RPC_SEND_MAP_MARKERS,params,true,pid);
1090 }
1091 else
1092 {
1093 RPCSingleParam(ERPCs.RPC_SEND_MAP_MARKERS,params,true);
1094 }
1095 }
1096
1097 override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
1098 {
1099 super.OnRPC(sender, rpc_type, ctx);
1100
1101 //array<vector,int,int,string> tmp_array = new array<vector,int,int,string>;
1102 //Param1<ref array<vector,int,int,string>> param = new Param1<ref array<vector,int,int,string>>(m_MarkerArray);
1103 Param1<ref array<ref MapMarker>> params = new Param1<ref array<ref MapMarker>>( m_MapMarkerArray );
1104
1105 if (rpc_type == ERPCs.RPC_SEND_MAP_MARKERS)
1106 {
1107 if (ctx.Read(params))
1108 {
1109 //Print("Map | OnRPC | m_MapMarkerArray_new count: " + m_MapMarkerArray_new.Count());
1110 }
1111 }
1112 }
1113
1114 override bool OnStoreLoad(ParamsReadContext ctx, int version)
1115 {
1116 if ( !super.OnStoreLoad(ctx, version) )
1117 return false;
1118
1119 if (version >= 108 && !ctx.Read(m_MapMarkerArray))
1120 {
1121 return false;
1122 }
1123 return true;
1124 }
1125
1127 {
1128 super.OnStoreSave(ctx);
1129
1130 ctx.Write(m_MapMarkerArray);
1131 }
1132
1133 override bool NameOverride(out string output)
1134 {
1135 output = m_DisplayName;
1136
1137 return true;
1138 }
1139
1140 override bool DescriptionOverride(out string output)
1141 {
1142 output = m_Description;
1143
1144 return true;
1145 }
1146
1147 /*array<vector,int,int,string> GetMarkerArray()
1148 {
1149 return m_MarkerArray;
1150 }*/
1151
1152 void InsertMarker(vector pos, string text, int color, int idx)
1153 {
1154 ref MapMarker marker = MapMarker(pos,text,color,idx);
1155 m_MapMarkerArray.Insert(marker);
1156 }
1157
1159 {
1160 return m_MapMarkerArray;
1161 }
1162};
1163
1165{
1167 protected int m_Color;
1168 protected int m_IconIdx;
1169 protected string m_Text;
1170
1171 void MapMarker(vector pos, string text, int color, int idx)
1172 {
1173 m_Position = pos;
1174 m_Text = text;
1175 m_Color = color;
1176 m_IconIdx = idx;
1177 }
1178
1180 {
1181 return m_Position;
1182 }
1183
1185 {
1186 return m_Text;
1187 }
1188
1190 {
1191 return m_Color;
1192 }
1193
1195 {
1196 return m_IconIdx;
1197 }
1198};
InventoryMode
Definition Inventory.c:20
eBleedingSourceType GetType()
void ReplaceWheelLambda(EntityAI old_item, string new_item_type, PlayerBase player)
CarWheel_Ruined m_oldOri
ItemGrenade GrenadeBase
class ItemBarrel extends InventoryItemSuper TuneNext
ItemSuppressor SuppressorBase
override protected bool CanExecuteLambda()
proto native void TunePrev()
AttachActionData ActionData ActionAttach()
Definition ActionAttach.c:9
void ActionDetach()
void AddAction(typename actionName)
void RemoveAction(typename actionName)
CarFluid
Type of vehicle's fluid. (native, do not change or extend)
Definition Car.c:19
CarDoorState
Definition CarScript.c:2
EMeleeTargetType
ERPCs
Definition ERPCs.c:2
InventoryLocationType
types of Inventory Location
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Definition ItemBase.c:5432
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
PlayerBase GetPlayer()
protected bool m_Initialized
class JsonUndergroundAreaTriggerData GetPosition
proto native void SetVoiceEffect(Object player, int effect, bool enable)
Enable/disable VoN effect (only on server)
proto void GetWorldName(out string world_name)
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native bool IsServer()
override void SetActions()
override int GetCarDoorsState(string slotType)
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
override bool CanPutAsAttachment(EntityAI parent)
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.
proto native void EnableReceive(bool state)
proto native bool SetUnpinned()
sets grenade to state GR_UNPINNED (if the state transition is possible)
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
proto native void SetCanSpeak(bool onOff)
override void OnInventoryExit(Man player)
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
proto native bool SetIgnited()
sets grenade to state GR_TRIGGERED (if the state transition is possible)
override void OnStoreSave(ParamsWriteContext ctx)
override bool ShowZonesHealth()
proto native bool IsActivated()
proto native void SetFrequencyByIndex(int index)
override void EEKilled(Object killer)
void SetMapStateOpen(bool state, PlayerBase player)
displays open/closed selections; 1 == opened
proto native void SetPrevChannel()
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
proto native bool IsReceiving()
override int GetMeleeTargetType()
protected ref array< ref MapMarker > m_MapMarkerArray
proto native void EnableBroadcast(bool state)
override void OnWasDetached(EntityAI parent, int slot_id)
override bool NameOverride(out string output)
void InsertMarker(vector pos, string text, int color, int idx)
proto native bool CanSpeak()
override bool OnStoreLoad(ParamsReadContext ctx, int version)
override void OnWasAttached(EntityAI parent, int slot_id)
array< ref MapMarker > GetMarkerArray()
proto native float GetWidth()
Returns wheel width.
proto native float GetTunedFrequency()
proto native float GetRadius()
Returns current wheel radius.
override void OnInventoryEnter(Man player)
override bool DescriptionOverride(out string output)
override bool DisplayNameRuinAttach()
override bool CanDetachAttachment(EntityAI parent)
proto native int GetTunedFrequencyIndex()
proto native void SetNextChannel()
proto native bool IsBroadcasting()
proto native bool IsPinned()
proto native bool SetPinned()
sets grenade to state GR_PINNED (if the state transition is possible)
override void SetActions()
InventoryLocation.
proto native int GetType()
returns type of InventoryLocation
proto native int GetSlot()
returns slot id if current type is Attachment
provides access to slot configuration
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
static proto native owned string GetSlotName(int id)
converts slot_id to string
void UpdateNVGStatus(PlayerBase player, bool attaching=false, bool force_disable=false)
override bool ShowZonesHealth()
int GetVoiceEffect()
The voice effect this item uses, default is 0 (none)
void MutePlayer(PlayerBase player, bool state)
This items has effect on player's voice.
float GetItemVisibility()
bool IsObstructingVoice()
Returns if this entity obsructs player's voice.
override void OnWasDetached(EntityAI parent, int slot_id)
void Clothing_Base()
void ~Clothing_Base()
float m_ItemVisibilityModifier
override bool IsClothing()
override void OnWasAttached(EntityAI parent, int slot_id)
bool IsGasMask()
override bool DisplayNameRuinAttach()
void HandleVoiceEffect(bool enable, PlayerBase player)
override void SetActions()
void MapMarker(vector pos, string text, int color, int idx)
protected int m_IconIdx
string GetMarkerText()
int GetMarkerColor()
protected string m_Text
int GetMarkerIcon()
protected vector m_Position
vector GetMarkerPos()
protected int m_Color
Definition EnMath.c:7
The class that will be instanced (moddable)
Definition gameplay.c:378
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
proto bool Write(void value_out)
proto bool Read(void value_in)
Base native class for all motorized wheeled vehicles.
Definition Car.c:80
override void OnSuccess(EntityAI new_item)
script counterpart to engine's class Weapon
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
string m_Description
class purpose description
Definition EnEntity.c:845
const int STATE_RUINED
Definition constants.c:742
const int STATE_PRISTINE
Definition constants.c:746
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
proto native Widget GetSibling()
proto native void RemoveChild(Widget child)
proto native Widget GetChildren()