Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
pluginplayerstatus.c
Go to the documentation of this file.
1 class PluginPlayerStatus extends PluginBase
2 {
3  ref multiMap<int, string> m_NotifiersLabel;
4  ref multiMap<int, int> m_NotifiersIndexColor;
5 
6  private ref multiMap<int, string> m_NotifiersIcons;
7 
8  void PluginPlayerStatus()
9  {
10  m_NotifiersLabel = new multiMap<int, string>; // [key] label
11  m_NotifiersIndexColor = new multiMap<int, int>; // [key] index, color
12 
13  m_NotifiersIcons = new multiMap<int, string>; // [key] iconName
14  m_NotifiersIcons.Insert( NTFKEY_HUNGRY, "iconHunger" );
15  m_NotifiersIcons.Insert( NTFKEY_THIRSTY, "iconThirsty" );
16  m_NotifiersIcons.Insert( NTFKEY_SICK, "iconHealth" );
17  m_NotifiersIcons.Insert( NTFKEY_BACTERIA, "iconBacteria" );
18  m_NotifiersIcons.Insert( NTFKEY_BLEEDISH, "iconBlood" );
19  m_NotifiersIcons.Insert( NTFKEY_FEVERISH, "iconTemperature" );
20  m_NotifiersIcons.Insert( NTFKEY_FRACTURE, "iconFracture" );
21  }
22 
23  void SetNotifier( int key, int index = 9, string label = "", int color = 0xFFFFFFFF )
24  {
25  if ( key )
26  {
27  if ( m_NotifiersLabel.HasKey( key ) )
28  {
29  m_NotifiersLabel.Remove( key );
30  m_NotifiersIndexColor.Remove( key );
31  }
32 
33  if ( label != "" )
34  {
35  m_NotifiersLabel.Insert( key, label );
36  m_NotifiersIndexColor.Insert( key, index );
37  m_NotifiersIndexColor.Insert( key, color );
38  }
39  }
40  }
41 
42  void DisplayTendency( int key, int tendency, int status = 1 )
43  {
44  if ( key )
45  {
46  // display icon
47  int icon_index = 0; // maybe we'll have several icons for different tendencies
48  if ( m_NotifiersIcons.HasKey( key ) )
49  {
50  string icon_name = m_NotifiersIcons.Get( key ).Get( icon_index );
51  Mission mission = GetGame().GetMission();
52  if ( mission )
53  {
54  Hud hud = mission.GetHud();
55  if ( hud )
56  {
57  hud.DisplayNotifier( key, tendency, status );
58  }
59  }
60  }
61  }
62  }
63 
64  void SetBadge( int key, int value )
65  {
66  if ( key )
67  {
68  Mission mission = GetGame().GetMission();
69  if ( mission )
70  {
71  Hud hud = mission.GetHud();
72  if ( hud )
73  {
74  hud.DisplayBadge( key, value );
75  }
76  }
77  }
78  }
79 
80  void SetStamina( int value , int range )
81  {
82  // Log( String( "SetStamina" + itoa( value) ), LogTemplates.TEMPLATE_JANOSIK );
83  Mission mission = GetGame().GetMission();
84  if ( mission )
85  {
86  Hud hud = mission.GetHud();
87  if ( hud )
88  {
89  hud.SetStamina( Math.Clamp( value, 0, range ), range );
90  }
91  }
92  }
93 
94  void SetStance( int value )
95  {
96  Mission mission = GetGame().GetMission();
97  if ( mission )
98  {
99  Hud hud = mission.GetHud();
100  if ( hud )
101  {
102  hud.DisplayStance( value );
103  }
104  }
105  }
106 }
GetGame
proto native CGame GetGame()
NTFKEY_THIRSTY
enum eBadgeLevel NTFKEY_THIRSTY
mission
Mission mission
Definition: displaystatus.c:28
Mission
Mission class.
Definition: gameplay.c:670
NTFKEY_HUNGRY
const int NTFKEY_HUNGRY
Definition: _constants.c:34
NTFKEY_FEVERISH
const int NTFKEY_FEVERISH
Definition: _constants.c:39
PluginBase
Definition: pluginadminlog.c:1
NTFKEY_SICK
const int NTFKEY_SICK
Definition: _constants.c:40
NTFKEY_BLEEDISH
const int NTFKEY_BLEEDISH
Definition: _constants.c:42
NTFKEY_BACTERIA
const int NTFKEY_BACTERIA
Definition: _constants.c:45
NTFKEY_FRACTURE
const int NTFKEY_FRACTURE
Definition: _constants.c:37
Math
Definition: enmath.c:6
Hud
Definition: gameplay.c:623