Planeshift
vitals.h
Go to the documentation of this file.
1 /*
2  * vitals.h
3  *
4  * Copyright (C) 2005 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef PS_VITAL_HEADER
21 #define PS_VITAL_HEADER
22 
23 #define HP_REGEN_RATE 0.2F
24 #define MANA_REGEN_RATE 0.2F
25 
26 
31 {
36  VITAL_COUNT // Count used to build a array of vitals, not a legal vital name
37 };
38 
41 {
42  DIRTY_VITAL_HP = 0x0001,
45  DIRTY_VITAL_MANA = 0x0008,
62 };
63 
67 template <typename Vital>
69 {
70 public:
72  {
73  experiencePoints = 0;
75  lastDRUpdate = 0;
76  }
78 
79  void SetVitals(const psVitalManager & newVitalMgr)
80  {
81  for(int i = 0; i < VITAL_COUNT; i++)
82  {
83  vitals[i] = newVitalMgr.vitals[i];
84  }
85  }
86 
88  void ResetVitals()
89  {
90  for (int i = 0; i < VITAL_COUNT; i++)
91  vitals[i] = origVitals[i];
92  }
93 
96  {
97  for (int i = 0; i < VITAL_COUNT; i++)
98  origVitals[i] = vitals[i];
99  }
100 
106  Vital & GetVital(int vital)
107  {
108  CS_ASSERT(vital >= 0 && vital < VITAL_COUNT);
109  return vitals[vital];
110  }
111 
112  // Quick accessors
113  float GetHP()
114  {
115  return vitals[VITAL_HITPOINTS].value;
116  }
117 
118  float GetMana()
119  {
120  return vitals[VITAL_MANA].value;
121  }
122 
123  float GetPStamina()
124  {
125  return vitals[VITAL_PYSSTAMINA].value;
126  }
127 
128  float GetMStamina()
129  {
130  return vitals[VITAL_MENSTAMINA].value;
131  }
132 
134  unsigned int GetExp() { return experiencePoints; }
135 
137  unsigned int GetPP() { return progressionPoints; }
138 
139 protected:
140  csTicks lastDRUpdate;
141 
144  Vital origVitals[VITAL_COUNT]; // saved copy for quick restore
145 
147  unsigned int experiencePoints;
148 
150  unsigned int progressionPoints;
151 };
152 #endif
void SetVitals(const psVitalManager &newVitalMgr)
Definition: vitals.h:79
PS_VITALS
The vitals that the client is concerned about.
Definition: vitals.h:30
unsigned int experiencePoints
Players current experience points.
Definition: vitals.h:147
void ResetVitals()
Reset to the "original" vitals (for use when killing NPCs).
Definition: vitals.h:88
psVitalManager()
Definition: vitals.h:71
unsigned int progressionPoints
Players progression Points.
Definition: vitals.h:150
float GetPStamina()
Definition: vitals.h:123
PS_DIRTY_VITALS
Used by the server to tell which fields are incoming.
Definition: vitals.h:40
unsigned int GetExp()
Get players experience points.
Definition: vitals.h:134
Manages a set of Vitals and does the predictions and updates on them when new data comes from the ser...
Definition: vitals.h:68
unsigned int GetPP()
Gets a players current progression points.
Definition: vitals.h:137
void SetOrigVitals()
Saves the current vitals as the "original".
Definition: vitals.h:95
float value
Definition: clientvitals.h:42
float GetMana()
Definition: vitals.h:118
~psVitalManager()
Definition: vitals.h:77
csTicks lastDRUpdate
Definition: vitals.h:140
Vital vitals[VITAL_COUNT]
A list of player vitals.
Definition: vitals.h:143
float GetHP()
Definition: vitals.h:113
float GetMStamina()
Definition: vitals.h:128
A character vital (such as HP or Mana) - client side.
Definition: clientvitals.h:38
Vital & GetVital(int vital)
Get a reference to a particular vital.
Definition: vitals.h:106
Vital origVitals[VITAL_COUNT]
Definition: vitals.h:144