DayZ 1.24
Loading...
Searching...
No Matches
MaskBase.c
Go to the documentation of this file.
1
2class MaskBase extends Mask_Base
3{
5
6 override bool IsGasMask()
7 {
8 return true;
9 }
10
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
27 {
28 return FindAttachmentBySlotName("GasMaskFilter");
29 }
30
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
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
56 {
57 ItemBase filter = ItemBase.Cast(GetExternalFilter());
58 if (filter)
59 return filter.GetQuantity();
60 else
61 return GetQuantity();
62 }
63
65 {
66 if (!HasValidFilter())
67 return 0;
68
69 ItemBase filter = ItemBase.Cast(GetExternalFilter());
70 float quantity, quantityMax;
71
72 if (filter)
73 {
74 quantity = filter.GetQuantity();
75 quantityMax = filter.GetQuantityMax();
76 }
77 else
78 {
81 }
82
84 }
85
87 {
88 return ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter")) != null;
89 }
90
92 {
93 return HasQuantity();
94 }
95
97 {
98 return !HasIntegratedFilter();
99 }
100
102 {
103 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
105
106 if (HasQuantity() && GetQuantity() > 0)
107 {
108 itemToConsume = this;//this mask itself has quantity(masks with integrated, non-attached filter)
109 }
110 else if (HasValidFilter())
112 if (itemToConsume)
113 {
114 itemToConsume.AddQuantity(-quantity);
115 OnQuantityConsumed(itemToConsume, consumer_player, quantity);
116 return true;
117 }
118
119 return false;
120 }
121
123
125 {
126 float damage = quantity * filter.GetFilterDamageRatio();
127 filter.AddHealth("", "", -damage);
128 }
129
130 override protected void InitGlobalExclusionValues()
131 {
132 super.InitGlobalExclusionValues();
133
134 AddSingleExclusionValueGlobal(EAttExclusions.EXCLUSION_MASK_2);
135
136 AddSingleExclusionValueGlobal(EAttExclusions.EXCLUSION_GLASSES_TIGHT_0);
137 AddSingleExclusionValueGlobal(EAttExclusions.EXCLUSION_HEADGEAR_HELMET_0);
138 }
139}
float quantityMax
override float GetQuantity()
Definition ItemBase.c:7995
bool HasQuantity()
Definition ItemBase.c:7990
override int GetQuantityMax()
Definition ItemBase.c:7941
override void OnDebugSpawn()
Definition MaskBase.c:21
bool ConsumeQuantity(float quantity, PlayerBase consumer_player)
Definition MaskBase.c:101
float GetFilterQuantityMax()
Definition MaskBase.c:43
override array< int > GetEffectWidgetTypes()
Definition MaskBase.c:11
override bool AllowFoodConsumption()
Definition MaskBase.c:16
bool HasIntegratedFilter()
Definition MaskBase.c:91
float GetFilterQuantity()
Definition MaskBase.c:55
float m_LowFilterEventTime
Definition MaskBase.c:4
EntityAI GetExternalFilter()
Definition MaskBase.c:26
float GetFilterQuantity01()
Definition MaskBase.c:64
bool HasValidFilter()
has either external or integrated non-empty non-ruined filter ?
Definition MaskBase.c:32
void OnQuantityConsumed(notnull ItemBase filter, PlayerBase consumer_player)
Definition MaskBase.c:122
bool IsExternalFilterAttached()
Definition MaskBase.c:86
void OnQuantityConsumed(notnull ItemBase filter, PlayerBase consumer_player, float quantity)
Definition MaskBase.c:124
bool CanHaveExternalFilter()
Definition MaskBase.c:96
override bool IsGasMask()
Definition MaskBase.c:6
void InitGlobalExclusionValues()
Definition MaskBase.c:130
Definition EnMath.c:7
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...