3 const float TICK_INTERVAL_SEC = 3;
5 bool m_DisableBloodLoss =
false;
12 return m_BleedingSourceZone.Get(GetSelectionNameFromBit(bit));
20 void RequestDeletion(
int bit)
22 m_DeleteList.Insert(bit);
25 override protected void AddBleedingSource(
int bit)
33 super.AddBleedingSource(bit);
37 override protected bool RemoveBleedingSource(
int bit)
39 if(!super.RemoveBleedingSource(bit))
41 Error(
"Failed to remove bleeding source:" + bit);
48 int inverse_bit_mask = ~bit;
61 chanceToInfect =
PlayerConstants.BLEEDING_SOURCE_CLOSE_INFECTION_CHANCE;
63 float diceRoll =
Math.RandomFloat01();
64 if (diceRoll < chanceToInfect)
74 void RemoveAnyBleedingSource()
76 int bleeding_sources_bits =
m_Player.GetBleedingBits();
77 int rightmost_bit = bleeding_sources_bits & (-bleeding_sources_bits);
79 RemoveBleedingSource(rightmost_bit);
82 void RemoveMostSignificantBleedingSource()
84 int bit = GetMostSignificantBleedingSource();
86 RemoveBleedingSource(bit);
89 void RemoveMostSignificantBleedingSourceEx(
ItemBase item)
92 RemoveMostSignificantBleedingSource();
95 int GetMostSignificantBleedingSource()
97 int bleeding_sources_bits =
m_Player.GetBleedingBits();
100 int highest_flow_bit;
105 int bit = 1 << bit_offset;
107 if( (bit & bleeding_sources_bits) != 0 )
112 if( meta.GetFlowModifier() > highest_flow )
114 highest_flow = meta.GetFlowModifier();
115 highest_flow_bit = bit;
122 return highest_flow_bit;
125 void OnTick(
float delta_time)
128 if(
m_Tick > TICK_INTERVAL_SEC )
130 while( m_DeleteList.Count() > 0 )
132 RemoveBleedingSource(m_DeleteList.Get(0));
133 m_DeleteList.Remove(0);
139 for(
int i = 0; i < m_BleedingSources.Count(); i++)
141 m_BleedingSources.GetElement(i).OnUpdateServer(
m_Tick, blood_scale, m_DisableBloodLoss );
149 for(
int i = 0; i < m_BleedingSourceZone.Count(); i++)
151 int bit = m_BleedingSourceZone.GetElement(i).GetBit();
152 if( CanAddBleedingSource(bit) )
154 AddBleedingSource(bit);
162 float dmg_max =
m_Player.GetMaxHealth(zone,
"Blood");
163 float bleed_threshold =
GetGame().ConfigGetFloat(
"CfgAmmo " + ammo +
" DamageApplied bleedThreshold");
164 string damageTypeString =
GetGame().ConfigGetTextOut(
"CfgAmmo " + ammo +
" DamageApplied type");
165 bleed_threshold =
Math.Clamp(bleed_threshold,0,1);
166 float bleedingChance;
167 bool createBleedingSource =
false;
170 if (
BleedChanceData.CalculateBleedChance(damageTypeString, damage, bleed_threshold,bleedingChance))
172 float roll =
Math.RandomFloat01();
173 createBleedingSource = bleedingChance != 0 && bleedingChance >= roll;
178 Debug.BleedingChancesLog(roll.ToString(),
"BleedingSourcesManagerServer" ,
"n/a",
"bleeding random roll:");
182 else if (source && source.IsZombie())
184 int chance =
Math.RandomInt(0,100);
185 if (chance <= damage)
187 createBleedingSource =
true;
190 else if (damage > (dmg_max * (1 - bleed_threshold)) )
192 createBleedingSource =
true;
195 if (createBleedingSource)
200 Debug.BleedingChancesLog(
"true",
"BleedingSourcesManagerServer" ,
"n/a",
"Attempting to create bleeding source");
207 void DebugActivateBleedingSource(
int source)
211 if(source >= m_BleedingSourceZone.Count() || !m_BleedingSourceZone.GetElement(source))
return;
213 int bit = m_BleedingSourceZone.GetElement(source).GetBit();
215 if( bit && CanAddBleedingSource(bit) )
217 AddBleedingSource(bit);
221 void SetBloodLoss(
bool status)
223 m_DisableBloodLoss = status;
229 int active_bits =
m_Player.GetBleedingBits();
230 ctx.Write(active_bits);
235 int bit = 1 << bit_offset;
236 if( (bit & active_bits) != 0 )
238 int active_time = GetBleedingSourceActiveTime(bit);
241 ctx.Write(active_time);
251 if(!ctx.Read(active_bits))
259 int bit = 1 << bit_offset;
260 if( (bit & active_bits) != 0 && CanAddBleedingSource(bit))
262 AddBleedingSource(bit);
264 if(!ctx.Read(active_time))
270 SetBleedingSourceActiveTime(bit,active_time);
281 SetBleedingSourceType(bit,type);
291 void ~BleedingSourcesManagerServer()