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:159
@ 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:463
@ RATE_XP_BG_KILL_SOTA
Definition: IWorld.h:468
@ RATE_XP_BG_KILL_WSG
Definition: IWorld.h:465
@ RATE_XP_BG_KILL_AB
Definition: IWorld.h:466
@ RATE_XP_BG_KILL_EOTS
Definition: IWorld.h:467
@ RATE_XP_BG_KILL_IC
Definition: IWorld.h:469
@ RATE_XP_BG_KILL_AV
Definition: IWorld.h:464
#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:197
uint32 GetPlayerDamageReq() const
Definition: Creature.cpp:3706
bool isElite() const
Definition: Creature.h:106
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:1453
bool IsCritter() const
Definition: Unit.h:1686
bool IsTotem() const
Definition: Unit.h:1427
uint8 GetLevel() const
Definition: Unit.h:1432
bool IsDungeon() const
Definition: Map.h:447

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
59 {
60 XPColorChar color;
61
62 if (mob_level >= pl_level + 5)
63 color = XP_RED;
64 else if (mob_level >= pl_level + 3)
65 color = XP_ORANGE;
66 else if (mob_level >= pl_level - 2)
67 color = XP_YELLOW;
68 else if (mob_level > GetGrayLevel(pl_level))
69 color = XP_GREEN;
70 else
71 color = XP_GRAY;
72
73 //sScriptMgr->OnColorCodeCalculation(color, pl_level, mob_level); // pussywizard: optimization
74 return color;
75 }
XPColorChar
Definition: SharedDefines.h:3549
@ XP_GREEN
Definition: SharedDefines.h:3553
@ XP_GRAY
Definition: SharedDefines.h:3554
@ XP_YELLOW
Definition: SharedDefines.h:3552
@ XP_RED
Definition: SharedDefines.h:3550
@ XP_ORANGE
Definition: SharedDefines.h:3551
uint8 GetGrayLevel(uint8 pl_level)
Definition: Formulas.h:41

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
42 {
43 uint8 level;
44
45 if (pl_level <= 5)
46 level = 0;
47 else if (pl_level <= 39)
48 level = pl_level - 5 - pl_level / 10;
49 else if (pl_level <= 59)
50 level = pl_level - 1 - pl_level / 5;
51 else
52 level = pl_level - 9;
53
54 //sScriptMgr->OnGrayLevelCalculation(level, pl_level); // pussywizard: optimization
55 return level;
56 }

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
78 {
79 uint8 diff;
80
81 if (pl_level < 8)
82 diff = 5;
83 else if (pl_level < 10)
84 diff = 6;
85 else if (pl_level < 12)
86 diff = 7;
87 else if (pl_level < 16)
88 diff = 8;
89 else if (pl_level < 20)
90 diff = 9;
91 else if (pl_level < 30)
92 diff = 11;
93 else if (pl_level < 40)
94 diff = 12;
95 else if (pl_level < 45)
96 diff = 13;
97 else if (pl_level < 50)
98 diff = 14;
99 else if (pl_level < 55)
100 diff = 15;
101 else if (pl_level < 60)
102 diff = 16;
103 else
104 diff = 17;
105
106 //sScriptMgr->OnZeroDifferenceCalculation(diff, pl_level); // pussywizard: optimization
107 return diff;
108 }

Referenced by BaseGain(), and TEST().

◆ xp_in_group_rate()

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

Referenced by KillRewarder::_RewardGroup().