Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
maskbase.c
Go to the documentation of this file.
1 class MaskBase extends Mask_Base
3 {
4  float m_LowFilterEventTime;
5 
6  override bool IsGasMask()
7  {
8  return true;
9  }
10 
11  override array<int> GetEffectWidgetTypes()
12  {
13  return {EffectWidgetsTypes.MASK_OCCLUDER, EffectWidgetsTypes.MASK_BREATH};
14  }
15 
16  override bool AllowFoodConsumption()
17  {
18  return false;
19  }
20 
21  override void OnDebugSpawn()
22  {
23  GetInventory().CreateInInventory("GasMask_Filter");
24  }
25 
26  EntityAI GetExternalFilter()
27  {
28  return FindAttachmentBySlotName("GasMaskFilter");
29  }
30 
32  bool HasValidFilter()
33  {
34  ItemBase filter = ItemBase.Cast(GetExternalFilter());
35  if (filter && !filter.IsRuined() && filter.GetQuantity() > 0)
36  return true;
37  else if (GetQuantity() > 0 && !IsRuined())
38  return true;
39 
40  return false;
41  }
42 
43  float GetFilterQuantityMax()
44  {
45  ItemBase filter = ItemBase.Cast(GetExternalFilter());
46  if (filter) //mask can have a filter, and filter is attached
47  return filter.GetQuantityMax();
48  else if (HasQuantity())//filter was not attached, checking if mask has internal filter
49  return GetQuantityMax();
50 
51  //mask does not have a filter attached nor does it have internal filter, max quantity can't be obtained
52  return 0;
53  }
54 
55  float GetFilterQuantity()
56  {
57  ItemBase filter = ItemBase.Cast(GetExternalFilter());
58  if (filter)
59  return filter.GetQuantity();
60  else
61  return GetQuantity();
62  }
63 
64  float GetFilterQuantity01()
65  {
66  if (!HasValidFilter())
67  {
68  return 0;
69  }
70 
71  ItemBase filter = ItemBase.Cast(GetExternalFilter());
72  float quantity, quantityMax;
73 
74  if (filter)
75  {
76  quantity = filter.GetQuantity();
77  quantityMax = filter.GetQuantityMax();
78  }
79  else
80  {
81  quantity = GetQuantity();
83  }
84 
85  return Math.InverseLerp(0, quantityMax, quantity);
86  }
87 
88  bool IsExternalFilterAttached()
89  {
90  return ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter")) != null;
91  }
92 
93  bool HasIntegratedFilter()
94  {
95  return HasQuantity();
96  }
97 
98  bool CanHaveExternalFilter()
99  {
100  return !HasIntegratedFilter();
101  }
102 
103  bool ConsumeQuantity(float quantity, PlayerBase consumer_player)
104  {
105  ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
106  ItemBase itemToConsume = null;
107 
108  if (HasQuantity() && GetQuantity() > 0)
109  {
110  itemToConsume = this;//this mask itself has quantity(masks with integrated, non-attached filter)
111  }
112  else if (HasValidFilter())
113  {
114  itemToConsume = filter;
115  }
116  if (itemToConsume)
117  {
118  itemToConsume.AddQuantity(-quantity);
119  OnQuantityConsumed(itemToConsume, consumer_player, quantity);
120  return true;
121  }
122 
123  return false;
124  }
125 
126  void OnQuantityConsumed(notnull ItemBase filter, PlayerBase consumer_player) {};
127 
128  void OnQuantityConsumed(notnull ItemBase filter, PlayerBase consumer_player, float quantity)
129  {
130  float damage = quantity * filter.GetFilterDamageRatio();
131  filter.AddHealth("","", -damage);
132  }
133 
134  override protected void InitGlobalExclusionValues()
135  {
136  super.InitGlobalExclusionValues();
137 
138  AddSingleExclusionValueGlobal(EAttExclusions.EXCLUSION_MASK_2);
139 
140  AddSingleExclusionValueGlobal(EAttExclusions.EXCLUSION_GLASSES_TIGHT_0);
141  AddSingleExclusionValueGlobal(EAttExclusions.EXCLUSION_HEADGEAR_HELMET_0);
142  }
143 }
ItemBase
Definition: inventoryitem.c:730
Mask_Base
gas mask base
Definition: balaclava3holes_colorbase.c:1
HasQuantity
bool HasQuantity()
Definition: itembase.c:3311
GetQuantityMax
override int GetQuantityMax()
Definition: itembase.c:3262
GetQuantity
override float GetQuantity()
Definition: itembase.c:3316
OnDebugSpawn
class Hatchback_02_Blue extends Hatchback_02 OnDebugSpawn
Definition: hatchback_02.c:404
PlayerBase
Definition: playerbaseclient.c:1
MaskBase
Definition: airbornemask.c:1
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
quantityMax
float quantityMax
Definition: cfgplayerspawndatajson.c:209
AllowFoodConsumption
bool AllowFoodConsumption()
Definition: itembase.c:3692
Math
Definition: enmath.c:6
EntityAI
Definition: building.c:5