AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::XP Namespace Reference

Functions

uint8 GetGrayLevel (uint8 pl_level)
 
XPColorChar GetColorCode (uint8 pl_level, uint8 mob_level)
 
uint8 GetZeroDifference (uint8 pl_level)
 
uint32 BaseGain (uint8 pl_level, uint8 mob_level, ContentLevels content)
 
uint32 Gain (Player *player, Unit *unit, bool isBattleGround=false)
 
float xp_in_group_rate (uint32 count, bool isRaid)
 

Function Documentation

◆ BaseGain()

uint32 Acore::XP::BaseGain ( uint8  pl_level,
uint8  mob_level,
ContentLevels  content 
)
26{
27 uint32 baseGain;
28 uint32 nBaseExp;
29
30 switch (content)
31 {
32 case CONTENT_1_60:
33 nBaseExp = 45;
34 break;
35 case CONTENT_61_70:
36 nBaseExp = 235;
37 break;
38 case CONTENT_71_80:
39 nBaseExp = 580;
40 break;
41 default:
42 LOG_ERROR("misc", "BaseGain: Unsupported content level {}", content);
43 nBaseExp = 45;
44 break;
45 }
46
47 if (mob_level >= pl_level)
48 {
49 uint8 nLevelDiff = mob_level - pl_level;
50 if (nLevelDiff > 4)
51 nLevelDiff = 4;
52
53 baseGain = ((pl_level * 5 + nBaseExp) * (20 + nLevelDiff) / 10 + 1) / 2;
54 }
55 else
56 {
57 uint8 gray_level = GetGrayLevel(pl_level);
58 if (mob_level > gray_level)
59 {
60 uint8 ZD = GetZeroDifference(pl_level);
61 baseGain = (pl_level * 5 + nBaseExp) * (ZD + mob_level - pl_level) / ZD;
62 }
63 else
64 baseGain = 0;
65 }
66
67 //sScriptMgr->OnBaseGainCalculation(baseGain, pl_level, mob_level, content); // pussywizard: optimization
68 return baseGain;
69}
std::uint8_t uint8
Definition: Define.h:110
std::uint32_t uint32
Definition: Define.h:108
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
@ CONTENT_61_70
Definition: DBCStores.h:43
@ CONTENT_71_80
Definition: DBCStores.h:44
@ CONTENT_1_60
Definition: DBCStores.h:42

References CONTENT_1_60, CONTENT_61_70, CONTENT_71_80, GetGrayLevel(), GetZeroDifference(), and LOG_ERROR.

Referenced by Gain(), and TEST().

◆ Gain()

uint32 Acore::XP::Gain ( Player player,
Unit unit,
bool  isBattleGround = false 
)
72{
73 Creature* creature = unit->ToCreature();
74 uint32 gain = 0;
75
76 if (!creature || (!creature->IsTotem() && !creature->IsPet() && !creature->IsCritter() &&
78 {
79 float xpMod = 1.0f;
80
81 gain = BaseGain(player->GetLevel(), unit->GetLevel(), GetContentLevelsForMapAndZone(unit->GetMapId(), unit->GetZoneId()));
82
83 if (gain && creature)
84 {
85 if (creature->isElite())
86 {
87 // Elites in instances have a 2.75x XP bonus instead of the regular 2x world bonus.
88 if (unit->GetMap() && unit->GetMap()->IsDungeon())
89 xpMod *= 2.75f;
90 else
91 xpMod *= 2.0f;
92 }
93
94 xpMod *= creature->GetCreatureTemplate()->ModExperience;
95 }
96
97 if (isBattleGround)
98 {
99 switch (player->GetMapId())
100 {
102 xpMod *= sWorld->getRate(RATE_XP_BG_KILL_AV);
103 break;
105 xpMod *= sWorld->getRate(RATE_XP_BG_KILL_WSG);
106 break;
108 xpMod *= sWorld->getRate(RATE_XP_BG_KILL_AB);
109 break;
111 xpMod *= sWorld->getRate(RATE_XP_BG_KILL_EOTS);
112 break;
114 xpMod *= sWorld->getRate(RATE_XP_BG_KILL_SOTA);
115 break;
117 xpMod *= sWorld->getRate(RATE_XP_BG_KILL_IC);
118 break;
119 }
120 }
121 else
122 {
123 xpMod *= sWorld->getRate(RATE_XP_KILL);
124 }
125
126 // if players dealt less than 50% of the damage and were credited anyway (due to CREATURE_FLAG_EXTRA_NO_PLAYER_DAMAGE_REQ), scale XP gained appropriately (linear scaling)
127 if (creature && creature->GetPlayerDamageReq())
128 {
129 xpMod *= 1.0f - 2.0f * creature->GetPlayerDamageReq() / creature->GetMaxHealth();
130 }
131
132 gain = uint32(gain * xpMod);
133 }
134
135 //sScriptMgr->OnGainCalculation(gain, player, u); // pussywizard: optimization
136 return gain;
137}
@ MAP_BG_ARATHI_BASIN
Definition: Battleground.h:61
@ MAP_BG_ISLE_OF_CONQUEST
Definition: Battleground.h:64
@ MAP_BG_ALTERAC_VALLEY
Definition: Battleground.h:59
@ MAP_BG_EYE_OF_THE_STORM
Definition: Battleground.h:62
@ MAP_BG_WARSONG_GULCH
Definition: Battleground.h:60
@ MAP_BG_STRAND_OF_THE_ANCIENTS
Definition: Battleground.h:63
ContentLevels GetContentLevelsForMapAndZone(uint32 mapid, uint32 zoneId)
Definition: DBCStores.cpp:710
@ CREATURE_FLAG_EXTRA_NO_XP
Definition: CreatureData.h:55
@ RATE_XP_KILL
Definition: IWorld.h:464
@ RATE_XP_BG_KILL_SOTA
Definition: IWorld.h:469
@ RATE_XP_BG_KILL_WSG
Definition: IWorld.h:466
@ RATE_XP_BG_KILL_AB
Definition: IWorld.h:467
@ RATE_XP_BG_KILL_EOTS
Definition: IWorld.h:468
@ RATE_XP_BG_KILL_IC
Definition: IWorld.h:470
@ RATE_XP_BG_KILL_AV
Definition: IWorld.h:465
#define sWorld
Definition: World.h:447
uint32 BaseGain(uint8 pl_level, uint8 mob_level, ContentLevels content)
Definition: Formulas.cpp:25
Definition: Creature.h:46
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:199
uint32 GetPlayerDamageReq() const
Definition: Creature.cpp:3723
bool isElite() const
Definition: Creature.h:107
float ModExperience
Definition: CreatureData.h:233
uint32 flags_extra
Definition: CreatureData.h:239
Creature * ToCreature()
Definition: Object.h:197
Map * GetMap() const
Definition: Object.h:517
uint32 GetZoneId() const
Definition: Object.cpp:3100
uint32 GetMapId() const
Definition: Position.h:276
bool IsPet() const
Definition: Unit.h:1425
uint32 GetMaxHealth() const
Definition: Unit.h:1455
bool IsCritter() const
Definition: Unit.h:1688
bool IsTotem() const
Definition: Unit.h:1427
uint8 GetLevel() const
Definition: Unit.h:1432
bool IsDungeon() const
Definition: Map.h:448

References BaseGain(), CREATURE_FLAG_EXTRA_NO_XP, CreatureTemplate::flags_extra, GetContentLevelsForMapAndZone(), Creature::GetCreatureTemplate(), Unit::GetLevel(), WorldObject::GetMap(), WorldLocation::GetMapId(), Unit::GetMaxHealth(), Creature::GetPlayerDamageReq(), WorldObject::GetZoneId(), Unit::IsCritter(), Map::IsDungeon(), Creature::isElite(), Unit::IsPet(), Unit::IsTotem(), MAP_BG_ALTERAC_VALLEY, MAP_BG_ARATHI_BASIN, MAP_BG_EYE_OF_THE_STORM, MAP_BG_ISLE_OF_CONQUEST, MAP_BG_STRAND_OF_THE_ANCIENTS, MAP_BG_WARSONG_GULCH, CreatureTemplate::ModExperience, RATE_XP_BG_KILL_AB, RATE_XP_BG_KILL_AV, RATE_XP_BG_KILL_EOTS, RATE_XP_BG_KILL_IC, RATE_XP_BG_KILL_SOTA, RATE_XP_BG_KILL_WSG, RATE_XP_KILL, sWorld, and Object::ToCreature().

Referenced by KillRewarder::_InitXP().

◆ GetColorCode()

XPColorChar Acore::XP::GetColorCode ( uint8  pl_level,
uint8  mob_level 
)
inline
64 {
65 XPColorChar color;
66
67 if (mob_level >= pl_level + 5)
68 color = XP_RED;
69 else if (mob_level >= pl_level + 3)
70 color = XP_ORANGE;
71 else if (mob_level >= pl_level - 2)
72 color = XP_YELLOW;
73 else if (mob_level > GetGrayLevel(pl_level))
74 color = XP_GREEN;
75 else
76 color = XP_GRAY;
77
78 //sScriptMgr->OnColorCodeCalculation(color, pl_level, mob_level); // pussywizard: optimization
79 return color;
80 }
XPColorChar
Definition: SharedDefines.h:3577
@ XP_GREEN
Definition: SharedDefines.h:3581
@ XP_GRAY
Definition: SharedDefines.h:3582
@ XP_YELLOW
Definition: SharedDefines.h:3580
@ XP_RED
Definition: SharedDefines.h:3578
@ XP_ORANGE
Definition: SharedDefines.h:3579
uint8 GetGrayLevel(uint8 pl_level)
Definition: Formulas.h:46

References GetGrayLevel(), XP_GRAY, XP_GREEN, XP_ORANGE, XP_RED, and XP_YELLOW.

Referenced by TEST().

◆ GetGrayLevel()

uint8 Acore::XP::GetGrayLevel ( uint8  pl_level)
inline
47 {
48 uint8 level;
49
50 if (pl_level <= 5)
51 level = 0;
52 else if (pl_level <= 39)
53 level = pl_level - 5 - pl_level / 10;
54 else if (pl_level <= 59)
55 level = pl_level - 1 - pl_level / 5;
56 else
57 level = pl_level - 9;
58
59 //sScriptMgr->OnGrayLevelCalculation(level, pl_level); // pussywizard: optimization
60 return level;
61 }

Referenced by KillRewarder::_InitGroupData(), BaseGain(), Player::CalculateReputationGain(), GetColorCode(), Player::isHonorOrXPTarget(), Player::RewardHonor(), TEST(), and Player::UpdateCombatSkills().

◆ GetZeroDifference()

uint8 Acore::XP::GetZeroDifference ( uint8  pl_level)
inline
83 {
84 uint8 diff;
85
86 if (pl_level < 8)
87 diff = 5;
88 else if (pl_level < 10)
89 diff = 6;
90 else if (pl_level < 12)
91 diff = 7;
92 else if (pl_level < 16)
93 diff = 8;
94 else if (pl_level < 20)
95 diff = 9;
96 else if (pl_level < 30)
97 diff = 11;
98 else if (pl_level < 40)
99 diff = 12;
100 else if (pl_level < 45)
101 diff = 13;
102 else if (pl_level < 50)
103 diff = 14;
104 else if (pl_level < 55)
105 diff = 15;
106 else if (pl_level < 60)
107 diff = 16;
108 else
109 diff = 17;
110
111 //sScriptMgr->OnZeroDifferenceCalculation(diff, pl_level); // pussywizard: optimization
112 return diff;
113 }

Referenced by BaseGain(), and TEST().

◆ xp_in_group_rate()

float Acore::XP::xp_in_group_rate ( uint32  count,
bool  isRaid 
)
inline
120 {
121 float rate;
122
123 if (isRaid)
124 {
125 // FIXME: Must apply decrease modifiers depending on raid size.
126 rate = 1.0f;
127 }
128 else
129 {
130 switch (count)
131 {
132 case 0:
133 case 1:
134 case 2:
135 rate = 1.0f;
136 break;
137 case 3:
138 rate = 1.166f;
139 break;
140 case 4:
141 rate = 1.3f;
142 break;
143 case 5:
144 default:
145 rate = 1.4f;
146 }
147 }
148
149 //sScriptMgr->OnGroupRateCalculation(rate, count, isRaid); // pussywizard: optimization
150 return rate;
151 }

Referenced by KillRewarder::_RewardGroup().