DayZ 1.24
Loading...
Searching...
No Matches
PlayerStatsPCO.c
Go to the documentation of this file.
2
4{
7
9 {
10 RegisterPCO(new PlayerStatsPCO_v100);
13 }
14
16 {
17 int version = pco.GetVersion();
18
19 if (version > m_HighestVersion)
20 m_HighestVersion = version;
21
22 m_PCOs.Insert(version, pco);
23 }
24
25 PlayerStatsPCO_Base GetPCO(int version = -1)
26 {
27 //PlayerStatsPCO_Base pco;
28
29 if (version == -1) //no version set - fetch the highest version
30 return m_PCOs.Get(m_HighestVersion);
31 else if (!m_PCOs.Contains(version))//version set - version not present, fetch the closest lower version
32 {
33 for (int i = version; i > 100; i--)
34 {
35 if (m_PCOs.Contains(i))
36 {
37 //Print("fetching PCO version:"+ i);
38 return m_PCOs.Get(i);
39 }
40 }
41 return null;
42 }
43 else//version set - version present, fetch it
44 {
45 //Print("fetching PCO version:"+ version);
46 return m_PCOs.Get(version);
47 }
48 }
49}
50
51
53{
55 {
57 }
59 void Init();
60
62 {
63 return -1;
64 }
74 {
75 m_PlayerStats.InsertAt(stat, id);
76 stat.Init(id/*, this*/);
77 }
78
80 {
81 for (int i = 0; i < m_PlayerStats.Count(); i++)
82 m_PlayerStats.Get(i).OnStoreSave(ctx);
83 }
84
86 {
87 for (int i = 0; i < m_PlayerStats.Count(); i++)
88 {
89 if (!m_PlayerStats.Get(i).OnStoreLoad(ctx))
90 return false;
91 }
92 return true;
93 }
94
99
101 {
102 m_PlayerStats.Clear();
103 Init();
104 }
105}
106
107//---------------------------------------------------------------
108//------------------------- version 100 -------------------------
109//---------------------------------------------------------------
125
126
127class PlayerStatsPCO_v100 extends PlayerStatsPCO_Base
128{
129
130 override int GetVersion()
131 {
132 return 100;
133 }
134
135 override void Init()
136 {
137 RegisterStat(EPlayerStats_v100.HEATCOMFORT, new PlayerStat<float> (-1, 1, 0, "HeatComfort", EPSstatsFlags.EMPTY));
138 RegisterStat(EPlayerStats_v100.TREMOR, new PlayerStat<float> (0, 1, 0, "Tremor", EPSstatsFlags.EMPTY));
139 RegisterStat(EPlayerStats_v100.WET, new PlayerStat<int> (0, 1, 0, "Wet", EPSstatsFlags.EMPTY));
140 RegisterStat(EPlayerStats_v100.ENERGY, new PlayerStat<float> (0, 20000, 600, "Energy", EPSstatsFlags.EMPTY));
141 RegisterStat(EPlayerStats_v100.WATER, new PlayerStat<float> (0, 5000, 500, "Water", EPSstatsFlags.EMPTY));
142 RegisterStat(EPlayerStats_v100.STOMACH_SOLID, new PlayerStat<float> (0, 5000, 0, "StomachSolid", EPSstatsFlags.EMPTY));
143 RegisterStat(EPlayerStats_v100.STOMACH_ENERGY, new PlayerStat<float> (0, 40000, 0, "StomachEnergy", EPSstatsFlags.EMPTY));
144 RegisterStat(EPlayerStats_v100.STOMACH_WATER, new PlayerStat<float> (0, 5000, 0, "StomachWater", EPSstatsFlags.EMPTY));
145 RegisterStat(EPlayerStats_v100.DIET, new PlayerStat<float> (0, 5000, 2500, "Diet", EPSstatsFlags.EMPTY));
147 RegisterStat(EPlayerStats_v100.SPECIALTY, new PlayerStat<float> (-1, 1, 0, "Specialty", EPSstatsFlags.EMPTY));
148 RegisterStat(EPlayerStats_v100.BLOODTYPE, new PlayerStat<int> (0, 128, BloodTypes.GenerateBloodType(), "BloodType", EPSstatsFlags.EMPTY));
149 }
150
152 {
153
154 }
155
156};
157//---------------------------------------------------------------
158//------------------------- version 101 -------------------------
159//---------------------------------------------------------------
160
162{
164 TREMOR,
165 WET,
166 ENERGY,
167 WATER,
171 DIET,
172 STAMINA,
173 SPECIALTY,
174 BLOODTYPE,
176};
177
178
180{
181 override int GetVersion()
182 {
183 return 101;
184 }
185
186 override void Init()
187 {
188 RegisterStat(EPlayerStats_v101.HEATCOMFORT, new PlayerStat<float> (-1, 1, 0, "HeatComfort", EPSstatsFlags.EMPTY));
189 RegisterStat(EPlayerStats_v101.TREMOR, new PlayerStat<float> (0, 1, 0, "Tremor", EPSstatsFlags.EMPTY));
190 RegisterStat(EPlayerStats_v101.WET, new PlayerStat<int> (0, 1, 0, "Wet", EPSstatsFlags.EMPTY));
191 RegisterStat(EPlayerStats_v101.ENERGY, new PlayerStat<float> (0, 20000, 600, "Energy", EPSstatsFlags.EMPTY));
192 RegisterStat(EPlayerStats_v101.WATER, new PlayerStat<float> (0, 5000, 500, "Water", EPSstatsFlags.EMPTY));
193 RegisterStat(EPlayerStats_v101.STOMACH_SOLID, new PlayerStat<float> (0, 5000, 0, "StomachSolid", EPSstatsFlags.EMPTY));
194 RegisterStat(EPlayerStats_v101.STOMACH_ENERGY, new PlayerStat<float> (0, 40000, 0, "StomachEnergy", EPSstatsFlags.EMPTY));
195 RegisterStat(EPlayerStats_v101.STOMACH_WATER, new PlayerStat<float> (0, 5000, 0, "StomachWater", EPSstatsFlags.EMPTY));
196 RegisterStat(EPlayerStats_v101.DIET, new PlayerStat<float> (0, 5000, 2500, "Diet", EPSstatsFlags.EMPTY));
198 RegisterStat(EPlayerStats_v101.SPECIALTY, new PlayerStat<float> (-1, 1, 0, "Specialty", EPSstatsFlags.EMPTY));
199 RegisterStat(EPlayerStats_v101.BLOODTYPE, new PlayerStat<int> (0, 128, BloodTypes.GenerateBloodType(), "BloodType", EPSstatsFlags.EMPTY));
200 RegisterStat(EPlayerStats_v101.TOXICITY, new PlayerStat<float> (0, 100, 0, "Toxicity", EPSstatsFlags.EMPTY));
201 }
202};
203
204
206{
208 TREMOR,
209 WET,
210 ENERGY,
211 WATER,
212 DIET,
213 STAMINA,
214 SPECIALTY,
215 BLOODTYPE,
216 TOXICITY,
217};
218
220{
221 override int GetVersion()
222 {
223 return 106;
224 }
225
226 override void Init()
227 {
228 RegisterStat(EPlayerStats_v106.HEATCOMFORT, new PlayerStat<float> (-1, 1, 0, "HeatComfort", EPSstatsFlags.EMPTY));
229 RegisterStat(EPlayerStats_v106.TREMOR, new PlayerStat<float> (0, 1, 0, "Tremor", EPSstatsFlags.EMPTY));
230 RegisterStat(EPlayerStats_v106.WET, new PlayerStat<int> (0, 1, 0, "Wet", EPSstatsFlags.EMPTY));
231 RegisterStat(EPlayerStats_v106.ENERGY, new PlayerStat<float> (0, 20000, 600, "Energy", EPSstatsFlags.EMPTY));
232 RegisterStat(EPlayerStats_v106.WATER, new PlayerStat<float> (0, 5000, 650, "Water", EPSstatsFlags.EMPTY));
233 RegisterStat(EPlayerStats_v106.DIET, new PlayerStat<float> (0, 5000, 2500, "Diet", EPSstatsFlags.EMPTY));
235 RegisterStat(EPlayerStats_v106.SPECIALTY, new PlayerStat<float> (-1, 1, 0, "Specialty", EPSstatsFlags.EMPTY));
236 RegisterStat(EPlayerStats_v106.BLOODTYPE, new PlayerStat<int> (0, 128, BloodTypes.GenerateBloodType(), "BloodType", EPSstatsFlags.EMPTY));
237 RegisterStat(EPlayerStats_v106.TOXICITY, new PlayerStat<float> (0, 100, 0, "Toxicity", EPSstatsFlags.EMPTY));
238 }
239};
240
241
243{
245 TREMOR,
246 WET,
247 ENERGY,
248 WATER,
249 DIET,
250 STAMINA,
251 SPECIALTY,
252 BLOODTYPE,
253 TOXICITY,
255};
256
258{
259 override int GetVersion()
260 {
261 return 115;
262 }
263
264 override void Init()
265 {
266 RegisterStat(EPlayerStats_v115.HEATCOMFORT, new PlayerStat<float> (-1, 1, 0, "HeatComfort", EPSstatsFlags.EMPTY));
267 RegisterStat(EPlayerStats_v115.TREMOR, new PlayerStat<float> (0, 1, 0, "Tremor", EPSstatsFlags.EMPTY));
268 RegisterStat(EPlayerStats_v115.WET, new PlayerStat<int> (0, 1, 0, "Wet", EPSstatsFlags.EMPTY));
271 RegisterStat(EPlayerStats_v115.DIET, new PlayerStat<float> (0, 5000, 2500, "Diet", EPSstatsFlags.EMPTY));
273 RegisterStat(EPlayerStats_v115.SPECIALTY, new PlayerStat<float> (-1, 1, 0, "Specialty", EPSstatsFlags.EMPTY));
274 RegisterStat(EPlayerStats_v115.BLOODTYPE, new PlayerStat<int> (0, 128, BloodTypes.GenerateBloodType(), "BloodType", EPSstatsFlags.EMPTY));
275 RegisterStat(EPlayerStats_v115.TOXICITY, new PlayerStat<float> (0, 100, 0, "Toxicity", EPSstatsFlags.EMPTY));
276 RegisterStat(EPlayerStats_v115.HEATBUFFER, new PlayerStat<float> (-30, 30, 0, "HeatBuffer", EPSstatsFlags.EMPTY));
277 }
278};
279
280
281//---------------------------------------------------------------
282//------------------------- version current -------------------------
283//---------------------------------------------------------------
284
289
290//mod this class, it will always point to the latest version
292{
293
294};
EPSstatsFlags
Definition PlayerStats.c:2
EPlayerStats_v106
array< ref PlayerStatBase > Get()
EPlayerStats_v115
@ HEATBUFFER
@ ENERGY
@ BLOODTYPE
@ STAMINA
@ DIET
@ HEATCOMFORT
@ TREMOR
@ SPECIALTY
@ WET
@ WATER
@ TOXICITY
enum EPlayerStats_v100 PlayerStatsPCO_Base
EPlayerStats_current
bool OnStoreLoad(ParamsReadContext ctx)
ref array< ref PlayerStatBase > m_PlayerStats
EPlayerStats_v101
@ STOMACH_SOLID
@ STOMACH_ENERGY
@ STOMACH_WATER
EPlayerStats_v100
void OnStoreSave(ParamsWriteContext ctx)
void RegisterStat(int id, PlayerStatBase stat)
void ResetAllStats()
PlayerStatBase GetStatObject(int id)
static int GenerateBloodType()
Definition BloodType.c:6
static float GetStaminaMax()
ref map< int, ref PlayerStatsPCO_Base > m_PCOs
PlayerStatsPCO_Base GetPCO(int version=-1)
void RegisterPCO(PlayerStatsPCO_Base pco)
static const float SL_ENERGY_MAX
static const float SL_WATER_MAX
override void Init()
override int GetVersion()
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
const float STAMINA_MAX
Definition constants.c:663