Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
areaexposure.c
Go to the documentation of this file.
2{
3 const int EVENT_1_INTERVAL_MIN = 3;
4 const int EVENT_1_INTERVAL_MAX = 5;
5
6 const float AGENTS_PER_SEC = 5;
7 protected float m_NextEvent1;
8 protected float m_Time1;
9
10 const int EVENT_2_INTERVAL_MIN = 13;
11 const int EVENT_2_INTERVAL_MAX = 18;
12
13
14 const float AGENT_DOSE_PER_BS_SEC = 0.33;//how many agents will be injected in one sec per a single bleeding source
15
16 protected float m_NextEvent2;
17 protected float m_Time2;
18
19
20
33
34 override bool ActivateCondition(PlayerBase player)
35 {
36 return false;
37 }
38
39 override void OnActivate(PlayerBase player)
40 {
42 if (data)
43 {
44 MiscGameplayFunctions.TeleportCheck(player, data.SafePositions);
45 player.SetPersistentFlag(PersistentFlag.AREA_PRESENCE, false);
46 }
47
48 //make the player cough immediately
49 float transmitted = TransmitAgents(player, 1);
50 if(transmitted)
51 player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_COUGH);
52
53 m_NextEvent1 = Math.RandomFloatInclusive( EVENT_1_INTERVAL_MIN, EVENT_1_INTERVAL_MAX );
54 }
55
56 override void OnDeactivate(PlayerBase player)
57 {
58 }
59
60 override bool DeactivateCondition(PlayerBase player)
61 {
62 return false;
63 }
64
65 override void OnTick(PlayerBase player, float deltaT)
66 {
67 #ifdef DEVELOPER
68 if(!player.GetCanBeDestroyed())
69 return;
70 #endif
71
72 float transmitted = TransmitAgents(player, AGENTS_PER_SEC * deltaT);
73
74 m_Time2 += deltaT;
75
76 if (transmitted)
77 {
78 m_Time1 += deltaT;
79 if (m_Time1 >= m_NextEvent1 )
80 {
81 player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_COUGH);
82
83 if(Math.RandomFloat01() < 0.25)//creates a cough cooldown once in a while
84 {
85 m_NextEvent1 = Math.RandomFloatInclusive( EVENT_1_INTERVAL_MIN * 2, EVENT_1_INTERVAL_MAX * 2 );
86 }
87 else
88 {
89 m_NextEvent1 = Math.RandomFloatInclusive( EVENT_1_INTERVAL_MIN, EVENT_1_INTERVAL_MAX );
90 }
91
92 m_Time1 = 0;
93 }
94 }
95
96 if ( m_Time2 >= m_NextEvent2 )
97 {
99 m_Time2 = 0;
101 }
102
103 ApplyAgentsToBleedingSources(player, deltaT);
104
105 }
106
107 void ApplyAgentsToBleedingSources(PlayerBase player, float deltaT)
108 {
109
110 int count = player.GetBleedingSourceCount();
111 float agent_dose = count * AGENT_DOSE_PER_BS_SEC * deltaT;
112 player.InsertAgent(eAgents.CHEMICAL_POISON, agent_dose);
113
114 }
115
117 {
118 int free_bs_locations = 0;//bitmask where each bit set to 1 represents available bleeding source location
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);//gets us the number of bits set to 1, where each represents a free bleeding source location
132
133 if ( num_of_free_bs > 0 )
134 {
135 int random_bs_index = Math.RandomIntInclusive(0, num_of_free_bs - 1 );// - 1 on the max to convert count to index
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 }
140
141 float TransmitAgents(PlayerBase player, float count)
142 {
143 PluginTransmissionAgents plugin = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
144 return plugin.TransmitAgentsEx(null, player, AGT_AIRBOURNE_CHEMICAL, count, eAgents.CHEMICAL_POISON);
145 }
146
147
148};
eBleedingSourceType
void ApplyAgentsToBleedingSources(PlayerBase player, float deltaT)
const float AGENT_DOSE_PER_BS_SEC
const int EVENT_2_INTERVAL_MAX
float TransmitAgents(PlayerBase player, float count)
const int EVENT_2_INTERVAL_MIN
void BleedingSourceCreateCheck(PlayerBase player)
override void OnTick(PlayerBase player, float deltaT)
override bool DeactivateCondition(PlayerBase player)
override bool ActivateCondition(PlayerBase player)
override void Init()
override void OnDeactivate(PlayerBase player)
override void OnActivate(PlayerBase player)
Definition enmath.c:7
eAgents
Definition eagents.c:3
int m_ID
ID of effect, given by SEffectManager when registered (automatically done when playing through it)
Definition effect.c:51
eModifiers
Definition emodifiers.c:2
const int DEF_CHEMICAL
Definition constants.c:513
const int AGT_AIRBOURNE_CHEMICAL
Definition constants.c:507
bool m_TrackActivatedTime
overall time this modifier was active
void DisableDeactivateCheck()
void DisableActivateCheck()
bool m_AnalyticsStatsEnabled
eModifierSyncIDs m_SyncID
float m_TickIntervalActive
float m_TickIntervalInactive
eModifierSyncIDs
const int DEFAULT_TICK_TIME_ACTIVE_SHORT
const int DEFAULT_TICK_TIME_INACTIVE_LONG
PersistentFlag
PluginBase GetPlugin(typename plugin_type)