2 * Copyright (C) 2005-2010 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 float hk_honor_at_level(uint32 level
, uint32 count
=1)
30 return (float)ceil(count
*(-0.53177f
+ 0.59357f
* exp((level
+23.54042f
) / 26.07859f
)));
35 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
)
84 case CONTENT_1_60
: nBaseExp
= 45; break;
85 case CONTENT_61_70
: nBaseExp
= 235; break;
86 case CONTENT_71_80
: nBaseExp
= 580; break;
88 sLog
.outError("BaseGain: Unsupported content level %u",content
);
92 if( mob_level
>= pl_level
)
94 uint32 nLevelDiff
= mob_level
- pl_level
;
97 return ((pl_level
*5 + nBaseExp
) * (20 + nLevelDiff
)/10 + 1)/2;
101 uint32 gray_level
= GetGrayLevel(pl_level
);
102 if( mob_level
> gray_level
)
104 uint32 ZD
= GetZeroDifference(pl_level
);
105 return (pl_level
*5 + nBaseExp
) * (ZD
+ mob_level
- pl_level
)/ZD
;
111 inline uint32
Gain(Player
*pl
, Unit
*u
)
113 if(u
->GetTypeId()==TYPEID_UNIT
&& (
114 ((Creature
*)u
)->isTotem() || ((Creature
*)u
)->isPet() ||
115 (((Creature
*)u
)->GetCreatureInfo()->flags_extra
& CREATURE_FLAG_EXTRA_NO_XP_AT_KILL
) ))
118 uint32 xp_gain
= BaseGain(pl
->getLevel(), u
->getLevel(), GetContentLevelsForMapAndZone(pl
->GetMapId(),pl
->GetZoneId()));
122 if(u
->GetTypeId()==TYPEID_UNIT
&& ((Creature
*)u
)->isElite())
125 return (uint32
)(xp_gain
*sWorld
.getConfig(CONFIG_FLOAT_RATE_XP_KILL
));
128 inline float xp_in_group_rate(uint32 count
, bool isRaid
)
132 // FIX ME: must apply decrease modifiers dependent from raid size