diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index 35b75442..5d445cab 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -369,9 +369,9 @@ AiPlayerbot.AggroDistance = 22 # # -# Set kill XP rate for bots (default: 1) -# Server XP Rate * AiPlayerbot.KillXPRate -AiPlayerbot.KillXPRate = 1 +# Set XP rate for bots (default: 1.0) +# Server XP Rate * AiPlayerbot.PlayerbotsXPRate +AiPlayerbot.PlayerbotsXPRate = 1.0 # Health/Mana levels AiPlayerbot.CriticalHealth = 25 diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index 0ff76fb6..2eb0bcfa 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -481,7 +481,7 @@ bool PlayerbotAIConfig::Initialize() autoGearQualityLimit = sConfigMgr->GetOption("AiPlayerbot.AutoGearQualityLimit", 3); autoGearScoreLimit = sConfigMgr->GetOption("AiPlayerbot.AutoGearScoreLimit", 0); - playerbotsXPrate = sConfigMgr->GetOption("AiPlayerbot.KillXPRate", 1); + playerbotsXPrate = sConfigMgr->GetOption("AiPlayerbot.PlayerbotsXPRate", 1.0); randomBotAllianceRatio = sConfigMgr->GetOption("AiPlayerbot.RandomBotAllianceRatio", 50); randomBotHordeRatio = sConfigMgr->GetOption("AiPlayerbot.RandomBotHordeRatio", 50); disableDeathKnightLogin = sConfigMgr->GetOption("AiPlayerbot.DisableDeathKnightLogin", 0); diff --git a/src/PlayerbotAIConfig.h b/src/PlayerbotAIConfig.h index 527fb6cd..eced5535 100644 --- a/src/PlayerbotAIConfig.h +++ b/src/PlayerbotAIConfig.h @@ -275,7 +275,7 @@ public: bool randomBotShowCloak; bool randomBotFixedLevel; bool disableRandomLevels; - uint32 playerbotsXPrate; + float playerbotsXPrate; uint32 randomBotAllianceRatio; uint32 randomBotHordeRatio; bool disableDeathKnightLogin; diff --git a/src/Playerbots.cpp b/src/Playerbots.cpp index 0deeac69..a9c58d3a 100644 --- a/src/Playerbots.cpp +++ b/src/Playerbots.cpp @@ -23,6 +23,8 @@ #include "DatabaseLoader.h" #include "GuildTaskMgr.h" #include "Metric.h" +#include "PlayerScript.h" +#include "PlayerbotAIConfig.h" #include "RandomPlayerbotMgr.h" #include "ScriptMgr.h" #include "cs_playerbots.h" @@ -83,7 +85,8 @@ public: PLAYERHOOK_ON_CHAT_WITH_GROUP, PLAYERHOOK_ON_BEFORE_CRITERIA_PROGRESS, PLAYERHOOK_ON_BEFORE_ACHI_COMPLETE, - PLAYERHOOK_CAN_PLAYER_USE_PRIVATE_CHAT + PLAYERHOOK_CAN_PLAYER_USE_PRIVATE_CHAT, + PLAYERHOOK_ON_GIVE_EXP }) {} void OnPlayerLogin(Player* player) override @@ -210,6 +213,17 @@ public: } return true; } + + void OnPlayerGiveXP(Player* player, uint32& amount, Unit* /*victim*/, uint8 /*xpSource*/) override + { + if (!player->GetSession()->IsBot()) + return; + + if (sPlayerbotAIConfig->playerbotsXPrate != 1.0) + { + amount = static_cast(std::round(static_cast(amount) * sPlayerbotAIConfig->playerbotsXPrate)); + } + } }; class PlayerbotsMiscScript : public MiscScript diff --git a/src/strategy/actions/XpGainAction.cpp b/src/strategy/actions/XpGainAction.cpp index c271def4..9ab40652 100644 --- a/src/strategy/actions/XpGainAction.cpp +++ b/src/strategy/actions/XpGainAction.cpp @@ -18,21 +18,21 @@ bool XpGainAction::Execute(Event event) WorldPacket p(event.getPacket()); // (8+4+1+4+8) ObjectGuid guid; - uint32 xpgain; - uint8 type = 0; // 00-kill_xp type, 01-non_kill_xp type - uint32 givenXp = 0; - float groupBonus = 0; + // uint32 xpgain; + // uint8 type = 0; // 00-kill_xp type, 01-non_kill_xp type + // uint32 givenXp = 0; + // float groupBonus = 0; p.rpos(0); p >> guid; // 8 victim - p >> xpgain; // 1 given experience - p >> type; // 1 00-kill_xp type, 01-non_kill_xp type + // p >> xpgain; // 1 given experience + // p >> type; // 1 00-kill_xp type, 01-non_kill_xp type - if (!type) - { - p >> givenXp; // 4 experience without rested bonus - p >> groupBonus; // 8 group bonus - } + // if (!type) + // { + // p >> givenXp; // 4 experience without rested bonus + // p >> groupBonus; // 8 group bonus + // } Creature* creature = botAI->GetCreature(guid); if (creature && !creature->GetMap()->IsDungeon()) @@ -40,15 +40,16 @@ bool XpGainAction::Execute(Event event) BroadcastHelper::BroadcastKill(botAI, bot, creature); } - if (!sRandomPlayerbotMgr->IsRandomBot(bot) || sPlayerbotAIConfig->playerbotsXPrate == 1) - return true; + // playerbotsXPrate is now implemented in OnPlayerGiveXP script + // if (!sRandomPlayerbotMgr->IsRandomBot(bot) || sPlayerbotAIConfig->playerbotsXPrate == 1) + // return true; - Unit* victim = nullptr; - if (guid) - victim = botAI->GetUnit(guid); + // Unit* victim = nullptr; + // if (guid) + // victim = botAI->GetUnit(guid); - xpgain = xpgain * (sPlayerbotAIConfig->playerbotsXPrate - 1); - GiveXP(xpgain, victim); + // xpgain = xpgain * (sPlayerbotAIConfig->playerbotsXPrate - 1); + // GiveXP(xpgain, victim); return true; }