DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
PluginTransmissionAgents.c
См. документацию.
7
13class PluginTransmissionAgents extends PluginBase
14{
17 bool m_IsConstructed = false;
18
20 {
21 //add new agents here
23 RegisterAgent(new CholeraAgent);
24 RegisterAgent(new SalmonellaAgent);
25 RegisterAgent(new BrainAgent);
27 RegisterAgent(new ChemicalAgent);
29 RegisterAgent(new NerveAgent);
31 }
32
38 {
39 m_AgentList.Insert(agent.GetAgentType(), agent);
40 }
41
46 {
47 string agent_name;
48 int agent_type;
49
50 for(int i = 0; i < m_AgentList.Count();i++)
51 {
52 AgentBase agent = m_AgentList.GetElement(i);
53 agent_name = agent.GetName();
54 agent_type = agent.GetAgentType();
55 m_SimpleAgentList.Insert(agent_type, agent_name);
56 }
57 }
58
67
81
87 static string GetNameByID(int agent_id)
88 {
89 return m_AgentList.Get(agent_id).GetName();
90 }
91
97 {
98 target.RemoveAllAgents();
99 }
100
106 static void RemoveAgent(EntityAI target, int agent_id)
107 {
108 target.RemoveAgent(agent_id);
109 }
110
116 protected float GetAgentTransferabilityIn(int agent_id)
117 {
118 if( !m_AgentList.Get(agent_id) ) return 0;
119 return m_AgentList.Get(agent_id).GetTransferabilityIn();
120 }
121
123 {
124 AgentBase agent = m_AgentList.Get(agentId);
125 if (!agent)
126 return true;
127
128 return agent.GrowDuringMedicalDrugsAttack(drugType, player);
129 }
130
134 float GetDieOffSpeed( int agent_id )
135 {
136 if( !m_AgentList.Get(agent_id) )
137 return 0;
138 return m_AgentList.Get(agent_id).GetDieOffSpeed();
139 }
140
147 float GetAgentDieOffSpeedEx(int agent_id, PlayerBase player)
148 {
149 if( !m_AgentList.Get(agent_id) )
150 return true;
151 return m_AgentList.Get(agent_id).GetDieOffSpeedEx(player);
152 }
153
157 EStatLevels GetPotency( int agent_id )
158 {
159 if( !m_AgentList.Get(agent_id) )
160 return 0;
161 return m_AgentList.Get(agent_id).GetPotency();
162 }
163
171 {
172 if( !m_AgentList.Get(agent_id) )
173 return true;
174 return m_AgentList.Get(agent_id).GetPotencyEx(player);
175 }
176
183 float GetAgentInvasibilityEx(int agent_id, PlayerBase player)
184 {
185 if( !m_AgentList.Get(agent_id) )
186 return true;
187 return m_AgentList.Get(agent_id).GetInvasibilityEx(player);
188 }
189
194 {
195 if(!m_AgentList.Get(agent_id))
196 return 0;
197 return m_AgentList.Get(agent_id).GetDrugResistance(drugType, player);
198 }
199
200
204 float GetAgentAntiboticsResistance( int agent_id )
205 {
206 if( !m_AgentList.Get(agent_id) )
207 return 0;
208 return m_AgentList.Get(agent_id).GetAntiboticsResistance();
209 }
210
217 float GetAgentAntiboticsResistanceEx( int agent_id , PlayerBase player)
218 {
219 if( !m_AgentList.Get(agent_id) )
220 return 0;
221 return m_AgentList.Get(agent_id).GetAntibioticsResistanceEx(player);
222 }
223
229 protected float GetAgentTransferabilityOut( int agent_id )
230 {
231 if(!m_AgentList.Get(agent_id))
232 return 0;
233 return m_AgentList.Get(agent_id).GetTransferabilityOut();
234 }
235
241 protected float GetAgentTransferabilityAirOut( int agent_id )
242 {
243 if(!m_AgentList.Get(agent_id))
244 return 0;
245 return m_AgentList.Get(agent_id).GetTransferabilityAirOut();
246 }
247
253 float GetAgentInvasibility( int agent_id )
254 {
255 if( !m_AgentList.Get(agent_id) )
256 return 0;
257 return m_AgentList.Get(agent_id).GetInvasibility();
258 }
259
263 float GetAgentDigestibility( int agent_id )
264 {
265 if( !m_AgentList.Get(agent_id) )
266 return 0;
267 return m_AgentList.Get(agent_id).GetDigestibility();
268 }
269
276 float GetAgentDigestibilityEx(int agent_id, PlayerBase player)
277 {
278 if (!m_AgentList.Get(agent_id))
279 return 0;
280 return m_AgentList.Get(agent_id).GetDigestibilityEx(player);
281 }
282
288 static int GetAgentMaxCount( int agent_id )
289 {
290 if( !m_AgentList.Get(agent_id) )
291 return 0;
292 return m_AgentList.Get(agent_id).GetMaxCount();
293 }
294
304 float TransmitAgentsEx(EntityAI source, EntityAI target, int pathway, int dose_size = 1000, int agents = 0)
305 {
306 //Debug.Log("Transmitting agents for source: " +source.ToString()+", target: " +target.ToString(),"Agents");
307 int sourceAgents = agents;
308 int targetAgents;
309 if(!sourceAgents && source) sourceAgents = source.GetAgents();//do not set sourceAgents again if already set
310 if(target) targetAgents = target.GetAgents();
311 int pollution = g_Game.GetMission().GetWorldData().GetPollution();
312
313 float count = 0;
314
315 switch (pathway)
316 {
317 case AGT_INV_OUT: //item leaving inventory
318 break;
319
320 case AGT_INV_IN: //item entering inventory
321 break;
322
323 case AGT_UACTION_TOUCH: //player touched the item
324 //InjectAgents( source, targetAgents ,GetProtectionLevel(DEF_BIOLOGICAL,InventorySlots.GLOVES, player) );
325 break;
326
327 case AGT_WATER_POND:
328 if (pollution & EPollution.HEAVYMETAL)
329 {
330 sourceAgents = sourceAgents | eAgents.HEAVYMETAL;
331 }
332 sourceAgents = sourceAgents | eAgents.CHOLERA;
333 InjectAgentsWithPlayer( target, sourceAgents , 0, 1, InjectTypes.ITEM_TO_PLAYER );
334 break;
335
337 sourceAgents = sourceAgents | eAgents.FOOD_POISON | eAgents.HEAVYMETAL;
338 InjectAgentsWithPlayer( target, sourceAgents , 0, 1, InjectTypes.ITEM_TO_PLAYER );
339 break;
340
341 case AGT_SNOW:
342 if (pollution & EPollution.HEAVYMETAL)
343 {
344 sourceAgents = sourceAgents | eAgents.HEAVYMETAL;
345 }
346 InjectAgentsWithPlayer( target, sourceAgents , 0, 1, InjectTypes.ITEM_TO_PLAYER );
347 break;
348
350 //InjectAgentsWithPlayer( target, sourceAgents , 0, dose_size, InjectTypes.ITEM_TO_PLAYER );
351 InjectAgentsWithPlayer( source, targetAgents , 0, 1, InjectTypes.PLAYER_TO_ITEM );
352 break;
353
354 case AGT_UACTION_TO_PLAYER: //user action of a consumption, only from item to player
355 InjectAgentsWithPlayerCount( target, sourceAgents , 0, dose_size, InjectTypes.ITEM_TO_PLAYER );
356 break;
357
358 case AGT_UACTION_TO_ITEM: //to transfer from the player to the consumed item
359 InjectAgentsWithPlayer( target, sourceAgents , 0, 1, InjectTypes.PLAYER_TO_ITEM );
360 break;
361
362 case AGT_TRANSFER_COPY: //transferring liquid
363 InjectAgentsWithoutPlayer( target, sourceAgents );
364 break;
365
366 case AGT_ITEM_TO_FLESH: //transferring liquid
367 InjectAgentsWithPlayer( target, sourceAgents , 0, 1, InjectTypes.ITEM_TO_PLAYER);
368 break;
369
371 float prot_level_mask_target = GetProtectionLevel(DEF_BIOLOGICAL,InventorySlots.MASK, Man.Cast( target ));
372 float prot_level_mask_source = GetProtectionLevel(DEF_BIOLOGICAL,InventorySlots.MASK, Man.Cast( source ));
373 float prot_level_headgear_target = GetProtectionLevel(DEF_BIOLOGICAL,InventorySlots.HEADGEAR, Man.Cast( target ));
374 float prot_level_headgear_source = GetProtectionLevel(DEF_BIOLOGICAL,InventorySlots.HEADGEAR, Man.Cast( source ));
375 float prot_level_target = Math.Max(prot_level_mask_target, prot_level_headgear_target);//find the bigger of the 2, TODO: should be improved
376 float prot_level_source = Math.Max(prot_level_mask_source, prot_level_headgear_source);//find the bigger of the 2, TODO: should be improved
377 float prot_level_combined = 1 - (1 - prot_level_target) * (1 - prot_level_source);
378 InjectAgentsWithPlayer( target, sourceAgents , prot_level_combined, 1, InjectTypes.PLAYER_AIR_PLAYER );
379 break;
381 float prot_level_mask_target2 = GetProtectionLevel(DEF_CHEMICAL,InventorySlots.MASK, Man.Cast( target ));
382
383 count = InjectAgentWithPlayerDose( target, agents , prot_level_mask_target2, dose_size, InjectTypes.PLAYER_AIR_PLAYER );
384 break;
385 default:
386 break;
387 }
388 return count;
389 }
390
394 void TransmitAgents(EntityAI source, EntityAI target, int pathway, int dose_size = 1000)
395 {
396 TransmitAgentsEx(source, target, pathway, dose_size);
397 }
398
404 protected void InjectAgentsWithoutPlayer(EntityAI target, int agents)
405 {
406 if( target.IsItemBase() )
407 {
408 ItemBase ib_target = ItemBase.Cast( target );
409 ib_target.TransferAgents(agents);
410 }
411 }
412
421 protected void InjectAgentsWithPlayer(EntityAI target, int agents, float protection, int dose_size, int inject_type)//target,array_of_agents,protection_lvl
422 {
423 if(target && (agents != 0) && target.IsEntityAI() )
424 {
425 int bit_count = Math.GetNumberOfSetBits(agents);
426
427 for (int i = 0; i < bit_count; i++)
428 {
429 int agent_bit = Math.Pow(2,Math.GetNthBitSet(agents,i));
430 if( DetermineChanceToTransmit(agent_bit, protection, inject_type))
431 {
432 target.InsertAgent(agent_bit,dose_size);
433 }
434 }
435 }
436 }
437
446 protected void InjectAgentsWithPlayerCount(EntityAI target, int agents, float protection, int dose_size, int inject_type)//target,array_of_agents,protection_lvl
447 {
448 if(target && (agents != 0) && target.IsEntityAI() )
449 {
450 int bit_count = Math.GetNumberOfSetBits(agents);
451
452 for (int i = 0; i < bit_count; i++)
453 {
454 int agent_bit = Math.Pow(2,Math.GetNthBitSet(agents,i));
455 float count = CalculateAgentsToTransmit(agent_bit, protection, dose_size, inject_type);
456 target.InsertAgent(agent_bit,count);
457 }
458 }
459 }
460
470 protected float InjectAgentWithPlayerDose(EntityAI target, int agent, float protection, float dose_size, int inject_type)//target,array_of_agents,protection_lvl
471 {
472 float count = CalculateAgentsToTransmit(agent, protection, dose_size, inject_type);
473 {
474 if(count > 0)
475 {
476 target.InsertAgent(agent, count);
477 return count;
478 }
479 }
480 return 0;
481 }
482
483 // !performance hog, avoid
484 static void BuildAgentArray(int agents, array<int> agents_out)
485 {
486 int mask = 1;
487 for(int i = 0; i < BIT_INT_SIZE; i++)
488 {
489 if( mask & agents )
490 agents_out.Insert(mask);
491 mask = mask * 2;
492 }
493 }
494
504 static float GetProtectionLevelEx(int type, int slot, Man player, bool consider_filter = true, int system = 0)
505 {
506 ItemBase attachment = ItemBase.Cast(player.GetInventory().FindAttachment(slot));
507
508 if(!attachment)
509 return 0;
510
511 return attachment.GetProtectionLevel(type, consider_filter, system);
512
513 }
514
518 protected float GetProtectionLevel(int type, int slot, Man player)
519 {
520 return GetProtectionLevelEx(type, slot, player);
521 }
522
523 //------------------------------------------------------------------------------------------------------
524
533 protected float CalculateAgentsToTransmit(int agent_id, float protection, int dose_size, int inject_type)
534 {
535
536 //Debug.Log("protection: "+protection.ToString());
537 //reverse the value (in config, the higher the value, the higher the protection: 0 - 1) so that we can easily interpolate between 0 and 1 by multiplication
538 float prot = 1 - protection;
539 //Debug.Log("prot: "+prot.ToString(), "Agents");
540 float transf;
541
542 if( inject_type == InjectTypes.PLAYER_TO_ITEM )
543 {
544 transf = GetAgentTransferabilityOut(agent_id);
545 }
546 else if( inject_type == InjectTypes.ITEM_TO_PLAYER )
547 {
548 transf = GetAgentTransferabilityIn(agent_id);
549 }
550 else if( inject_type == InjectTypes.PLAYER_AIR_PLAYER )
551 {
552 transf = GetAgentTransferabilityAirOut(agent_id);
553 }
554
555 //Debug.Log("transf: "+transf.ToString(), "Agents");
556 //float result = GetAgentInitialCount(agent_id) * prot * transf * dose_size;//final formula
557 float result = 1 * prot * transf * dose_size;//final formula
558 //result = Math.Ceil(result);
559 //Debug.Log("result: "+result.ToString(), "Agents");
560 return result;
561 }
562
563 //------------------------------------------------------------------------------------------------------
571 protected bool DetermineChanceToTransmit(int agent_id, float protection, int inject_type)
572 {
573
574 //Debug.Log("protection: "+protection.ToString());
575 //reverse the value (in config, the higher the value, the higher the protection: 0 - 1) so that we can easily interpolate between 0 and 1 by multiplication
576 float prot = 1 - protection;
577 //Debug.Log("prot: "+prot.ToString(), "Agents");
578 float transf;
579
580 if( inject_type == InjectTypes.PLAYER_TO_ITEM )
581 {
582 transf = GetAgentTransferabilityOut(agent_id);
583 }
584 else if( inject_type == InjectTypes.ITEM_TO_PLAYER )
585 {
586 transf = GetAgentTransferabilityIn(agent_id);
587 }
588 else if( inject_type == InjectTypes.PLAYER_AIR_PLAYER )
589 {
590 transf = GetAgentTransferabilityAirOut(agent_id);
591 }
592 #ifdef DEVELOPER
593 //Debug.Log("transf: "+transf.ToString(), "Agents");
594 #endif
595 //float result = GetAgentInitialCount(agent_id) * prot * transf * dose_size;//final formula
596 bool dice = Math.RandomFloat01() < (prot * transf);
597 //result = Math.Ceil(result);
598
599 return dice;
600 }
601 //------------------------------------------------------------------------------------------------------
602
603
605 bool GrowDuringAntibioticsAttack(int agent_id, PlayerBase player)
606 {
607 if (!m_AgentList.Get(agent_id))
608 return true;
609
610 return m_AgentList.Get(agent_id).GrowDuringMedicalDrugsAttack(EMedicalDrugsType.ANTIBIOTICS, player);
611 }
612}
const int BIT_INT_SIZE
Определения BitArray.c:4
map
Определения ControlsXboxNew.c:4
DayZGame g_Game
Определения DayZGame.c:3942
eAgents
Определения EAgents.c:3
EMedicalDrugsType
Определения EMedicalDrugsType.c:2
EStatLevels
Определения EStatLevels.c:2
InjectTypes
Определения PluginTransmissionAgents.c:2
@ PLAYER_AIR_PLAYER
Определения PluginTransmissionAgents.c:5
@ PLAYER_TO_ITEM
Определения PluginTransmissionAgents.c:3
@ ITEM_TO_PLAYER
Определения PluginTransmissionAgents.c:4
int GetAgentType()
Определения AgentBase.c:33
bool GrowDuringMedicalDrugsAttack(EMedicalDrugsType drugType, PlayerBase player)
should this agent grow based on invasibility even during usage of specific medical drugs attack
Определения AgentBase.c:88
string GetName()
Определения AgentBase.c:146
Определения AgentBase.c:2
Определения FoodPoisonAgent.c:2
Определения HeavyMetalAgent.c:2
Определения InfluenzaAgent.c:2
provides access to slot configuration
Определения InventorySlots.c:6
Определения EnMath.c:7
Определения PlayerBaseClient.c:2
float InjectAgentWithPlayerDose(EntityAI target, int agent, float protection, float dose_size, int inject_type)
Injects agent to a given target.
Определения PluginTransmissionAgents.c:470
bool GrowDuringMedicalDrugsAttack(int agentId, EMedicalDrugsType drugType, PlayerBase player)
Определения PluginTransmissionAgents.c:122
static int GetAgentMaxCount(int agent_id)
Returns max count attribute for given agent.
Определения PluginTransmissionAgents.c:288
void RemoveAllAgents(EntityAI target)
Removes all agents from given entity.
Определения PluginTransmissionAgents.c:96
static float GetProtectionLevelEx(int type, int slot, Man player, bool consider_filter=true, int system=0)
Protection level of an attachment against enviromental hazard (mask/filters for example)
Определения PluginTransmissionAgents.c:504
int GetAgentSpecificDrugResistance(int agent_id, EMedicalDrugsType drugType, PlayerBase player)
Определения PluginTransmissionAgents.c:193
map< int, string > GetSimpleAgentList()
Returns map of all registered agents in simplified format(for non-gameplay purposas mainly)
Определения PluginTransmissionAgents.c:72
float GetAgentInvasibilityEx(int agent_id, PlayerBase player)
Returns invasibility attribute for given agent.
Определения PluginTransmissionAgents.c:183
float CalculateAgentsToTransmit(int agent_id, float protection, int dose_size, int inject_type)
Calculates number of agents that can be transmitted (based on given dose_size)
Определения PluginTransmissionAgents.c:533
void ConstructSimpleAgentList()
Builds simplified list of agents in <id, name> format.
Определения PluginTransmissionAgents.c:45
bool DetermineChanceToTransmit(int agent_id, float protection, int inject_type)
Agent transmission chance processing.
Определения PluginTransmissionAgents.c:571
void TransmitAgents(EntityAI source, EntityAI target, int pathway, int dose_size=1000)
Process transmission of agents between entities (for specified transmission type) (see TransmitAgents...
Определения PluginTransmissionAgents.c:394
float GetAgentDigestibility(int agent_id)
Returns stomach digetibility attribute for given agent (see GetAgentDigestibilityEx())
Определения PluginTransmissionAgents.c:263
float GetDieOffSpeed(int agent_id)
Returns dieOfSpeed attribute for given agent (see GetDieOffSpeedEx())
Определения PluginTransmissionAgents.c:134
static void RemoveAgent(EntityAI target, int agent_id)
Removes given agent from given entity.
Определения PluginTransmissionAgents.c:106
void InjectAgentsWithPlayer(EntityAI target, int agents, float protection, int dose_size, int inject_type)
Injects agents to a given target, using chance of transmission and full dose size if chance succeeds.
Определения PluginTransmissionAgents.c:421
static ref map< int, ref AgentBase > m_AgentList
Определения PluginTransmissionAgents.c:15
float GetAgentTransferabilityAirOut(int agent_id)
Returns transferabilitAiryOut attribute for given agent.
Определения PluginTransmissionAgents.c:241
float GetAgentInvasibility(int agent_id)
Returns invasibility attribute for given agent.
Определения PluginTransmissionAgents.c:253
EStatLevels GetPotency(int agent_id)
Returns potency attribute for given agent (see GetAgentPotencyEx())
Определения PluginTransmissionAgents.c:157
void InjectAgentsWithPlayerCount(EntityAI target, int agents, float protection, int dose_size, int inject_type)
Injects agents to a given target, with no probability, but the dose size is modified by m_Transferabi...
Определения PluginTransmissionAgents.c:446
void InjectAgentsWithoutPlayer(EntityAI target, int agents)
Injects specified agents directly to target.
Определения PluginTransmissionAgents.c:404
float GetAgentDieOffSpeedEx(int agent_id, PlayerBase player)
Returns dieOfSpeed attribute for given agent.
Определения PluginTransmissionAgents.c:147
bool m_IsConstructed
simple <eAgents, agentName> pair
Определения PluginTransmissionAgents.c:17
float GetProtectionLevel(int type, int slot, Man player)
Protection level of an attachment against enviromental hazard (mask/filters for example) (see GetProt...
Определения PluginTransmissionAgents.c:518
float GetAgentDigestibilityEx(int agent_id, PlayerBase player)
Returns stomach digetibility attribute for given agent.
Определения PluginTransmissionAgents.c:276
bool GrowDuringAntibioticsAttack(int agent_id, PlayerBase player)
DEPRECATED.
Определения PluginTransmissionAgents.c:605
static void BuildAgentArray(int agents, array< int > agents_out)
Определения PluginTransmissionAgents.c:484
void RegisterAgent(AgentBase agent)
Registers new agent into system.
Определения PluginTransmissionAgents.c:37
map< int, ref AgentBase > GetAgentList()
Returns map of all registered agent classes.
Определения PluginTransmissionAgents.c:63
float GetAgentAntiboticsResistanceEx(int agent_id, PlayerBase player)
Returns antibiotics resistance attribute for given agent.
Определения PluginTransmissionAgents.c:217
float TransmitAgentsEx(EntityAI source, EntityAI target, int pathway, int dose_size=1000, int agents=0)
Process transmission of agents between entities (for specified transmission type)
Определения PluginTransmissionAgents.c:304
float GetAgentAntiboticsResistance(int agent_id)
Returns antibiotics resistance attribute for given agent see GetAgentAntiboticsResistanceEx()
Определения PluginTransmissionAgents.c:204
EStatLevels GetAgentPotencyEx(int agent_id, PlayerBase player)
Returns potency attribute for given agent.
Определения PluginTransmissionAgents.c:170
void PluginTransmissionAgents()
Определения PluginTransmissionAgents.c:19
static string GetNameByID(int agent_id)
Returns agent's name from given id.
Определения PluginTransmissionAgents.c:87
float GetAgentTransferabilityIn(int agent_id)
Returns transferabilityIn attribute for given agent.
Определения PluginTransmissionAgents.c:116
ref map< int, string > m_SimpleAgentList
Определения PluginTransmissionAgents.c:16
float GetAgentTransferabilityOut(int agent_id)
Returns transferabilityOut attribute for given agent.
Определения PluginTransmissionAgents.c:229
Plugin interface for controlling of agent pool system.
Определения PluginBase.c:2
Определения WoundAgent.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения CachedEquipmentStorage.c:4
const int AGT_UACTION_CONSUME
Определения 3_Game/DayZ/constants.c:502
const int AGT_ITEM_TO_FLESH
Определения 3_Game/DayZ/constants.c:509
const int AGT_UACTION_TOUCH
Определения 3_Game/DayZ/constants.c:504
const int DEF_BIOLOGICAL
Определения 3_Game/DayZ/constants.c:515
const int DEF_CHEMICAL
Определения 3_Game/DayZ/constants.c:516
const int AGT_AIRBOURNE_BIOLOGICAL
Определения 3_Game/DayZ/constants.c:506
const int AGT_TRANSFER_COPY
Определения 3_Game/DayZ/constants.c:503
const int AGT_WATER_HOT_SPRING
Определения 3_Game/DayZ/constants.c:513
const int AGT_WATER_POND
Определения 3_Game/DayZ/constants.c:505
const int AGT_INV_OUT
Определения 3_Game/DayZ/constants.c:501
const int AGT_UACTION_TO_PLAYER
Определения 3_Game/DayZ/constants.c:507
const int AGT_AIRBOURNE_CHEMICAL
Определения 3_Game/DayZ/constants.c:510
const int AGT_UACTION_TO_ITEM
Определения 3_Game/DayZ/constants.c:508
const int AGT_SNOW
Определения 3_Game/DayZ/constants.c:511
const int AGT_INV_IN
Определения 3_Game/DayZ/constants.c:500
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
Определения EnMath.c:126
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto int GetNthBitSet(int value, int n)
returns the the index of n-th bit set in a bit mask counting from the right, for instance,...
static proto float Pow(float v, float power)
Return power of v ^ power.
static proto int GetNumberOfSetBits(int i)
returns the number of bits set in a bitmask i