3 const float TICK_INTERVAL_SEC = 3;
5 bool m_DisableBloodLoss =
false;
8 protected bool m_ProcessSourcesRemoval =
false;
24 if (m_DeleteList.Find(bit) == -1)
26 m_DeleteList.Insert(bit);
27 m_ProcessSourcesRemoval =
true;
39 super.AddBleedingSource(bit);
45 if (super.RemoveBleedingSource(bit))
56 chanceToInfect =
PlayerConstants.BLEEDING_SOURCE_CLOSE_INFECTION_CHANCE;
58 float diceRoll =
Math.RandomFloat01();
59 if (diceRoll < chanceToInfect)
69 int inverse_bit_mask = ~bit;
78 int bleeding_sources_bits =
m_Player.GetBleedingBits();
79 int rightmost_bit = bleeding_sources_bits & (-bleeding_sources_bits);
99 int bleeding_sources_bits =
m_Player.GetBleedingBits();
102 int highest_flow_bit;
107 int bit = 1 << bit_offset;
109 if ((bit & bleeding_sources_bits) != 0)
114 if (meta.GetFlowModifier() > highest_flow)
116 highest_flow = meta.GetFlowModifier();
117 highest_flow_bit = bit;
124 return highest_flow_bit;
131 if (m_ProcessSourcesRemoval)
133 while (m_DeleteList.Count() > 0)
136 m_DeleteList.Remove(0);
138 m_ProcessSourcesRemoval =
false;
141 if (
m_Tick > TICK_INTERVAL_SEC)
146 for (
int i = 0; i < m_BleedingSources.Count(); ++i)
148 m_BleedingSources.GetElement(i).OnUpdateServer(
m_Tick, blood_scale, m_DisableBloodLoss);
156 for (
int i = 0; i < m_BleedingSourceZone.Count(); ++i)
158 int bit = m_BleedingSourceZone.GetElement(i).GetBit();
169 float dmg_max =
m_Player.GetMaxHealth(zone,
"Blood");
170 float bleed_threshold =
GetGame().ConfigGetFloat(
"CfgAmmo " + ammo +
" DamageApplied bleedThreshold");
171 string damageTypeString =
GetGame().ConfigGetTextOut(
"CfgAmmo " + ammo +
" DamageApplied type");
172 bleed_threshold =
Math.Clamp(bleed_threshold,0,1);
173 float bleedingChance;
174 bool createBleedingSource =
false;
177 if (
BleedChanceData.CalculateBleedChance(damageTypeString, damage, bleed_threshold,bleedingChance))
179 float roll =
Math.RandomFloat01();
180 createBleedingSource = bleedingChance != 0 && bleedingChance >= roll;
182 #ifdef ENABLE_LOGGING
185 Debug.BleedingChancesLog(roll.ToString(),
"BleedingSourcesManagerServer" ,
"n/a",
"bleeding random roll:");
189 else if (source && source.IsZombie())
191 int chance =
Math.RandomInt(0,100);
192 if (chance <= damage)
194 createBleedingSource =
true;
197 else if (damage > (dmg_max * (1 - bleed_threshold)))
199 createBleedingSource =
true;
202 if (createBleedingSource)
204 #ifdef ENABLE_LOGGING
207 Debug.BleedingChancesLog(
"true",
"BleedingSourcesManagerServer" ,
"n/a",
"Attempting to create bleeding source");
218 if (source >= m_BleedingSourceZone.Count() || !m_BleedingSourceZone.GetElement(source))
return;
220 int bit = m_BleedingSourceZone.GetElement(source).GetBit();
230 m_DisableBloodLoss = status;
236 int active_bits =
m_Player.GetBleedingBits();
237 ctx.Write(active_bits);
242 int bit = 1 << bit_offset;
243 if ((bit & active_bits) != 0)
248 ctx.Write(active_time);
258 if (!ctx.Read(active_bits))
266 int bit = 1 << bit_offset;
271 if (!ctx.Read(active_time))
Static data of bleeding chance probabilities; currently used for melee only.
void DebugActivateBleedingSource(int source)
void SetBloodLoss(bool status)
int GetBleedingSourceActiveTime(int bit)
void SetItem(ItemBase item)
void RemoveMostSignificantBleedingSource()
void OnTick(float delta_time)
void AddBleedingSource(int bit)
int GetMostSignificantBleedingSource()
void OnStoreSave(ParamsWriteContext ctx)
bool AttemptAddBleedingSource(int component)
eBleedingSourceType GetBleedingSourceType(int bit)
BleedingSourceZone GetBleedingSourceMeta(int bit)
string GetSelectionNameFromBit(int bit)
void SetBleedingSourceActiveTime(int bit, int time)
void ProcessHit(float damage, EntityAI source, int component, string zone, string ammo, vector modelPos)
void RemoveAnyBleedingSource()
void ~BleedingSourcesManagerServer()
bool RemoveBleedingSource(int bit)
bool CanAddBleedingSource(int bit)
bool OnStoreLoad(ParamsReadContext ctx, int version)
void SetBleedingSourceType(int bit, eBleedingSourceType type)
void RequestDeletion(int bit)
void RemoveMostSignificantBleedingSourceEx(ItemBase item)
BleedingSourceZone GetBleedingSourceZone(int bit)
const int STORAGE_VERSION
Serialization general interface. Serializer API works with:
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
class ModifierDebugObj STORAGE_VERSION