DayZ 1.24
Loading...
Searching...
No Matches
BleedingSourcesManagerBase.c
Go to the documentation of this file.
2{
6 static ref map<int, int> m_BleedingSourcesZonesMaskByLocation = new map<int, int>;//for each inventory location, keep a bitmask where a bit is set to 1 for each bleeding source zone that belongs to that location
8 ItemBase m_Item;//item used to remove the bleeding source
10 //ref map<string, int> m_FireGeomToBit = new map<string, int>;
12 protected int m_Bit;
13 int m_BitOffset = 0;
14
20
21 protected void Init()
22 {
23 //dmgZone_head
25 //dmgZone_torso
26 RegisterBleedingZoneEx("Neck", PlayerConstants.BLEEDING_SOURCE_DURATION_NORMAL, "", "-180 0 0", "0.02 -0.05 0.05", PlayerConstants.BLEEDING_SOURCE_FLOW_MODIFIER_HIGH, "BleedingSourceEffect", InventorySlots.HEADGEAR);
32 //dmgZone_leftArm
37 //dmgZone_rightArm
42 //dmgZone_leftHand
43 RegisterBleedingZoneEx("LeftForeArmRoll", PlayerConstants.BLEEDING_SOURCE_DURATION_NORMAL, "", "0 90 0", "0.1 0 0", PlayerConstants.BLEEDING_SOURCE_FLOW_MODIFIER_LOW, "BleedingSourceEffectLight", InventorySlots.GLOVES);
44 //dmgZone_rightHand
45 RegisterBleedingZoneEx("RightForeArmRoll", PlayerConstants.BLEEDING_SOURCE_DURATION_NORMAL, "", "0 90 0", "-0.1 0 0", PlayerConstants.BLEEDING_SOURCE_FLOW_MODIFIER_LOW, "BleedingSourceEffectLight", InventorySlots.GLOVES);
46 //dmgZone_leftLeg
51 //dmgZone_rightLeg
56 //dmgZone_leftFoot
57 RegisterBleedingZoneEx("LeftFoot", PlayerConstants.BLEEDING_SOURCE_DURATION_NORMAL, "", "0 180 0", "0 0 0.035", PlayerConstants.BLEEDING_SOURCE_FLOW_MODIFIER_LOW, "BleedingSourceEffectLight", InventorySlots.LEGS);
59 //dmgZone_rightFoot
60 RegisterBleedingZoneEx("RightFoot", PlayerConstants.BLEEDING_SOURCE_DURATION_NORMAL, "", "0 0 0", "0 0 -0.035", PlayerConstants.BLEEDING_SOURCE_FLOW_MODIFIER_LOW, "BleedingSourceEffectLight", InventorySlots.LEGS);
62 }
63
64 protected void SetItem(ItemBase item)
65 {
66 m_Item = item;
67 }
68
69
74
75
76 //for inventory location, get the active bits
84
85 //for inventory location, get the active bits
95
97 {
98 name.ToLower();
100
101 return m_Player.GetBleedingBits() & bit;
102 }
103
104
105 protected int GetBitFromSelectionID(int id)
106 {
108 m_Player.GetActionComponentNameList(id, CachedObjectsArrays.ARRAY_STRING, "fire");
109
110 for (int i = 0; i < CachedObjectsArrays.ARRAY_STRING.Count(); i++)
111 {
112 /*
113 string name = CachedObjectsArrays.ARRAY_STRING.Get(i);
114 PrintString(name);
115 */
117 if (bit != 0)
118 return bit;
119 }
120 return 0;
121 }
122
127
129 {
130 return m_BitOffset;
131 }
132
133 protected void RegisterBleedingZoneEx(string name, int max_time, string bone = "", vector orientation = "0 0 0", vector offset = "0 0 0", float flow_modifier = 1, string particle_name = "BleedingSourceEffect", int inv_location = 0)
134 {
136 Error("Too many bleeding sources, max is " + BIT_INT_SIZE.ToString());
137 else
138 {
139 name.ToLower();
140 //PrintString(name);
141 //int bit = Math.Pow(2, m_BitOffset);
142 m_Bit = 1 << m_BitOffset;
143 //PrintString(bit.ToString());
144 string bone_name = bone;
145
146 if (bone_name == "")
147 bone_name = name;
148
150 m_BleedingSourceZone.Get(name).SetInvLocation(inv_location);
151 m_BitToFireGeom.Insert(m_Bit, name);
152 m_BleedingSourcesZonesMaskByLocation.Set(inv_location, m_BleedingSourcesZonesMaskByLocation.Get(inv_location) | m_Bit); //set a bit to 1 to already existing bitmask for that location
154 m_BitOffset++;
155 }
156 }
157 protected void RegisterBleedingZone(string name, int max_time, string bone = "", vector orientation = "0 0 0", vector offset = "0 0 0", float flow_modifier = 1, string particle_name = "BleedingSourceEffect")
158 {
160 }
161
163 {
164 //int count = m_BleedingSources.Count();
165 while (m_BleedingSources.Count() > 0)
166 {
167 int bit = m_BleedingSources.GetKey(0);
169 }
170 }
171
172 protected int GetBitFromSelectionName(string name)
173 {
174 if (!m_BleedingSourceZone.Get(name))
175 return 0;
176 return m_BleedingSourceZone.Get(name).GetBit();
177 }
178
179 protected string GetSelectionNameFromBit(int bit)
180 {
181 return m_BitToFireGeom.Get(bit);
182 }
183
185 {
187
188 if (bit == 0)
189 return false;
190
192 {
194 return true;
195 }
196 return false;
197 }
198
200 {
201 selection_name.ToLower();
203
204 if (bit == 0)
205 return false;
206
208 {
210 return true;
211 }
212 return false;
213 }
214
215
217 {
219 {
221 return true;
222 }
223 return false;
224 }
225
226
227 protected bool CanAddBleedingSource(int bit)
228 {
230 return false;
231 if ((m_Player.GetBleedingBits() & bit) == 0)
232 return true;
233 return false;
234 }
235
236 protected void AddBleedingSourceEx(int bit, eBleedingSourceType type = eBleedingSourceType.NORMAL, int context = 0)
237 {
239 m_BleedingSources.Get(bit).SetType(type);
240 }
241
242 protected void AddBleedingSource(int bit)
243 {
245 vector orientation = bsz.GetOrientation();
246 vector offset = bsz.GetOffset();
247 string bone_name = bsz.GetBoneName();
248 float flow_modifier = bsz.GetFlowModifier();
249 int max_time = bsz.GetMaxTime();
250 string particle_name = bsz.GetParticleName();
251 int inventory_loc = bsz.GetInvLocation();
254 }
255
257 {
258 int time = -1;
259 if (m_BleedingSources.Contains(bit))
260 time = m_BleedingSources.Get(bit).GetActiveTime();
261 return time;
262 }
263
265 {
266 if (m_BleedingSources.Contains(bit))
267 m_BleedingSources.Get(bit).SetActiveTime(time);
268 }
269
271 {
272 if (m_BleedingSources.Contains(bit))
273 m_BleedingSources.Get(bit).SetType(type);
274 }
276 {
277 if (m_BleedingSources.Contains(bit))
278 return m_BleedingSources.Get(bit).GetType();
279 return -1;
280 }
281
282 protected bool RemoveBleedingSource(int bit)
283 {
284 if (m_BleedingSources.Contains(bit))
285 {
287 int inventory_loc = bsz.GetInvLocation();
289 m_BleedingSources.Remove(bit);
290 return true;
291 }
292 return false;
293 }
294
296 {
297 return m_BleedingSources.Count();
298 }
299
300 /*void ChangeBleedingIndicatorVisibility(bool visible)
301 {
302 int count = m_BleedingSources.Count();
303 for (int i = 0; i < count; i++)
304 {
305 m_BleedingSources.GetElement(i).ToggleSourceBleedingIndication(visible);
306 }
307 }*/
308}
void BleedingSource(PlayerBase player, int bit, string bone, vector orientation, vector offset, int max_time, float flow_modifier, string particle_name)
eBleedingSourceType
const int BIT_INT_SIZE
Definition BitArray.c:4
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
int GetBleedingSourceBitsByInvLocation(int inv_location)
void AddBleedingSourceEx(int bit, eBleedingSourceType type=eBleedingSourceType.NORMAL, int context=0)
void RegisterBleedingZone(string name, int max_time, string bone="", vector orientation="0 0 0", vector offset="0 0 0", float flow_modifier=1, string particle_name="BleedingSourceEffect")
static ref map< int, int > m_BleedingSourcesZonesMaskByLocation
bool AttemptAddBleedingSourceDirectly(int bit, eBleedingSourceType type=eBleedingSourceType.NORMAL, int context=0)
int GetFreeBleedingSourceBitsByInvLocation(int inv_location)
eBleedingSourceType GetBleedingSourceType(int bit)
BleedingSourceZone GetBleedingSourceMeta(int bit)
ref map< int, ref BleedingSource > m_BleedingSources
void SetBleedingSourceActiveTime(int bit, int time)
ref map< int, int > m_BleedingSourcesByLocation
static ref set< int > m_BleedingSourcesLocationsList
bool AttemptAddBleedingSourceBySelection(string selection_name)
void BleedingSourcesManagerBase(PlayerBase player)
void RegisterBleedingZoneEx(string name, int max_time, string bone="", vector orientation="0 0 0", vector offset="0 0 0", float flow_modifier=1, string particle_name="BleedingSourceEffect", int inv_location=0)
ref map< string, ref BleedingSourceZone > m_BleedingSourceZone
void SetBleedingSourceType(int bit, eBleedingSourceType type)
static ref TStringArray ARRAY_STRING
provides access to slot configuration
static const float BLEEDING_SOURCE_FLOW_MODIFIER_LOW
static const float BLEEDING_SOURCE_FLOW_MODIFIER_HIGH
static const float BLEEDING_SOURCE_FLOW_MODIFIER_MEDIUM
static const int BLEEDING_SOURCE_DURATION_NORMAL
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90