117 {
118 int free_bs_locations = 0;
119 set<int> list = player.GetBleedingManagerServer().GetBleedingSourcesLocations();
120
121 foreach(int location: list)
122 {
123 float prot_level = PluginTransmissionAgents.GetProtectionLevelEx(
DEF_CHEMICAL, location, player,
true);
124 float dice_throw = Math.RandomFloat01();
125 if(dice_throw > prot_level)
126 {
127 free_bs_locations = player.GetBleedingManagerServer().GetFreeBleedingSourceBitsByInvLocation(location) | free_bs_locations;
128 }
129 }
130
131 int num_of_free_bs = Math.GetNumberOfSetBits(free_bs_locations);
132
133 if ( num_of_free_bs > 0 )
134 {
135 int random_bs_index = Math.RandomIntInclusive(0, num_of_free_bs - 1 );
136 int random_bs_bit = Math.Pow(2, Math.GetNthBitSet(free_bs_locations,random_bs_index));
137 player.GetBleedingManagerServer().AttemptAddBleedingSourceDirectly(random_bs_bit,
eBleedingSourceType.CONTAMINATED);
138 }
139 }