DayZ 1.24
Loading...
Searching...
No Matches
PluginLifespan.c File Reference

Go to the source code of this file.

Enumerations

enum  eBloodyHandsTypes { CLEAN = 0 , SALMONELA , JUST_BLOOD , LAST_INDEX }
 

Functions

static PluginLifespan GetInstance ()
 
void PluginLifespan ()
 
void LoadFromCfg ()
 
void SynchLifespanVisual (PlayerBase player, int beard_state_visible, bool bloody_hands_visible, bool blood_type_visible, int blood_type)
 
void ChangeFakePlaytime (PlayerBase player, int change)
 
void UpdateLifespan (PlayerBase player, bool force_update=false)
 
void UpdateLifespanLevel (PlayerBase player, float player_beard, bool force_update=false)
 
LifespanLevel GetLifespanLevel (string player_class, float age=0)
 
void SetPlayerLifespanLevel (PlayerBase player, LifespanLevel level)
 
void SynchBeardVisual (PlayerBase player, int state)
 
void UpdateBloodyHandsVisibilityEx (PlayerBase player, eBloodyHandsTypes type)
 
void UpdateBloodyHandsVisibility (PlayerBase player, bool show)
 
void SynchBloodyHandsVisual (PlayerBase player, bool has_bloody_hands)
 
void SetBloodyHandsEx (PlayerBase player, eBloodyHandsTypes type)
 
void SetBloodyHands (PlayerBase player, bool show)
 
void SetHandsMaterial (PlayerBase player, int material_type)
 
bool CanMakeHandsBloody (PlayerBase player)
 
void UpdateBloodTypeVisibility (PlayerBase player, bool show)
 
void UpdateBloodType (PlayerBase player, int blood_type)
 
void SynchShowBloodTypeVisual (PlayerBase player, bool show)
 
void SynchShowBloodType (PlayerBase player, int blood_type)
 
string GetCurrentHeadTexture (PlayerBase player)
 
string GetCurrentHeadMaterial (PlayerBase player)
 

Variables

enum eBloodyHandsTypes BEARD_NONE = 0
 
enum eBloodyHandsTypes BEARD_MEDIUM = 1
 
enum eBloodyHandsTypes BEARD_LARGE = 2
 
enum eBloodyHandsTypes BEARD_EXTRA = 3
 
enum eBloodyHandsTypes COUNT = 4
 
enum eBloodyHandsTypes LIFESPAN_MIN = 0
 
static const int LIFESPAN_MAX = 240
 
int m_FakePlaytime
 
ref map< PlayerBase, ref LifespanLevelm_PlayerCurrentLevel
 
ref map< string, ref array< ref LifespanLevel > > m_LifespanLevels
 
ref map< string, ref BloodyHandsm_BloodyHands
 
ref map< PlayerBase, intm_BloodType
 

Enumeration Type Documentation

◆ eBloodyHandsTypes

Enumerator
CLEAN 
SALMONELA 
JUST_BLOOD 
LAST_INDEX 

Definition at line 8 of file PluginLifespan.c.

9{
10 CLEAN = 0,//clean needs to be 0
13 //--- ONLY LAST_INDEX BELLOW !!!
15}
@ JUST_BLOOD
@ CLEAN
@ LAST_INDEX
@ SALMONELA

Function Documentation

◆ CanMakeHandsBloody()

bool CanMakeHandsBloody ( PlayerBase player)
protected

Definition at line 467 of file PluginLifespan.c.

468 {
469 return !player.FindAttachmentBySlotName("Gloves"));
470 }

Referenced by UpdateBloodyHandsVisibility(), and UpdateBloodyHandsVisibilityEx().

◆ ChangeFakePlaytime()

void ChangeFakePlaytime ( PlayerBase player,
int change )
protected

Definition at line 205 of file PluginLifespan.c.

206 {
207 if (!GetGame().IsMultiplayer())
208 {
210 UpdateLifespan(player, true);
211 }
212 }
void UpdateLifespan(PlayerBase player, bool force_update=false)
int m_FakePlaytime
proto native CGame GetGame()

References GetGame(), m_FakePlaytime, and UpdateLifespan().

◆ GetCurrentHeadMaterial()

string GetCurrentHeadMaterial ( PlayerBase player)
protected

Definition at line 513 of file PluginLifespan.c.

514 {
515 if (m_PlayerCurrentLevel.Contains(player))
516 {
518 return current_level.GetMaterialName();
519 }
520 return "";
521 }
ref map< PlayerBase, ref LifespanLevel > m_PlayerCurrentLevel

References m_PlayerCurrentLevel.

◆ GetCurrentHeadTexture()

string GetCurrentHeadTexture ( PlayerBase player)
protected

Definition at line 503 of file PluginLifespan.c.

504 {
505 if (m_PlayerCurrentLevel.Contains(player))
506 {
508 return current_level.GetTextureName();
509 }
510 return "";
511 }

References m_PlayerCurrentLevel.

◆ GetInstance()

static PluginLifespan GetInstance ( )
staticprotected

Definition at line 40 of file PluginLifespan.c.

41 {
43 }
void PluginLifespan()
PluginBase GetPlugin(typename plugin_type)

References GetPlugin(), and PluginLifespan().

◆ GetLifespanLevel()

LifespanLevel GetLifespanLevel ( string player_class,
float age = 0 )
protected

Definition at line 269 of file PluginLifespan.c.

270 {
272
273 if (lifespan_levels != NULL)
274 {
275 for (int i = lifespan_levels.Count() - 1; i >= 0; i--)
276 {
278
279 if (age >= level.GetThreshold())
280 return level;
281 }
282 }
283
284 return NULL;
285 }
ref map< string, ref array< ref LifespanLevel > > m_LifespanLevels

References m_LifespanLevels.

Referenced by UpdateLifespanLevel().

◆ LoadFromCfg()

void LoadFromCfg ( )
protected

Definition at line 56 of file PluginLifespan.c.

57 {
60
62
63 //cfg_name = 'CfgVehicles'
64 // config_name = 'CfgVehicles'
65 //cfg_class_count = 2348
66 // config_count = 2348
67 //cfg_class_name = 'SurvivorMale_Base'
68 // survivor_name = 'SurvivorMale_Base'
69 //cfg_class_fullname = 'CfgVehicles SurvivorMale_Base'
70 // survivor_path = 'CfgVehicles SurvivorMale_Base'
71 //cfg_class_member_count = 10
72 // survivor_lifespan_count = 10
73 //cfg_class_member_name = 'Lifespan'
74 // survivor_lifespan_name = 'Lifespan'
75 //cfg_class_member_fullname = 'CfgVehicles SurvivorMale_Base Lifespan';
76 // survivor_lifespan_path = 'CfgVehicles SurvivorMale_Base Lifespan';
77 //cfg_class_member_member_count = 1
78 // survivor_lifespan_beard_count = 1
79 //cfg_class_member_member_name = 'Beard'
80 // survivor_lifespan_beard_name = 'Beard'
81 //cfg_class_member_member_fullname = 'CfgVehicles SurvivorMale_Base Lifespan Beard'
82 // survivor_lifespan_beard_path = 'CfgVehicles SurvivorMale_Base Lifespan Beard'
83 //cfg_class_member_member_variable_name = 'mat'
84 // survivor_lifespan_beard_material_name = 'mat'
85 //cfg_class_member_member_variable_fullname = 'CfgVehicles SurvivorMale_Base Lifespan Beard mat'
86 // survivor_lifespan_beard_material_path = 'CfgVehicles SurvivorMale_Base Lifespan Beard mat'
87
88 string config_name = "CfgVehicles";
89 int config_count = GetGame().ConfigGetChildrenCount(config_name);
90
91 int i, j, k, l, m;
92
93 //Print( "config_count: " + config_count );
94 for (i = 0; i < config_count; i++)
95 {
96 string survivor_name = "";
97 GetGame().ConfigGetChildName(config_name, i, survivor_name);
98
99 if (survivor_name != "" && survivor_name != "access")
100 {
101 if (GetGame().IsKindOf(survivor_name, "SurvivorMale_Base") || GetGame().IsKindOf(survivor_name, "SurvivorFemale_Base"))
102 {
103 string survivor_path = config_name + " " + survivor_name;
104 int survivor_lifespan_count = GetGame().ConfigGetChildrenCount(survivor_path);
105
106 //Print( "survivor_path: " + survivor_path );
107 for (j = 0; j < survivor_lifespan_count; j++)
108 {
109 string survivor_lifespan_name = "";
110 GetGame().ConfigGetChildName(survivor_path, j, survivor_lifespan_name);
111
113
114 if (survivor_lifespan_name == "Lifespan")
115 {
116 int survivor_lifespan_beard_count = GetGame().ConfigGetChildrenCount(survivor_lifespan_path);
117
118 for (k = 0; k < survivor_lifespan_beard_count; k++)
119 {
122
124
125 if (survivor_lifespan_beard_name == "Beard")
126 {
129
131 {
135
137 {
139
141
142 int level_count = materials.Count() / 2;
143 for (m = 0; m < level_count; m++)
144 {
145 int tex = m * 2;
146 int mat = ((m * 2) + 1);
147 if (mat < materials.Count())
148 {
149 float threshold = (((float)m / (float)(level_count - 1)) * (float)LIFESPAN_LENGTH) + (float)LIFESPAN_MIN;
151 //Print("material a textura a threshold: " + materials.Get(tex) + " " + materials.Get(mat) + " " + threshold );
152 }
153 }
154
155 if (lifespan_levels.Count() > 0)
157 }
158 }
159 }
160 }
161 }
162 else if (survivor_lifespan_name == "BloodyHands")
163 {
165 string path_normal = survivor_lifespan_path + " mat_normal";
166 string path_bloody = survivor_lifespan_path + " mat_blood";
167 GetGame().ConfigGetText(path_normal, normal_material);
168 GetGame().ConfigGetText(path_bloody, bloody_material);
170 }
171 }
172 }
173 }
174 }
175
176 /*for ( int cl = 0; cl < m_LifespanLevels.Count(); cl++ )
177 {
178 string class_name = m_LifespanLevels.GetKey( cl );
179 array<ref LifespanLevel> levels = m_LifespanLevels.GetElement( cl );
180
181 Print( class_name );
182
183 for ( int ll = 0; ll < levels.Count(); ll++)
184 {
185 Print( "lvl: " + levels.Get( ll ).GetLevel() );
186 Print( "treshold: " + levels.Get( ll ).GetThreshold() );
187 Print( "texture: " + levels.Get( ll ).GetTextureName() );
188 Print( "material: " + levels.Get( ll ).GetMaterialName() );
189 }
190 }*/
191 }
static const int LIFESPAN_MAX
enum eBloodyHandsTypes LIFESPAN_MIN
ref map< string, ref BloodyHands > m_BloodyHands
array< string > TStringArray
Definition EnScript.c:666

References GetGame(), LIFESPAN_MAX, LIFESPAN_MIN, m_BloodyHands, and m_LifespanLevels.

◆ PluginLifespan()

◆ SetBloodyHands()

void SetBloodyHands ( PlayerBase player,
bool show )
protected

Definition at line 437 of file PluginLifespan.c.

438 {
439 player.SetBloodyHands(show);
440
441 if (show)
443 else
445 }
void SetHandsMaterial(PlayerBase player, int material_type)
const int MATERIAL_TYPE_BLOODY
Definition BloodyHands.c:6
const int MATERIAL_TYPE_NORMAL
Definition BloodyHands.c:5

References BloodyHands::MATERIAL_TYPE_BLOODY, BloodyHands::MATERIAL_TYPE_NORMAL, and SetHandsMaterial().

Referenced by UpdateBloodyHandsVisibility().

◆ SetBloodyHandsEx()

void SetBloodyHandsEx ( PlayerBase player,
eBloodyHandsTypes type )
protected

◆ SetHandsMaterial()

void SetHandsMaterial ( PlayerBase player,
int material_type )
protected

Definition at line 447 of file PluginLifespan.c.

448 {
449 string player_class = player.GetPlayerClass();
450 int slot_id;
452
453 if (m_BloodyHands.Contains(player_class))
454 {
456 eai = player.GetInventory().FindPlaceholderForSlot(slot_id);
457
458 if (eai)
459 eai.SetObjectMaterial(0, m_BloodyHands.Get(player_class).GetMaterial(material_type));
460 }
461 else
462 {
463 //Print("Error! Player class <" + player_class + "> does not contain valid configuration for bloody hands!");
464 }
465 }
provides access to slot configuration
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id

References InventorySlots::GetSlotIdFromString(), and m_BloodyHands.

Referenced by SetBloodyHands(), and SetBloodyHandsEx().

◆ SetPlayerLifespanLevel()

void SetPlayerLifespanLevel ( PlayerBase player,
LifespanLevel level )
protected

Definition at line 287 of file PluginLifespan.c.

288 {
289 if (player.m_CorpseState != 0)
290 return;
292 EntityAI players_head = player.GetInventory().FindPlaceholderForSlot(slot_id);
293
294 if (players_head)
295 {
296 switch (level.GetLevel())
297 {
298 case LifeSpanState.BEARD_NONE:
299 {
300 players_head.SetObjectTexture(0, "");
301 players_head.SetObjectMaterial(0, "");
302
303 player.SetFaceTexture(level.GetTextureName());
304 player.SetFaceMaterial(level.GetMaterialName());
305
306 player.SetLifeSpanStateVisible(LifeSpanState.BEARD_NONE);
307 //Print("LifeSpanState.BEARD_NONE");
308 break;
309 }
310 case LifeSpanState.BEARD_MEDIUM:
311 {
312 players_head.SetObjectTexture(0, "");
313 players_head.SetObjectMaterial(0, "");
314
315 player.SetFaceTexture(level.GetTextureName());
316 player.SetFaceMaterial(level.GetMaterialName());
317
318 player.SetLifeSpanStateVisible(LifeSpanState.BEARD_MEDIUM);
319 //Print("LifeSpanState.BEARD_MEDIUM");
320 break;
321 }
322
323 case LifeSpanState.BEARD_LARGE:
324 {
325 players_head.SetObjectTexture(0, "");
326 players_head.SetObjectMaterial(0, "");
327
328 player.SetFaceTexture(level.GetTextureName());
329 player.SetFaceMaterial(level.GetMaterialName());
330
331 player.SetLifeSpanStateVisible(LifeSpanState.BEARD_LARGE);
332 //Print("LifeSpanState.BEARD_LARGE");
333 break;
334 }
335
336 case LifeSpanState.BEARD_EXTRA:
337 {
338 players_head.SetObjectTexture(0, level.GetTextureName());
339 players_head.SetObjectMaterial(0, level.GetMaterialName());
340
343
344 player.SetFaceTexture(prev_level.GetTextureName());
345 player.SetFaceMaterial(prev_level.GetMaterialName());
346
347 player.SetLifeSpanStateVisible(LifeSpanState.BEARD_EXTRA);
348 //Print("LifeSpanState.BEARD_EXTRA");
349 break;
350 }
351
352 default:
353 {
354 Print("Lifespan state missing");
355 break;
356 }
357 }
358 }
359 }
proto void Print(void var)
Prints content of variable to console/log.

References InventorySlots::GetSlotIdFromString(), m_LifespanLevels, and Print().

Referenced by UpdateLifespanLevel().

◆ SynchBeardVisual()

void SynchBeardVisual ( PlayerBase player,
int state )
protected

Definition at line 361 of file PluginLifespan.c.

362 {
363 float player_beard;
364
365 switch (state)
366 {
367 case LifeSpanState.BEARD_NONE:
368 {
369 // first out of 4 states
371 break;
372 }
373 case LifeSpanState.BEARD_MEDIUM:
374 {
375 // second out of 4 states
377 break;
378 }
379
380 case LifeSpanState.BEARD_LARGE:
381 {
382 // third out of 4 states
384 break;
385 }
386
387 case LifeSpanState.BEARD_EXTRA:
388 {
389 // fourth out of 4 states
391 break;
392 }
393
394 default:
395 {
396 Print("Lifespan state missing");
397 break;
398 }
399 }
400
402 }
void UpdateLifespanLevel(PlayerBase player, float player_beard, bool force_update=false)

References LIFESPAN_MAX, LIFESPAN_MIN, Print(), and UpdateLifespanLevel().

Referenced by SynchLifespanVisual().

◆ SynchBloodyHandsVisual()

void SynchBloodyHandsVisual ( PlayerBase player,
bool has_bloody_hands )
protected

Definition at line 420 of file PluginLifespan.c.

421 {
423 }
void UpdateBloodyHandsVisibility(PlayerBase player, bool show)

References UpdateBloodyHandsVisibility().

Referenced by SynchLifespanVisual().

◆ SynchLifespanVisual()

void SynchLifespanVisual ( PlayerBase player,
int beard_state_visible,
bool bloody_hands_visible,
bool blood_type_visible,
int blood_type )
protected

Definition at line 197 of file PluginLifespan.c.

198 {
203 }
void SynchShowBloodTypeVisual(PlayerBase player, bool show)
void SynchBloodyHandsVisual(PlayerBase player, bool has_bloody_hands)
void SynchBeardVisual(PlayerBase player, int state)
void SynchShowBloodType(PlayerBase player, int blood_type)

References SynchBeardVisual(), SynchBloodyHandsVisual(), SynchShowBloodType(), and SynchShowBloodTypeVisual().

◆ SynchShowBloodType()

void SynchShowBloodType ( PlayerBase player,
int blood_type )
protected

Definition at line 494 of file PluginLifespan.c.

495 {
497 }
void UpdateBloodType(PlayerBase player, int blood_type)

References UpdateBloodType().

Referenced by SynchLifespanVisual().

◆ SynchShowBloodTypeVisual()

void SynchShowBloodTypeVisual ( PlayerBase player,
bool show )
protected

Definition at line 489 of file PluginLifespan.c.

490 {
492 }
void UpdateBloodTypeVisibility(PlayerBase player, bool show)

References UpdateBloodTypeVisibility().

Referenced by SynchLifespanVisual().

◆ UpdateBloodType()

void UpdateBloodType ( PlayerBase player,
int blood_type )
protected

Definition at line 484 of file PluginLifespan.c.

485 {
486 player.SetBloodType(blood_type);
487 }

Referenced by SynchShowBloodType().

◆ UpdateBloodTypeVisibility()

void UpdateBloodTypeVisibility ( PlayerBase player,
bool show )
protected

Definition at line 476 of file PluginLifespan.c.

477 {
478 player.SetBloodTypeVisible(show);
479
480 if (player.m_Hud)
481 player.m_Hud.UpdateBloodName();
482 }

Referenced by SynchShowBloodTypeVisual().

◆ UpdateBloodyHandsVisibility()

void UpdateBloodyHandsVisibility ( PlayerBase player,
bool show )
protected

Definition at line 414 of file PluginLifespan.c.

415 {
417 SetBloodyHands(player, show);
418 }
void SetBloodyHands(PlayerBase player, bool show)
bool CanMakeHandsBloody(PlayerBase player)

References CanMakeHandsBloody(), and SetBloodyHands().

Referenced by SynchBloodyHandsVisual().

◆ UpdateBloodyHandsVisibilityEx()

void UpdateBloodyHandsVisibilityEx ( PlayerBase player,
eBloodyHandsTypes type )
protected

Definition at line 408 of file PluginLifespan.c.

409 {
412 }
void SetBloodyHandsEx(PlayerBase player, eBloodyHandsTypes type)

References CanMakeHandsBloody(), and SetBloodyHandsEx().

◆ UpdateLifespan()

void UpdateLifespan ( PlayerBase player,
bool force_update = false )
protected

Definition at line 218 of file PluginLifespan.c.

219 {
220 if (player != null)
221 {
223
224 if (GetGame().IsMultiplayer() && GetGame().IsServer())
226
227 float playerBeard = playerPlaytime - player.GetLastShavedSeconds();
228 playerBeard = playerBeard / 60.0;
229
231 }
232 }

References GetGame(), m_FakePlaytime, AnalyticsManagerServer::STAT_PLAYTIME, and UpdateLifespanLevel().

Referenced by ChangeFakePlaytime().

◆ UpdateLifespanLevel()

void UpdateLifespanLevel ( PlayerBase player,
float player_beard,
bool force_update = false )
protected

Definition at line 234 of file PluginLifespan.c.

235 {
236 if (!player.IsAlive())
237 return;
238
239 if (m_PlayerCurrentLevel.Contains(player))
240 {
242
243 if (player_beard > current_level.GetThreshold() || force_update)
244 {
246
247 if (next_level != NULL)
248 {
251 }
252 }
253 }
254 else
255 {
256 if (m_LifespanLevels.Contains(player.GetPlayerClass()))
257 {
259
260 if (level != NULL)
261 {
264 }
265 }
266 }
267 }
void SetPlayerLifespanLevel(PlayerBase player, LifespanLevel level)
LifespanLevel GetLifespanLevel(string player_class, float age=0)

References GetLifespanLevel(), m_LifespanLevels, m_PlayerCurrentLevel, and SetPlayerLifespanLevel().

Referenced by SynchBeardVisual(), and UpdateLifespan().

Variable Documentation

◆ BEARD_EXTRA

enum eBloodyHandsTypes BEARD_EXTRA = 3

◆ BEARD_LARGE

enum eBloodyHandsTypes BEARD_LARGE = 2

◆ BEARD_MEDIUM

enum eBloodyHandsTypes BEARD_MEDIUM = 1

◆ BEARD_NONE

enum eBloodyHandsTypes BEARD_NONE = 0

◆ COUNT

◆ LIFESPAN_MAX

const int LIFESPAN_MAX = 240
staticprotected

Definition at line 29 of file PluginLifespan.c.

Referenced by LoadFromCfg(), and SynchBeardVisual().

◆ LIFESPAN_MIN

enum eBloodyHandsTypes LIFESPAN_MIN = 0

Referenced by LoadFromCfg(), and SynchBeardVisual().

◆ m_BloodType

◆ m_BloodyHands

ref map<string, ref BloodyHands> m_BloodyHands
protected

Definition at line 34 of file PluginLifespan.c.

Referenced by LoadFromCfg(), and SetHandsMaterial().

◆ m_FakePlaytime

int m_FakePlaytime
protected

Definition at line 30 of file PluginLifespan.c.

Referenced by ChangeFakePlaytime(), PluginLifespan(), and UpdateLifespan().

◆ m_LifespanLevels

ref map<string, ref array< ref LifespanLevel> > m_LifespanLevels
protected

◆ m_PlayerCurrentLevel

ref map<PlayerBase, ref LifespanLevel> m_PlayerCurrentLevel
protected