Skip to content

Commit

Permalink
Generalize XP rate mod of previous commit and unify GetXPModRate call
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberium committed Feb 1, 2024
1 parent 7b12c53 commit eff384a
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 60 deletions.
2 changes: 1 addition & 1 deletion src/game/Entities/Pet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ void Pet::GivePetXP(uint32 xp)
if (level < maxlevel)
{

xp *= sWorld.getConfig(CONFIG_FLOAT_RATE_PET_XP_KILL) * GetMap()->GetPetKillXPMod();
xp *= GetMap()->GetXPModRate(RateModType::PETKILL);

uint32 nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP);
uint32 curXP = GetUInt32Value(UNIT_FIELD_PETEXPERIENCE);
Expand Down
8 changes: 4 additions & 4 deletions src/game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6900,7 +6900,7 @@ void Player::CheckAreaExploreAndOutdoor()
uint32 XP;
if (diff < -5)
{
XP = uint32(sObjectMgr.GetBaseXP(GetLevel() + 5) * sWorld.getConfig(CONFIG_FLOAT_RATE_XP_EXPLORE) * GetMap()->GetExploreXPMod());
XP = uint32(sObjectMgr.GetBaseXP(GetLevel() + 5) * GetMap()->GetXPModRate(RateModType::EXPLORE));
}
else if (diff > 5)
{
Expand All @@ -6910,11 +6910,11 @@ void Player::CheckAreaExploreAndOutdoor()
else if (exploration_percent < 0)
exploration_percent = 0;

XP = uint32(sObjectMgr.GetBaseXP(p->area_level) * exploration_percent / 100 * sWorld.getConfig(CONFIG_FLOAT_RATE_XP_EXPLORE) * GetMap()->GetExploreXPMod());
XP = uint32(sObjectMgr.GetBaseXP(p->area_level) * exploration_percent / 100 * GetMap()->GetXPModRate(RateModType::EXPLORE));
}
else
{
XP = uint32(sObjectMgr.GetBaseXP(p->area_level) * sWorld.getConfig(CONFIG_FLOAT_RATE_XP_EXPLORE) * GetMap()->GetExploreXPMod());
XP = uint32(sObjectMgr.GetBaseXP(p->area_level) * GetMap()->GetXPModRate(RateModType::EXPLORE));
}

GiveXP(XP, nullptr);
Expand Down Expand Up @@ -14496,7 +14496,7 @@ void Player::RewardQuest(Quest const* pQuest, uint32 reward, Object* questGiver,
bool rewarded = q_status.m_rewarded && !pQuest->IsDungeonFinderQuest();

// Used for client inform but rewarded only in case not max level
uint32 xp = uint32(pQuest->GetXPReward(this) * sWorld.getConfig(CONFIG_FLOAT_RATE_XP_QUEST) * GetMap()->GetQuestXPMod());
uint32 xp = uint32(pQuest->GetXPReward(this) * GetMap()->GetXPModRate(RateModType::QUEST));

if (GetLevel() < GetMaxAttainableLevel())
{
Expand Down
128 changes: 80 additions & 48 deletions src/game/Maps/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1265,60 +1265,92 @@ void Map::SetNewDifficultyCooldown(TimePoint const& newCooldown)
m_dynamicDifficultyCooldown = newCooldown;
}

float Map::GetPetKillXPMod() const
// This is not retail like
// Get xp rate for given type
float Map::GetXPModRate(RateModType type) const
{
switch (GetExpansion())
float expMod = 1.0f;
switch (type)
{
default:
case 0:
return sWorld.getConfig(CONFIG_FLOAT_RATE_PET_XP_KILL_VANILLA);
case 1:
return sWorld.getConfig(CONFIG_FLOAT_RATE_PET_XP_KILL_BC);
case 2:
return sWorld.getConfig(CONFIG_FLOAT_RATE_PET_XP_KILL_WOTLK);
}
}
case RateModType::QUEST:
{
switch (GetExpansion())
{
case 0:
expMod = sWorld.getConfig(CONFIG_FLOAT_RATE_XP_QUEST_VANILLA);
break;
case 1:
expMod = sWorld.getConfig(CONFIG_FLOAT_RATE_XP_QUEST_BC);
break;

float Map::GetQuestXPMod() const
{
switch (GetExpansion())
{
default:
case 0:
return sWorld.getConfig(CONFIG_FLOAT_RATE_XP_QUEST_VANILLA);
case 1:
return sWorld.getConfig(CONFIG_FLOAT_RATE_XP_QUEST_BC);
case 2:
return sWorld.getConfig(CONFIG_FLOAT_RATE_XP_QUEST_WOTLK);
}
}
default:
expMod = sWorld.getConfig(CONFIG_FLOAT_RATE_XP_QUEST_WOTLK);
break;
}
expMod *= sWorld.getConfig(CONFIG_FLOAT_RATE_XP_QUEST);
break;

float Map::GetKillXPMod() const
{
switch (GetExpansion())
{
default:
case 0:
return sWorld.getConfig(CONFIG_FLOAT_RATE_XP_KILL_VANILLA);
case 1:
return sWorld.getConfig(CONFIG_FLOAT_RATE_XP_KILL_BC);
case 2:
return sWorld.getConfig(CONFIG_FLOAT_RATE_XP_KILL_WOTLK);
}
}
}

case RateModType::KILL:
{
switch (GetExpansion())
{
case 0:
expMod = sWorld.getConfig(CONFIG_FLOAT_RATE_XP_KILL_VANILLA);
break;
case 1:
expMod = sWorld.getConfig(CONFIG_FLOAT_RATE_XP_KILL_BC);
break;

float Map::GetExploreXPMod() const
{
switch (GetExpansion())
{
default:
case 0:
return sWorld.getConfig(CONFIG_FLOAT_RATE_XP_EXPLORE_VANILLA);
case 1:
return sWorld.getConfig(CONFIG_FLOAT_RATE_XP_EXPLORE_BC);
case 2:
return sWorld.getConfig(CONFIG_FLOAT_RATE_XP_EXPLORE_WOTLK);
default:
expMod = sWorld.getConfig(CONFIG_FLOAT_RATE_XP_KILL_WOTLK);
break;
}
expMod *= sWorld.getConfig(CONFIG_FLOAT_RATE_XP_KILL);
break;
}

case RateModType::EXPLORE:
{
switch (GetExpansion())
{
case 0:
expMod = sWorld.getConfig(CONFIG_FLOAT_RATE_XP_EXPLORE_VANILLA);
break;
case 1:
expMod = sWorld.getConfig(CONFIG_FLOAT_RATE_XP_EXPLORE_BC);
break;

default:
expMod = sWorld.getConfig(CONFIG_FLOAT_RATE_XP_EXPLORE_WOTLK);
break;
}
expMod *= sWorld.getConfig(CONFIG_FLOAT_RATE_XP_EXPLORE);
break;
}

case RateModType::PETKILL:
{
switch (GetExpansion())
{
case 0:
expMod = sWorld.getConfig(CONFIG_FLOAT_RATE_PET_XP_KILL_VANILLA);
break;
case 1:
expMod = sWorld.getConfig(CONFIG_FLOAT_RATE_PET_XP_KILL_BC);
break;

default:
expMod = sWorld.getConfig(CONFIG_FLOAT_RATE_PET_XP_KILL_WOTLK);
break;
}
expMod *= sWorld.getConfig(CONFIG_FLOAT_RATE_PET_XP_KILL);
break;
}
}

return expMod;
}

uint32 Map::GetMaxPlayers() const
Expand Down
17 changes: 12 additions & 5 deletions src/game/Maps/Map.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ enum LevelRequirementVsMode
LEVELREQUIREMENT_HEROIC = 70
};

enum class RateModType
{
KILL = 0,
QUEST = 1,
EXPLORE = 2,
PETKILL = 3,
MAX = 4
};

struct ZoneDynamicInfo
{
ZoneDynamicInfo() : musicId(0), weatherId(0), weatherGrade(0.0f),
Expand Down Expand Up @@ -221,13 +230,11 @@ class Map : public GridRefManager<NGridType>
void ChangeMapDifficulty(Difficulty difficulty);
void SetNewDifficultyCooldown(TimePoint const& newCooldown);
TimePoint const& GetNewDifficultyCooldown() const { return m_dynamicDifficultyCooldown; }
float GetPetKillXPMod() const;
float GetQuestXPMod() const;
float GetKillXPMod() const;
float GetExploreXPMod() const;

MapEntry const* GetEntry() const { return i_mapEntry; }
uint32 GetExpansion() const { return (i_mapEntry) ? i_mapEntry->Expansion() : 0u; }
float GetXPModRate(RateModType type) const;

MapEntry const* GetEntry() const { return i_mapEntry; }
bool Instanceable() const { return i_mapEntry && i_mapEntry->Instanceable(); }
bool IsDungeon() const { return i_mapEntry && i_mapEntry->IsDungeon(); }
bool IsRaid() const { return i_mapEntry && i_mapEntry->IsRaid(); }
Expand Down
2 changes: 1 addition & 1 deletion src/game/Tools/Formulas.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ namespace MaNGOS

xp_gain = target->GetModifierXpBasedOnDamageReceived(xp_gain);

return (uint32)(std::nearbyint(xp_gain * sWorld.getConfig(CONFIG_FLOAT_RATE_XP_KILL) * target->GetMap()->GetKillXPMod()));
return (uint32)(std::nearbyint(xp_gain * target->GetMap()->GetXPModRate(RateModType::KILL)));
}

inline float xp_in_group_rate(uint32 count, bool /*isRaid*/)
Expand Down
2 changes: 1 addition & 1 deletion src/mangosd/mangosd.conf.dist.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#####################################

[MangosdConf]
ConfVersion=2022021301
ConfVersion=2024020101

###################################################################################################################
# CONNECTIONS AND DIRECTORIES
Expand Down

0 comments on commit eff384a

Please sign in to comment.