Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
playerstatspco.c
Go to the documentation of this file.
1 
2 
4 {
6  int m_HighestVersion;
7 
8  void PCOHandlerStats()
9  {
10  RegisterPCO(new PlayerStatsPCO_v100);
11  RegisterPCO(new PlayerStatsPCO_v101);
12  RegisterPCO(new PlayerStatsPCO_current);
13  }
14 
15  void RegisterPCO(PlayerStatsPCO_Base pco)
16  {
17  int version = pco.GetVersion();
18 
19  if( version > m_HighestVersion )
20  {
21  m_HighestVersion = version;
22  }
23 
24  m_PCOs.Insert(version, pco);
25  }
26 
27  PlayerStatsPCO_Base GetPCO(int version = -1)
28  {
29  //PlayerStatsPCO_Base pco;
30 
31  if(version == -1)//no version set - fetch the highest version
32  {
33  return m_PCOs.Get(m_HighestVersion);
34  }
35  else if( !m_PCOs.Contains(version))//version set - version not present, fetch the closest lower version
36  {
37  for(int i = version; i > 100; i--)
38  {
39  if(m_PCOs.Contains(i))
40  {
41  //Print("fetching PCO version:"+ i);
42  return m_PCOs.Get(i);
43  }
44  }
45  return null;
46  }
47  else//version set - version present, fetch it
48  {
49  //Print("fetching PCO version:"+ version);
50  return m_PCOs.Get(version);
51  }
52  }
53 }
54 
55 
57 {
59  {
60  Init();
61  }
62 
63  void Init();
64 
65  int GetVersion()
66  {
67  return -1;
68  }
69 
71 
73  {
74  return m_PlayerStats.Get(id);
75  }
76 
77  void RegisterStat(int id, PlayerStatBase stat)
78  {
79  m_PlayerStats.InsertAt(stat, id);
80  stat.Init(id/*, this*/);
81  }
82 
84  {
85  for ( int i = 0; i < m_PlayerStats.Count(); i++ )
86  {
87  m_PlayerStats.Get(i).OnStoreSave(ctx);
88  }
89  }
90 
92  {
93  for ( int i = 0; i < m_PlayerStats.Count(); i++ )
94  {
95  if(!m_PlayerStats.Get(i).OnStoreLoad(ctx))
96  {
97  return false;
98  }
99  }
100  return true;
101  }
102 
104  {
105  return m_PlayerStats;
106  }
107 
109  {
110  m_PlayerStats.Clear();
111  Init();
112  }
113 }
114 
115 //---------------------------------------------------------------
116 //------------------------- version 100 -------------------------
117 //---------------------------------------------------------------
119 {
132 };
133 
134 
135 class PlayerStatsPCO_v100 extends PlayerStatsPCO_Base
136 {
137 
138  override int GetVersion()
139  {
140  return 100;
141  }
142 
143  override void Init()
144  {
145  RegisterStat(EPlayerStats_v100.HEATCOMFORT, new PlayerStat<float> (-1, 1, 0, "HeatComfort", EPSstatsFlags.EMPTY) );
146  RegisterStat(EPlayerStats_v100.TREMOR, new PlayerStat<float> (0, 1, 0, "Tremor", EPSstatsFlags.EMPTY) );
147  RegisterStat(EPlayerStats_v100.WET, new PlayerStat<int> (0, 1, 0, "Wet", EPSstatsFlags.EMPTY) );
148  RegisterStat(EPlayerStats_v100.ENERGY, new PlayerStat<float> (0, 20000, 600, "Energy", EPSstatsFlags.EMPTY) );
149  RegisterStat(EPlayerStats_v100.WATER, new PlayerStat<float> (0, 5000, 500, "Water", EPSstatsFlags.EMPTY) );
150  RegisterStat(EPlayerStats_v100.STOMACH_SOLID, new PlayerStat<float> (0, 5000, 0, "StomachSolid", EPSstatsFlags.EMPTY) );
151  RegisterStat(EPlayerStats_v100.STOMACH_ENERGY, new PlayerStat<float> (0, 40000, 0, "StomachEnergy", EPSstatsFlags.EMPTY) );
152  RegisterStat(EPlayerStats_v100.STOMACH_WATER, new PlayerStat<float> (0, 5000, 0, "StomachWater", EPSstatsFlags.EMPTY) );
153  RegisterStat(EPlayerStats_v100.DIET, new PlayerStat<float> (0, 5000, 2500, "Diet", EPSstatsFlags.EMPTY) );
154  RegisterStat(EPlayerStats_v100.STAMINA, new PlayerStat<float> (0, GameConstants.STAMINA_MAX, 100, "Stamina", EPSstatsFlags.EMPTY) );
155  RegisterStat(EPlayerStats_v100.SPECIALTY, new PlayerStat<float> (-1, 1, 0, "Specialty", EPSstatsFlags.EMPTY) );
156  RegisterStat(EPlayerStats_v100.BLOODTYPE, new PlayerStat<int> (0, 128, BloodTypes.GenerateBloodType(), "BloodType", EPSstatsFlags.EMPTY) );
157  }
158 
159  void PlayerStatsPCO_v100()
160  {
161 
162  }
163 
164 };
165 //---------------------------------------------------------------
166 //------------------------- version 101 -------------------------
167 //---------------------------------------------------------------
168 
170 {
171  HEATCOMFORT,
172  TREMOR,
173  WET,
174  ENERGY,
175  WATER,
179  DIET,
180  STAMINA,
181  SPECIALTY,
182  BLOODTYPE,
184 };
185 
186 
187 class PlayerStatsPCO_v101 extends PlayerStatsPCO_Base
188 {
189  override int GetVersion()
190  {
191  return 101;
192  }
193 
194  override void Init()
195  {
196  RegisterStat(EPlayerStats_v101.HEATCOMFORT, new PlayerStat<float> (-1, 1, 0, "HeatComfort", EPSstatsFlags.EMPTY) );
197  RegisterStat(EPlayerStats_v101.TREMOR, new PlayerStat<float> (0, 1, 0, "Tremor", EPSstatsFlags.EMPTY) );
198  RegisterStat(EPlayerStats_v101.WET, new PlayerStat<int> (0, 1, 0, "Wet", EPSstatsFlags.EMPTY) );
199  RegisterStat(EPlayerStats_v101.ENERGY, new PlayerStat<float> (0, 20000, 600, "Energy", EPSstatsFlags.EMPTY) );
200  RegisterStat(EPlayerStats_v101.WATER, new PlayerStat<float> (0, 5000, 500, "Water", EPSstatsFlags.EMPTY) );
201  RegisterStat(EPlayerStats_v101.STOMACH_SOLID, new PlayerStat<float> (0, 5000, 0, "StomachSolid", EPSstatsFlags.EMPTY) );
202  RegisterStat(EPlayerStats_v101.STOMACH_ENERGY, new PlayerStat<float> (0, 40000, 0, "StomachEnergy", EPSstatsFlags.EMPTY) );
203  RegisterStat(EPlayerStats_v101.STOMACH_WATER, new PlayerStat<float> (0, 5000, 0, "StomachWater", EPSstatsFlags.EMPTY) );
204  RegisterStat(EPlayerStats_v101.DIET, new PlayerStat<float> (0, 5000, 2500, "Diet", EPSstatsFlags.EMPTY) );
205  RegisterStat(EPlayerStats_v101.STAMINA, new PlayerStat<float> (0, GameConstants.STAMINA_MAX, 100, "Stamina", EPSstatsFlags.EMPTY) );
206  RegisterStat(EPlayerStats_v101.SPECIALTY, new PlayerStat<float> (-1, 1, 0, "Specialty", EPSstatsFlags.EMPTY) );
207  RegisterStat(EPlayerStats_v101.BLOODTYPE, new PlayerStat<int> (0, 128, BloodTypes.GenerateBloodType(), "BloodType", EPSstatsFlags.EMPTY) );
208  RegisterStat(EPlayerStats_v101.TOXICITY, new PlayerStat<float> (0, 100, 0, "Toxicity", EPSstatsFlags.EMPTY) );
209  }
210 };
211 
212 
214 {
215  HEATCOMFORT,
216  TREMOR,
217  WET,
218  ENERGY,
219  WATER,
220  DIET,
221  STAMINA,
222  SPECIALTY,
223  BLOODTYPE,
224  TOXICITY,
225 };
226 
227 class PlayerStatsPCO_v106 extends PlayerStatsPCO_Base
228 {
229  override int GetVersion()
230  {
231  return 106;
232  }
233 
234  override void Init()
235  {
236  RegisterStat(EPlayerStats_v106.HEATCOMFORT, new PlayerStat<float> (-1, 1, 0, "HeatComfort", EPSstatsFlags.EMPTY) );
237  RegisterStat(EPlayerStats_v106.TREMOR, new PlayerStat<float> (0, 1, 0, "Tremor", EPSstatsFlags.EMPTY) );
238  RegisterStat(EPlayerStats_v106.WET, new PlayerStat<int> (0, 1, 0, "Wet", EPSstatsFlags.EMPTY) );
239  RegisterStat(EPlayerStats_v106.ENERGY, new PlayerStat<float> (0, 20000, 600, "Energy", EPSstatsFlags.EMPTY) );
240  RegisterStat(EPlayerStats_v106.WATER, new PlayerStat<float> (0, 5000, 650, "Water", EPSstatsFlags.EMPTY) );
241  RegisterStat(EPlayerStats_v106.DIET, new PlayerStat<float> (0, 5000, 2500, "Diet", EPSstatsFlags.EMPTY) );
242  RegisterStat(EPlayerStats_v106.STAMINA, new PlayerStat<float> (0, GameConstants.STAMINA_MAX, 100, "Stamina", EPSstatsFlags.EMPTY) );
243  RegisterStat(EPlayerStats_v106.SPECIALTY, new PlayerStat<float> (-1, 1, 0, "Specialty", EPSstatsFlags.EMPTY) );
244  RegisterStat(EPlayerStats_v106.BLOODTYPE, new PlayerStat<int> (0, 128, BloodTypes.GenerateBloodType(), "BloodType", EPSstatsFlags.EMPTY) );
245  RegisterStat(EPlayerStats_v106.TOXICITY, new PlayerStat<float> (0, 100, 0, "Toxicity", EPSstatsFlags.EMPTY) );
246  }
247 };
248 
249 
251 {
252  HEATCOMFORT,
253  TREMOR,
254  WET,
255  ENERGY,
256  WATER,
257  DIET,
258  STAMINA,
259  SPECIALTY,
260  BLOODTYPE,
261  TOXICITY,
263 };
264 
266 {
267  override int GetVersion()
268  {
269  return 115;
270  }
271 
272  override void Init()
273  {
274  RegisterStat(EPlayerStats_v115.HEATCOMFORT, new PlayerStat<float> (-1, 1, 0, "HeatComfort", EPSstatsFlags.EMPTY) );
275  RegisterStat(EPlayerStats_v115.TREMOR, new PlayerStat<float> (0, 1, 0, "Tremor", EPSstatsFlags.EMPTY) );
276  RegisterStat(EPlayerStats_v115.WET, new PlayerStat<int> (0, 1, 0, "Wet", EPSstatsFlags.EMPTY) );
277  RegisterStat(EPlayerStats_v115.ENERGY, new PlayerStat<float> (0, PlayerConstants.SL_ENERGY_MAX, 600, "Energy", EPSstatsFlags.EMPTY) );
278  RegisterStat(EPlayerStats_v115.WATER, new PlayerStat<float> (0, PlayerConstants.SL_WATER_MAX, 600, "Water", EPSstatsFlags.EMPTY) );
279  RegisterStat(EPlayerStats_v115.DIET, new PlayerStat<float> (0, 5000, 2500, "Diet", EPSstatsFlags.EMPTY) );
280  RegisterStat(EPlayerStats_v115.STAMINA, new PlayerStat<float> (0, CfgGameplayHandler.GetStaminaMax(), 100, "Stamina", EPSstatsFlags.EMPTY) );
281  RegisterStat(EPlayerStats_v115.SPECIALTY, new PlayerStat<float> (-1, 1, 0, "Specialty", EPSstatsFlags.EMPTY) );
282  RegisterStat(EPlayerStats_v115.BLOODTYPE, new PlayerStat<int> (0, 128, BloodTypes.GenerateBloodType(), "BloodType", EPSstatsFlags.EMPTY) );
283  RegisterStat(EPlayerStats_v115.TOXICITY, new PlayerStat<float> (0, 100, 0, "Toxicity", EPSstatsFlags.EMPTY) );
284  RegisterStat(EPlayerStats_v115.HEATBUFFER, new PlayerStat<float> (-30, 30, 0, "HeatBuffer", EPSstatsFlags.EMPTY) );
285  }
286 };
287 
288 
289 //---------------------------------------------------------------
290 //------------------------- version current -------------------------
291 //---------------------------------------------------------------
292 
294 {
295 
296 };
297 
298 //mod this class, it will always point to the latest version
299 class PlayerStatsPCO_current extends PlayerStatsPCO_v115
300 {
301 
302 };
EPlayerStats_v115
EPlayerStats_v115
Definition: playerstatspco.c:250
EPlayerStats_v106
EPlayerStats_v106
Definition: playerstatspco.c:213
HEATCOMFORT
@ HEATCOMFORT
Definition: playerstatspco.c:120
OnStoreSave
void OnStoreSave(ParamsWriteContext ctx)
Definition: playerstatspco.c:83
GetVersion
int GetVersion()
Definition: playerstatspco.c:65
PlayerStatBase
Definition: playerstatbase.c:1
PlayerStatsPCO_v115
Definition: playerstatspco.c:299
SPECIALTY
@ SPECIALTY
Definition: playerstatspco.c:130
STAMINA
@ STAMINA
Definition: playerstatspco.c:129
ResetAllStats
void ResetAllStats()
Definition: playerstatspco.c:108
STOMACH_ENERGY
@ STOMACH_ENERGY
Definition: playerstatspco.c:126
EPSstatsFlags
EPSstatsFlags
Definition: playerstats.c:1
m_PlayerStats
ref array< ref PlayerStatBase > m_PlayerStats
Definition: playerstatspco.c:70
GetStatObject
PlayerStatBase GetStatObject(int id)
Definition: playerstatspco.c:72
PlayerStatsPCO_Base
Definition: playerstatspco.c:135
RegisterStat
void RegisterStat(int id, PlayerStatBase stat)
Definition: playerstatspco.c:77
BLOODTYPE
@ BLOODTYPE
Definition: playerstatspco.c:131
EPlayerStats_v100
EPlayerStats_v100
Definition: playerstatspco.c:118
OnStoreLoad
bool OnStoreLoad(ParamsReadContext ctx)
Definition: playerstatspco.c:91
m_PCOs
ref map< int, ref PlayerStatsPCO_Base > m_PCOs
Definition: playerstatspco.c:2
EPlayerStats_v101
EPlayerStats_v101
Definition: playerstatspco.c:169
ENERGY
@ ENERGY
Definition: playerstatspco.c:123
STOMACH_WATER
@ STOMACH_WATER
Definition: playerstatspco.c:127
EPlayerStats_current
EPlayerStats_current
Definition: playerstatspco.c:293
PlayerStatsPCO_Base
enum EPlayerStats_v100 PlayerStatsPCO_Base
Definition: playerstatspco.c:58
WET
@ WET
Definition: playerstatspco.c:122
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
map
map
Definition: controlsxboxnew.c:3
PlayerConstants
Definition: playerconstants.c:1
DIET
@ DIET
Definition: playerstatspco.c:128
BloodTypes
Definition: bloodtype.c:1
TREMOR
@ TREMOR
Definition: playerstatspco.c:121
Get
array< ref PlayerStatBase > Get()
Definition: playerstatspco.c:103
HEATBUFFER
@ HEATBUFFER
Definition: playerstatspco.c:262
CfgGameplayHandler
Definition: cfggameplayhandler.c:1
m_HighestVersion
int m_HighestVersion
Definition: playerstatspco.c:3
array< ref PlayerStatBase >
GameConstants
Definition: constants.c:612
Init
void Init()
Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside o...
Definition: uihintpanel.c:46
WATER
@ WATER
Definition: playerstatspco.c:124
STOMACH_SOLID
@ STOMACH_SOLID
Definition: playerstatspco.c:125
TOXICITY
@ TOXICITY
Definition: playerstatspco.c:183
PCOHandlerStats
Definition: playerstatspco.c:3