8 class PluginTransmissionAgents
extends PluginBase
12 bool m_IsConstructed =
false;
14 void PluginTransmissionAgents()
17 RegisterAgent(
new InfluenzaAgent);
18 RegisterAgent(
new CholeraAgent);
19 RegisterAgent(
new SalmonellaAgent);
20 RegisterAgent(
new BrainAgent);
21 RegisterAgent(
new FoodPoisonAgent);
22 RegisterAgent(
new ChemicalAgent);
23 RegisterAgent(
new WoundAgent);
24 RegisterAgent(
new NerveAgent);
29 m_AgentList.Insert(agent.GetAgentType(), agent);
32 void ConstructSimpleAgentList()
37 for(
int i = 0; i < m_AgentList.Count();i++)
39 AgentBase agent = m_AgentList.GetElement(i);
40 agent_name = agent.GetName();
41 agent_type = agent.GetAgentType();
42 m_SimpleAgentList.Insert(agent_type, agent_name);
53 if( !m_IsConstructed )
55 ConstructSimpleAgentList();
56 m_IsConstructed =
true;
58 return m_SimpleAgentList;
61 static string GetNameByID(
int agent_id)
63 return m_AgentList.Get(agent_id).GetName();
68 target.RemoveAllAgents();
73 target.RemoveAgent( agent_id );
78 protected float GetAgentTransferabilityIn(
int agent_id )
80 if( !m_AgentList.Get(agent_id) )
return 0;
81 return m_AgentList.Get(agent_id).GetTransferabilityIn();
85 bool GrowDuringAntibioticsAttack(
int agent_id,
PlayerBase player)
87 if( !m_AgentList.Get(agent_id) )
return true;
88 return m_AgentList.Get(agent_id).GrowDuringAntibioticsAttack(player);
92 float GetAgentDieOffSpeedEx(
int agent_id,
PlayerBase player)
94 if( !m_AgentList.Get(agent_id) )
return true;
95 return m_AgentList.Get(agent_id).GetDieOffSpeedEx(player);
100 if( !m_AgentList.Get(agent_id) )
return true;
101 return m_AgentList.Get(agent_id).GetPotencyEx(player);
104 float GetAgentInvasibilityEx(
int agent_id,
PlayerBase player)
106 if( !m_AgentList.Get(agent_id) )
return true;
107 return m_AgentList.Get(agent_id).GetInvasibilityEx(player);
113 float GetAgentAntiboticsResistance(
int agent_id )
115 if( !m_AgentList.Get(agent_id) )
return 0;
116 return m_AgentList.Get(agent_id).GetAntiboticsResistance();
120 float GetAgentAntiboticsResistanceEx(
int agent_id ,
PlayerBase player)
122 if( !m_AgentList.Get(agent_id) )
return 0;
123 return m_AgentList.Get(agent_id).GetAntibioticsResistanceEx(player);
126 protected float GetAgentTransferabilityOut(
int agent_id )
128 if(!m_AgentList.Get(agent_id))
return 0;
129 return m_AgentList.Get(agent_id).GetTransferabilityOut();
132 protected float GetAgentTransferabilityAirOut(
int agent_id )
134 if(!m_AgentList.Get(agent_id))
return 0;
135 return m_AgentList.Get(agent_id).GetTransferabilityAirOut();
143 float GetAgentInvasibility(
int agent_id )
145 if( !m_AgentList.Get(agent_id) )
147 return m_AgentList.Get(agent_id).GetInvasibility();
151 float GetAgentDigestibility(
int agent_id )
153 if( !m_AgentList.Get(agent_id) )
155 return m_AgentList.Get(agent_id).GetDigestibility();
158 float GetDieOffSpeed(
int agent_id )
160 if( !m_AgentList.Get(agent_id) )
162 return m_AgentList.Get(agent_id).GetDieOffSpeed();
167 if( !m_AgentList.Get(agent_id) )
169 return m_AgentList.Get(agent_id).GetPotency();
172 static int GetAgentMaxCount(
int agent_id )
174 if( !m_AgentList.Get(agent_id) )
return 0;
175 return m_AgentList.Get(agent_id).GetMaxCount();
192 float TransmitAgentsEx(
EntityAI source,
EntityAI target,
int pathway,
int dose_size = 1000,
int agents = 0)
195 int sourceAgents = agents;
197 if(!sourceAgents && source) sourceAgents = source.GetAgents();
198 if(target) targetAgents = target.GetAgents();
220 InjectAgentsWithPlayer( source, targetAgents , 0, 1,
InjectTypes.PLAYER_TO_ITEM );
224 InjectAgentsWithPlayerCount( target, sourceAgents , 0, dose_size,
InjectTypes.ITEM_TO_PLAYER );
228 InjectAgentsWithPlayer( target, sourceAgents , 0, 1,
InjectTypes.PLAYER_TO_ITEM );
232 InjectAgentsWithoutPlayer( target, sourceAgents );
236 InjectAgentsWithPlayer( target, sourceAgents , 0, 1,
InjectTypes.ITEM_TO_PLAYER);
244 float prot_level_target =
Math.Max(prot_level_mask_target, prot_level_headgear_target);
245 float prot_level_source =
Math.Max(prot_level_mask_source, prot_level_headgear_source);
246 float prot_level_combined = 1 - (1 - prot_level_target) * (1 - prot_level_source);
247 InjectAgentsWithPlayer( target, sourceAgents , prot_level_combined, 1,
InjectTypes.PLAYER_AIR_PLAYER );
252 count = InjectAgentWithPlayerDose( target, agents , prot_level_mask_target2, dose_size,
InjectTypes.PLAYER_AIR_PLAYER );
259 void TransmitAgents(
EntityAI source,
EntityAI target,
int pathway,
int dose_size = 1000)
261 TransmitAgentsEx(source, target, pathway, dose_size);
264 protected void InjectAgentsWithoutPlayer(
EntityAI target,
int agents)
266 if( target.IsItemBase() )
269 ib_target.TransferAgents(agents);
274 protected void InjectAgentsWithPlayer(
EntityAI target,
int agents,
float protection,
int dose_size,
int inject_type)
276 if(target && (agents != 0) && target.IsEntityAI() )
278 int bit_count =
Math.GetNumberOfSetBits(agents);
280 for (
int i = 0; i < bit_count; i++)
282 int agent_bit =
Math.Pow(2,
Math.GetNthBitSet(agents,i));
283 if( DetermineChanceToTransmit(agent_bit, protection, inject_type))
285 target.InsertAgent(agent_bit,dose_size);
292 protected void InjectAgentsWithPlayerCount(
EntityAI target,
int agents,
float protection,
int dose_size,
int inject_type)
294 if(target && (agents != 0) && target.IsEntityAI() )
296 int bit_count =
Math.GetNumberOfSetBits(agents);
298 for (
int i = 0; i < bit_count; i++)
300 int agent_bit =
Math.Pow(2,
Math.GetNthBitSet(agents,i));
301 float count = CalculateAgentsToTransmit(agent_bit, protection, dose_size, inject_type);
302 target.InsertAgent(agent_bit,count);
308 protected float InjectAgentWithPlayerDose(
EntityAI target,
int agent,
float protection,
float dose_size,
int inject_type)
310 float count = CalculateAgentsToTransmit(agent, protection, dose_size, inject_type);
314 target.InsertAgent(agent, count);
322 static void BuildAgentArray(
int agents,
array<int> agents_out)
328 agents_out.Insert(mask);
334 static float GetProtectionLevelEx(
int type,
int slot, Man player,
bool consider_filter =
true,
int system = 0)
336 ItemBase attachment =
ItemBase.Cast(player.GetInventory().FindAttachment(slot));
341 return attachment.GetProtectionLevel(type, consider_filter, system);
347 return GetProtectionLevelEx(type, slot, player);
352 protected float CalculateAgentsToTransmit(
int agent_id,
float protection,
int dose_size,
int inject_type)
356 float prot = 1 - protection;
362 transf = GetAgentTransferabilityOut(agent_id);
364 else if( inject_type ==
InjectTypes.ITEM_TO_PLAYER )
366 transf = GetAgentTransferabilityIn(agent_id);
368 else if( inject_type ==
InjectTypes.PLAYER_AIR_PLAYER )
370 transf = GetAgentTransferabilityAirOut(agent_id);
375 float result = 1 * prot * transf * dose_size;
382 protected bool DetermineChanceToTransmit(
int agent_id,
float protection,
int inject_type)
386 float prot = 1 - protection;
392 transf = GetAgentTransferabilityOut(agent_id);
394 else if( inject_type ==
InjectTypes.ITEM_TO_PLAYER )
396 transf = GetAgentTransferabilityIn(agent_id);
398 else if( inject_type ==
InjectTypes.PLAYER_AIR_PLAYER )
400 transf = GetAgentTransferabilityAirOut(agent_id);
406 bool dice =
Math.RandomFloat01() < (prot * transf);