DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
PlayerAgentPool.c
См. документацию.
2{
3 const int STORAGE_VERSION = 137;
4
9
11
13
14 PluginTransmissionAgents m_PluginTransmissionAgents = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
15
17 {
18 m_Player = player;
19 m_LastTicked = 0;
21
23
26 }
27
29 {
30 return STORAGE_VERSION;
31 }
32
34 {
35 if (m_VirusPool)
36 {
37 for (int i = 0; i < m_VirusPool.Count(); ++i)
38 {
39 Debug.Log("Agent: "+ m_VirusPool.GetKey(i).ToString(), "Agents");
40 Debug.Log("Count: "+ m_VirusPool.GetElement(i).ToString(), "Agents");
41 }
42 }
43 }
44
45 void ImmuneSystemTick(float value, float deltaT)//this is a regular tick induced in the the player's immune system
46 {
48 SpawnAgents(deltaT);
49 GrowAgents(deltaT);
50 }
51
52 void GrowAgents(float deltaT)
53 {
55 return;
56
57 EStatLevels immunityLevel = m_Player.GetImmunityLevel();
58
60 for (int i = 0; i < m_VirusPool.Count(); i++)
61 {
62 int agentId = m_VirusPool.GetKey(i);
63 int maxCount = m_PluginTransmissionAgents.GetAgentMaxCount(agentId);
64
65 EStatLevels agentPotency = m_PluginTransmissionAgents.GetAgentPotencyEx(agentId, m_Player);
66
67 float growDelta;
68
69 if (agentPotency <= immunityLevel)
70 {
71 float temporaryResistance = GetTemporaryResistance(agentId);
72 if (temporaryResistance > 1.0)
73 continue;
74
75 if (m_Player.IsAntibioticsActive() && !m_PluginTransmissionAgents.GrowDuringMedicalDrugsAttack(agentId, EMedicalDrugsType.CHELATION, m_Player))
76 continue;
77
78 if (m_Player.IsChelationActive() && !m_PluginTransmissionAgents.GrowDuringMedicalDrugsAttack(agentId, EMedicalDrugsType.CHELATION, m_Player))
79 continue
80
81 float invasibility = m_PluginTransmissionAgents.GetAgentInvasibilityEx(agentId, m_Player);
82 growDelta = invasibility * deltaT;
83 }
84 else
85 {
86 float dieOffSpeed = m_PluginTransmissionAgents.GetAgentDieOffSpeedEx(agentId, m_Player);
87 growDelta = -dieOffSpeed * deltaT;
88 }
89
90 float oldCount = m_VirusPool.Get(agentId);
91 float newCount = oldCount + growDelta;
92 newCount = Math.Clamp(newCount, 0, maxCount);
93
94 m_TotalAgentCount += newCount;
95 SetAgentCount(agentId, newCount);
96 }
97 }
98
99 protected void ProcessTemporaryResistance(float deltaTime)
100 {
101 foreach (int agentId, float timeResistance : m_AgentTemporaryResistance)
102 {
103 float temporaryResistance = GetTemporaryResistance(agentId);
104
105 if (temporaryResistance > 1.0)
106 {
107 float newResistanceValue = temporaryResistance - deltaTime;
108 SetTemporaryResistance(agentId, newResistanceValue);
109 }
110 else
111 SetTemporaryResistance(agentId, 0.0);
112 }
113 }
114
116 {
117 int count = m_PluginTransmissionAgents.GetAgentList().Count();
118 array<int> agentList = m_PluginTransmissionAgents.GetAgentList().GetKeyArray();
119 foreach (int agentId : agentList)
120 {
121 ctx.Write(agentId);
122 ctx.Write(GetSingleAgentCount(agentId));
123 ctx.Write(GetTemporaryResistance(agentId));
124 }
125 }
126
127 bool OnStoreLoad(ParamsReadContext ctx, int version)
128 {
129 int count;
130 if (version >= 137)
131 {
132 count = m_PluginTransmissionAgents.GetAgentList().Count();
133 }
134 else
135 {
136 if (!ctx.Read(count))
137 return false;
138 }
139
140
141 for (int i = 0; i < count; ++i)
142 {
143 int agentId;
144 if (!ctx.Read(agentId))
145 return false;
146
147 int agentCount;
148 if (!ctx.Read(agentCount))
149 return false;
150
151 if (version >= 137)
152 {
153 float agentTemporaryResistanceTime;
154 if (!ctx.Read(agentTemporaryResistanceTime))
155 return false;
156
157 SetTemporaryResistance(agentId, agentTemporaryResistanceTime);
158 }
159
160 SetAgentCount(agentId, agentCount);
161 }
162
163 return true;
164 }
165 void DigestAgent(int agent_id, float count)
166 {
167 AddAgent(agent_id, m_PluginTransmissionAgents.GetAgentDigestibilityEx(agent_id, m_Player) * count);
168 }
169
170 void AddAgent(int agent_id, float count)
171 {
172 if (GetTemporaryResistance(agent_id) > 0)
173 return;
174
175 int max_count = m_PluginTransmissionAgents.GetAgentMaxCount(agent_id);
176
177 if (!m_VirusPool.Contains(agent_id) && count > 0)//if it contains, maybe add count only ?
178 {
179 SetAgentCount(agent_id,count);
180 }
181 else
182 {
183 float newValue = m_VirusPool.Get(agent_id) + count;
184 SetAgentCount(agent_id, newValue);
185 }
186 }
187
188 void RemoveAgent(int agent_id)
189 {
190 SetAgentCount(agent_id, 0);
191 }
192
194 {
195 m_AgentMask = 0;
196 m_VirusPool.Clear();
197
199 }
200
201 void ReduceAgent(int id, float percent)
202 {
203 percent = Math.Clamp(percent, 0, 100);
204 float reduction = percent * 0.01;
205
206 int agentCount = GetSingleAgentCount(id);
207 agentCount -= agentCount * reduction;
208
209 SetAgentCount(id, agentCount);
210 }
211
213 {
214 return m_AgentMask;
215 }
216
217 int GetSingleAgentCount(int agent_id)
218 {
219 if (m_VirusPool.Contains(agent_id))
220 return m_VirusPool.Get(agent_id);
221
222 return 0;
223 }
224
226 {
227 float agentCount;
228 for (int i = 0; i < m_VirusPool.Count(); i++)
229 agentCount += m_VirusPool.GetElement(i);
230
231 return agentCount;
232 }
233
234 void SpawnAgents(float deltaT)
235 {
236 int count = m_PluginTransmissionAgents.GetAgentList().Count();
237 for (int i = 0; i < count; ++i)
238 {
239 AgentBase agent = m_PluginTransmissionAgents.GetAgentList().GetElement(i);
240 int agentId = agent.GetAgentType();
241
242 if (GetSingleAgentCount(agentId) == 0 && agent.AutoinfectCheck(deltaT, m_Player))
243 AddAgent(agentId, agent.GetAutoinfectCount());
244 }
245 }
246
247 void SetAgentCount(int agent_id, float count)
248 {
249 if (count > 0)
250 {
251 //Debug.Log("+ growing agent"+ agent_id.ToString() +"to count: "+count.ToString(), "Agents");
252 m_VirusPool.Set(agent_id, count);
253 m_AgentMask = m_AgentMask | agent_id;
254 }
255 else
256 {
257 //Debug.Log("- REMOVING agent"+ agent_id.ToString(), "Agents");
258 m_VirusPool.Remove(agent_id);
259 m_AgentMask = m_AgentMask & ~agent_id;
260 }
261
262 if (m_Player.m_Agents != m_AgentMask)
263 {
264 m_Player.m_Agents = m_AgentMask;
265 m_Player.SetSynchDirty();
266 }
267 }
268
269 void AntibioticsAttack(float attack_value)
270 {
271 for (int i = 0; i < m_VirusPool.Count(); ++i)
272 {
273 int agentId = m_VirusPool.GetKey(i);
274 float resistance = 1 - m_PluginTransmissionAgents.GetAgentAntiboticsResistanceEx(agentId, m_Player);
275 float delta = attack_value * resistance;
276 float actualAgentCount = m_VirusPool.Get(agentId);
277 float newAgentCount = actualAgentCount - delta;
278 SetAgentCount(agentId, newAgentCount);
279 }
280 }
281
282 void DrugsAttack(EMedicalDrugsType drugType, float attackValue)
283 {
284 switch (drugType)
285 {
286 case EMedicalDrugsType.ANTIBIOTICS:
287 AntibioticsAttack(attackValue);
288 break;
289 default:
290 for (int i = 0; i < m_VirusPool.Count(); ++i)
291 {
292 int agentId = m_VirusPool.GetKey(i);
293 float actualAgentCount = m_VirusPool.Get(agentId);
294 float newAgentCount = actualAgentCount - attackValue;
295 SetAgentCount(agentId, newAgentCount);
296 }
297 }
298 }
299
300 void SetTemporaryResistance(int agentId, float time)
301 {
302 m_AgentTemporaryResistance[agentId] = Math.Clamp(time, 0.0, int.MAX);
303 }
304
305 float GetTemporaryResistance(int agentId)
306 {
307 if (m_AgentTemporaryResistance.Contains(agentId))
308 return m_AgentTemporaryResistance[agentId];
309
310 return 0.0;
311 }
312
314 {
315 foreach (int agentId, float value : m_AgentTemporaryResistance)
316 SetTemporaryResistance(agentId, 0.0);
317 }
318
320 {
322 int id = CachedObjectsParams.PARAM1_INT.param1;
323 int max = m_PluginTransmissionAgents.GetAgentMaxCount(Math.AbsInt(id));
324 int grow = max / 10;
325
326 if (id > 0)
327 AddAgent(id, grow);
328 else if (id < 0)
329 AddAgent(-id, -grow);
330 }
331
333 {
334 int count = m_PluginTransmissionAgents.GetAgentList().Count();
335 for (int i = 0; i < count; i++)
336 {
337 AgentBase agent = m_PluginTransmissionAgents.GetAgentList().GetElement(i);
338 string agentName = agent.GetName();
339 int agentId = agent.GetAgentType();
340 int maxAgents = m_PluginTransmissionAgents.GetAgentMaxCount(agentId);
341 string amount = GetSingleAgentCount(agentId).ToString() + "/" + maxAgents.ToString();
342
343 float tempResistance = GetTemporaryResistance(agentId);
344
345 object_out.Insert(new Param4<string,string, int, float>(agentName, amount, agentId, tempResistance));
346 }
347
348 object_out.InsertAt(new Param1<int>(count) ,0);
349 }
350
353}
map
Определения ControlsXboxNew.c:4
EMedicalDrugsType
Определения EMedicalDrugsType.c:2
EStatLevels
Определения EStatLevels.c:2
const int MAX
Определения EnConvert.c:27
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
bool IsPluginManagerExists()
Определения PluginManager.c:306
int GetAgentType()
Определения AgentBase.c:24
string GetName()
Определения AgentBase.c:132
bool AutoinfectCheck(float deltaT, PlayerBase player)
Определения AgentBase.c:89
int GetAutoinfectCount()
Определения AgentBase.c:127
Определения AgentBase.c:2
static ref Param1< int > PARAM1_INT
Определения UtilityClasses.c:11
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Определения Debug.c:122
Определения Debug.c:2
Определения EnMath.c:7
void OnStoreSave(ParamsWriteContext ctx)
Определения PlayerAgentPool.c:115
void DrugsAttack(EMedicalDrugsType drugType, float attackValue)
Определения PlayerAgentPool.c:282
void RemoteGrowRequestDebug(ParamsReadContext ctx)
Определения PlayerAgentPool.c:319
void RemoveAllAgents()
Определения PlayerAgentPool.c:193
float GetTotalAgentCount()
Определения PlayerAgentPool.c:225
void SetTemporaryResistance(int agentId, float time)
Определения PlayerAgentPool.c:300
void PlayerAgentPool(PlayerBase player)
Определения PlayerAgentPool.c:16
float m_TotalAgentCount
Определения PlayerAgentPool.c:7
PluginTransmissionAgents m_PluginTransmissionAgents
Определения PlayerAgentPool.c:14
void RemoveAgent(int agent_id)
Определения PlayerAgentPool.c:188
ref array< int > m_VirusPoolArray
DEPRECATED.
Определения PlayerAgentPool.c:352
void AddAgent(int agent_id, float count)
Определения PlayerAgentPool.c:170
ref map< int, float > m_AgentTemporaryResistance
Определения PlayerAgentPool.c:12
float m_LastTicked
Определения PlayerAgentPool.c:6
PlayerBase m_Player
Определения PlayerAgentPool.c:8
ref map< int, float > m_VirusPool
Определения PlayerAgentPool.c:10
int GetAgents()
Определения PlayerAgentPool.c:212
float GetTemporaryResistance(int agentId)
Определения PlayerAgentPool.c:305
int m_AgentMask
Определения PlayerAgentPool.c:5
void ImmuneSystemTick(float value, float deltaT)
Определения PlayerAgentPool.c:45
void AntibioticsAttack(float attack_value)
Определения PlayerAgentPool.c:269
void ProcessTemporaryResistance(float deltaTime)
Определения PlayerAgentPool.c:99
void ReduceAgent(int id, float percent)
Определения PlayerAgentPool.c:201
bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения PlayerAgentPool.c:127
void ResetTemporaryResistance()
Определения PlayerAgentPool.c:313
void DigestAgent(int agent_id, float count)
Определения PlayerAgentPool.c:165
const int STORAGE_VERSION
Определения PlayerAgentPool.c:3
int GetStorageVersion()
Определения PlayerAgentPool.c:28
void PrintAgents()
Определения PlayerAgentPool.c:33
void SetAgentCount(int agent_id, float count)
Определения PlayerAgentPool.c:247
void GetDebugObject(array< ref Param > object_out)
Определения PlayerAgentPool.c:332
int GetSingleAgentCount(int agent_id)
Определения PlayerAgentPool.c:217
void SpawnAgents(float deltaT)
Определения PlayerAgentPool.c:234
void GrowAgents(float deltaT)
Определения PlayerAgentPool.c:52
Определения PlayerBaseClient.c:2
proto bool Write(void value_out)
proto bool Read(void value_in)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Serializer ParamsReadContext
Определения gameplay.c:15
Serializer ParamsWriteContext
Определения gameplay.c:16
static proto int AbsInt(int i)
Returns absolute value.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.