2 * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (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 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
19 #ifndef MANGOS_FORMULAS_H
20 #define MANGOS_FORMULAS_H
28 inline uint32
hk_honor_at_level(uint32 level
, uint32 count
=1)
30 return ceil(count
*(-0.53177f
+ 0.59357f
* exp((level
+23.54042f
) / 26.07859f
)));
35 typedef enum XPColorChar
{ RED
, ORANGE
, YELLOW
, GREEN
, GRAY
};
37 inline uint32
GetGrayLevel(uint32 pl_level
)
41 else if( pl_level
<= 39 )
42 return pl_level
- 5 - pl_level
/10;
43 else if( pl_level
<= 59 )
44 return pl_level
- 1 - pl_level
/5;
49 inline XPColorChar
GetColorCode(uint32 pl_level
, uint32 mob_level
)
51 if( mob_level
>= pl_level
+ 5 )
53 else if( mob_level
>= pl_level
+ 3 )
55 else if( mob_level
>= pl_level
- 2 )
57 else if( mob_level
> GetGrayLevel(pl_level
) )
63 inline uint32
GetZeroDifference(uint32 pl_level
)
65 if( pl_level
< 8 ) return 5;
66 if( pl_level
< 10 ) return 6;
67 if( pl_level
< 12 ) return 7;
68 if( pl_level
< 16 ) return 8;
69 if( pl_level
< 20 ) return 9;
70 if( pl_level
< 30 ) return 11;
71 if( pl_level
< 40 ) return 12;
72 if( pl_level
< 45 ) return 13;
73 if( pl_level
< 50 ) return 14;
74 if( pl_level
< 55 ) return 15;
75 if( pl_level
< 60 ) return 16;
79 inline uint32
BaseGain(uint32 pl_level
, uint32 mob_level
, ContentLevels content
)
81 //TODO: need modifier for CONTENT_71_80 different from CONTENT_61_70?
82 const uint32 nBaseExp
= content
== CONTENT_1_60
? 45 : 235;
83 if( mob_level
>= pl_level
)
85 uint32 nLevelDiff
= mob_level
- pl_level
;
88 return ((pl_level
*5 + nBaseExp
) * (20 + nLevelDiff
)/10 + 1)/2;
92 uint32 gray_level
= GetGrayLevel(pl_level
);
93 if( mob_level
> gray_level
)
95 uint32 ZD
= GetZeroDifference(pl_level
);
96 return (pl_level
*5 + nBaseExp
) * (ZD
+ mob_level
- pl_level
)/ZD
;
102 inline uint32
Gain(Player
*pl
, Unit
*u
)
104 if(u
->GetTypeId()==TYPEID_UNIT
&& (
105 ((Creature
*)u
)->isTotem() || ((Creature
*)u
)->isPet() ||
106 (((Creature
*)u
)->GetCreatureInfo()->flags_extra
& CREATURE_FLAG_EXTRA_NO_XP_AT_KILL
) ))
109 uint32 xp_gain
= BaseGain(pl
->getLevel(), u
->getLevel(), GetContentLevelsForMapAndZone(pl
->GetMapId(),pl
->GetZoneId()));
113 if(u
->GetTypeId()==TYPEID_UNIT
&& ((Creature
*)u
)->isElite())
116 return (uint32
)(xp_gain
*sWorld
.getRate(RATE_XP_KILL
));
119 inline uint32
xp_Diff(uint32 lvl
)
133 inline uint32
mxp(uint32 lvl
)
137 return (45 + (5*lvl
));
141 return (235 + (5*lvl
));
145 inline uint32
xp_to_level(uint32 lvl
)
150 xp
= (8*lvl
+ xp_Diff(lvl
)) * mxp(lvl
);
154 xp
= (155 + mxp(lvl
) * (1344 - 70 - ((69 - lvl
) * (7 + (69 - lvl
) * 8 - 1)/2)));
158 xp
= (155 + mxp(lvl
) * (1344 - ((69-lvl
) * (7 + (69 - lvl
) * 8 - 1)/2)));
161 // level higher than 70 is not supported
162 xp
= (uint32
)(779700 * (pow(sWorld
.getRate(RATE_XP_PAST_70
), (int32
)lvl
- 69)));
163 return ((xp
< 0x7fffffff) ? xp
: 0x7fffffff);
166 // The XP to Level is always rounded to the nearest 100 points (50 rounded to high).
167 xp
= ((xp
+ 50) / 100) * 100; // use additional () for prevent free association operations in C++
169 if ((lvl
> 10) && (lvl
< 60)) // compute discount added in 2.3.x
171 uint32 discount
= (lvl
< 28) ? (lvl
- 10) : 18;
172 xp
= (xp
* (100 - discount
)) / 100; // apply discount
173 xp
= (xp
/ 100) * 100; // floor to hundreds
179 inline float xp_in_group_rate(uint32 count
, bool isRaid
)
183 // FIX ME: must apply decrease modifiers dependent from raid size