Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
pumpkinhelmet.c
Go to the documentation of this file.
1 // Have a spooky Halloween everyone!
2 
4 {
5  void PumpkinHelmet()
6  {
7  SetEventMask(EntityEvent.INIT); // Enable EOnInit event
8  }
9 
10  override void OnMovedInsideCargo(EntityAI container)
11  {
12  UpdateGlowState();
13  }
14 
15  override void OnMovedWithinCargo(EntityAI container)
16  {
17  UpdateGlowState();
18  }
19 
20  override void OnRemovedFromCargo(EntityAI container)
21  {
22  UpdateGlowState();
23  }
24 
25  override void EOnInit( IEntity other, int extra)
26  {
27  UpdateGlowState();
28  }
29 
30  override void OnItemLocationChanged( EntityAI old_owner, EntityAI new_owner)
31  {
32  super.OnItemLocationChanged( old_owner, new_owner);
33 
34  UpdateGlowState();
35  }
36 
37  override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
38  {
39  super.EEHealthLevelChanged(oldLevel,newLevel,zone);
40 
41  UpdateGlowState();
42  }
43 
44  void UpdateGlowState()
45  {
46  // Makes sure PumpkinHelmet doesn't glow when it's attached on head, or it's inside cargo.
47 
48  bool do_glow = true;
49 
50  if ( IsDamageDestroyed() )
51  {
52  do_glow = false;
53  }
54  else
55  {
56  int id = InventorySlots.HEADGEAR;
58  GetInventory().GetCurrentInventoryLocation( IL );
59 
60  int id_2 = IL.GetSlot();
61  int id_cargo = IL.GetIdx();
62 
63  if ( id == id_2) // Pumpkin is attached on head
64  do_glow = false;
65 
66  if ( id_cargo != -1 ) // Pumpkin is in cargo
67  do_glow = false;
68  }
69 
70  SetPilotLight(do_glow);
71  }
72 
73  override void UpdateNVGStatus(PlayerBase player, bool attaching = false, bool force_disable = false)
74  {
75  if ( !GetGame().IsDedicatedServer() ) //SP only
76  {
77  if (force_disable)
78  {
79  player.RemoveActiveNV(NVTypes.NV_PUMPKIN);
80  }
81  else
82  {
83  if ( attaching && (!player.IsNVGWorking() || player.GetNVType() != NVTypes.NV_PUMPKIN) )
84  {
85  player.AddActiveNV(NVTypes.NV_PUMPKIN);
86  }
87  else if ( !attaching && player.IsNVGWorking() )
88  {
89  player.RemoveActiveNV(NVTypes.NV_PUMPKIN);
90  }
91  }
92  }
93  }
94 
95  override protected set<int> GetAttachmentExclusionInitSlotValue(int slotId)
96  {
97  set<int> ret = super.GetAttachmentExclusionInitSlotValue(slotId);
98  if (slotId == InventorySlots.HEADGEAR)
99  {
100  ret.Insert(EAttExclusions.EXCLUSION_HEADGEAR_HELMET_0);
101 
102  ret.Insert(EAttExclusions.EXCLUSION_MASK_1);
103  ret.Insert(EAttExclusions.EXCLUSION_MASK_2);
104  ret.Insert(EAttExclusions.EXCLUSION_HEADSTRAP_0);
105 
106  ret.Insert(EAttExclusions.SHAVING_HEADGEAR_ATT_0);
107  }
108  return ret;
109  }
110 };
111 
112 // boo!
GetGame
proto native CGame GetGame()
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
IsDamageDestroyed
protected bool IsDamageDestroyed(ActionTarget target)
Definition: actionbase.c:913
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
IEntity
Definition: enentity.c:164
PlayerBase
Definition: playerbaseclient.c:1
PumpkinHelmet
Definition: pumpkinhelmet.c:3
NVTypes
NVTypes
Definition: dayzplayercamera_base.c:54
HelmetBase
Definition: greathelm.c:1
EntityEvent
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition: enentity.c:44
EntityAI
Definition: building.c:5