1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef RY_DEATH_PENALTIES_H
18 #define RY_DEATH_PENALTIES_H
20 #include "egs_variables.h"
21 #include "game_share/persistent_data.h"
22 #include "game_share/skills.h"
24 #include "game_share/timer.h"
30 * properties to manage death penalties
31 * \author Nicolas Brigand
32 * \author Nevrax France
37 NL_INSTANCE_COUNTER_DECL(CDeathPenalties
);
40 // Start by declaring methods for persistent load/ save operations
41 // The following macro is defined in persistent_data.h
42 // At time of writing it evaluated to:
43 // void store(CPersistentDataRecord &pdr) const;
44 // void apply(CPersistentDataRecord &pdr);
46 DECLARE_PERSISTENCE_METHODS
49 :_NbDeath(0),_CurrentDeathXP(0.0),_DeathXPToGain(0.0),_BonusUpdateTime(0),_DeathPenaltyFactor(1.0f
){}
54 _CurrentDeathXP
= 0.0;
59 void reset(CCharacter
& user
)
65 double getDeathXPToGain() { return _DeathXPToGain
- _CurrentDeathXP
; }
66 void addDeathXP(CCharacter
*user
, double xp
)
68 _CurrentDeathXP
+= xp
;
72 void addDeath(CCharacter
& user
, float deathPenaltyFactor
);
74 uint32
updateResorption( CCharacter
& user
);
76 void addXP( CCharacter
& user
, SKILLS::ESkills usedSkill
, double & xp
);
78 void addXP( CCharacter
& user
, SKILLS::ESkills usedSkill
, double & xp
, double xpRaw
);
80 void serial( NLMISC::IStream
& f
)
82 f
.xmlPush("death_penalties");
83 f
.xmlPush("nb_death");
86 f
.xmlPush("current_death_xp");
87 f
.serial(_CurrentDeathXP
);
89 f
.xmlPush("death_xp_to_gain");
90 f
.serial(_DeathXPToGain
);
92 f
.xmlPush("bonus_update_time");
93 f
.serial(_BonusUpdateTime
);
95 f
.xmlPush("nb_death");
98 void updataDb(CCharacter
& user
);
100 bool isNull() const { return (_NbDeath
== 0); }
103 /// number of death of the player ( reset when there is no more XP malus )
105 /// XP gained to recover from death
106 double _CurrentDeathXP
;
107 /// XP to gain to recover from death malus
108 double _DeathXPToGain
;
109 /// Last time at which bonus was given
110 uint32 _BonusUpdateTime
;
111 /// factor of xp used for death penalty
112 float _DeathPenaltyFactor
;
115 class CDeathPenaltiesTimerEvent
:public CTimerEvent
118 CDeathPenaltiesTimerEvent(CCharacter
*parent
);
119 void timerCallback(CTimer
*owner
);
124 #endif // RY_DEATH_PENALTIES_H
126 /* End of death_penalties.h */