Skip to content

Commit

Permalink
NPCBots: Implement Blizzlike XP reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
trickerer committed Nov 26, 2024
1 parent a2dcc1e commit 46854ca
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/server/game/AI/NpcBots/botmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ uint32 _targetBGPlayersPerTeamCount_SA;
uint32 _targetBGPlayersPerTeamCount_IC;
bool _enableNpcBots;
bool _logToDB;
bool _xpReductionBlizzlikeEnable;
bool _xpReductionBlizzlikeGroupOnly;
bool _enableNpcBotsDungeons;
bool _enableNpcBotsRaids;
bool _enableNpcBotsBGs;
Expand Down Expand Up @@ -331,6 +333,8 @@ void BotMgr::LoadConfig(bool reload)
_basefollowdist = sConfigMgr->GetIntDefault("NpcBot.BaseFollowDistance", 30);
_xpReductionAmount = sConfigMgr->GetIntDefault("NpcBot.XpReduction.Amount", 0);
_xpReductionStartingNumber = sConfigMgr->GetIntDefault("NpcBot.XpReduction.StartingNumber", 2);
_xpReductionBlizzlikeEnable = sConfigMgr->GetBoolDefault("NpcBot.XpReduction.Blizzlike.Enable", true);
_xpReductionBlizzlikeGroupOnly = sConfigMgr->GetBoolDefault("NpcBot.XpReduction.Blizzlike.GroupOnly", false);
_mountLevel60 = sConfigMgr->GetIntDefault("NpcBot.MountLevel.60", 20);
_mountLevel100 = sConfigMgr->GetIntDefault("NpcBot.MountLevel.100", 40);
_healTargetIconFlags = sConfigMgr->GetIntDefault("NpcBot.HealTargetIconMask", 0);
Expand Down Expand Up @@ -1104,6 +1108,14 @@ uint8 BotMgr::GetNpcBotXpReductionStartingNumber()
{
return _xpReductionStartingNumber;
}
bool BotMgr::GetNpcBotXpReductionBlizzlikeEnabled()
{
return _xpReductionBlizzlikeEnable;
}
bool BotMgr::GetNpcBotXpReductionBlizzlikeGroupOnly()
{
return _xpReductionBlizzlikeGroupOnly;
}

uint8 BotMgr::GetNpcBotMountLevel60()
{
Expand Down
2 changes: 2 additions & 0 deletions src/server/game/AI/NpcBots/botmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ class TC_GAME_API BotMgr
static uint8 GetMaxNpcBots(uint8 level);
static uint8 GetNpcBotXpReduction();
static uint8 GetNpcBotXpReductionStartingNumber();
static bool GetNpcBotXpReductionBlizzlikeEnabled();
static bool GetNpcBotXpReductionBlizzlikeGroupOnly();
static uint8 GetNpcBotMountLevel60();
static uint8 GetNpcBotMountLevel100();
static int32 GetBotInfoPacketsLimit();
Expand Down
28 changes: 28 additions & 0 deletions src/server/game/Entities/Player/KillRewarder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,34 @@ inline void KillRewarder::_InitGroupData()
if (_victim->GetLevel() > grayLevel && (!_maxNotGrayMember || _maxNotGrayMember->GetLevel() < lvl))
_maxNotGrayMember = member;
}

//npcbot
if (BotMgr::GetNpcBotXpReductionBlizzlikeEnabled())
{
for (GroupReference* itr = _group->GetFirstMember(); itr != nullptr; itr = itr->next())
{
Player* member = itr->GetSource();
if (!member || !member->IsInMap(_victim) || !member->HaveBot())
continue;

BotMap const* botMap = member->GetBotMgr()->GetBotMap();
for (auto const& kv : *botMap)
{
Creature const* bot = kv.second;
if (bot && bot->IsAlive() && bot->IsInMap(_victim) && (_group->IsMember(kv.first) || !BotMgr::GetNpcBotXpReductionBlizzlikeGroupOnly()) &&
(member->GetMap()->IsDungeon() || _victim->GetDistance(bot) <= sWorld->getFloatConfig(CONFIG_GROUP_XP_DISTANCE)))
{
const uint8 lvl = bot->GetLevel();
++_count;
_sumLevel += lvl;
if (_maxLevel < lvl)
_maxLevel = lvl;
}
}
}
}
//end npcbot

// 2.5. _isFullXP - flag identifying that for all group members victim is not gray,
// so 100% XP will be rewarded (50% otherwise).
_isFullXP = _maxNotGrayMember && (_maxLevel == _maxNotGrayMember->GetLevel());
Expand Down
15 changes: 12 additions & 3 deletions src/server/worldserver/worldserver.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4213,14 +4213,23 @@ NpcBot.BaseFollowDistance = 30
#
# NpcBot.XpReduction.Amount
# NpcBot.XpReduction.StartingNumber
# NpcBot.XpReduction.Blizzlike.Enable
# NpcBot.XpReduction.Blizzlike.GroupOnly
# Description: XP percent penalty for each bot used starting with <StartingNumber>.
# Example: 3 bots, reduction is 20, start is 2: ((3-(2-1))*20) = 40%, 60% exp gained.
# <Blizzlike> enables group size based XP reduction counting either any bots
# or bots in group only, combines multiplicatively
# Example: Group of 4, 3 bots, reduction is 20, start is 2, blizzlike enabled:
# (100 - ((3-(2-1))*20)) * 1.3 / 4 = 19.5% exp gained.
# Note: Maximum overall xp reduction is 90%.
# Default: 0 - (NpcBot.XpReduction.Amount)
# 2 - (NpcBot.XpReduction.StartingNumber)
# 1 - (NpcBot.XpReduction.Blizzlike.Enable)
# 0 - (NpcBot.XpReduction.Blizzlike.GroupOnly)

NpcBot.XpReduction.Amount = 0
NpcBot.XpReduction.StartingNumber = 2
NpcBot.XpReduction.Amount = 0
NpcBot.XpReduction.StartingNumber = 2
NpcBot.XpReduction.Blizzlike.Enable = 1
NpcBot.XpReduction.Blizzlike.GroupOnly = 0

#
# NpcBot.MountLevel.60
Expand Down

0 comments on commit 46854ca

Please sign in to comment.