mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Scripts and sessions update to align with acore (#987)
This commit is contained in:
@@ -5431,7 +5431,7 @@ InventoryResult PlayerbotAI::CanEquipItem(uint8 slot, uint16& dest, Item* pItem,
|
|||||||
ItemTemplate const* pProto = pItem->GetTemplate();
|
ItemTemplate const* pProto = pItem->GetTemplate();
|
||||||
if (pProto)
|
if (pProto)
|
||||||
{
|
{
|
||||||
if (!sScriptMgr->CanEquipItem(bot, slot, dest, pItem, swap, not_loading))
|
if (!sScriptMgr->OnPlayerCanEquipItem(bot, slot, dest, pItem, swap, not_loading))
|
||||||
return EQUIP_ERR_CANT_DO_RIGHT_NOW;
|
return EQUIP_ERR_CANT_DO_RIGHT_NOW;
|
||||||
|
|
||||||
// item used
|
// item used
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "ChannelMgr.h"
|
#include "ChannelMgr.h"
|
||||||
#include "BroadcastHelper.h"
|
#include "BroadcastHelper.h"
|
||||||
#include "PlayerbotDbStore.h"
|
#include "PlayerbotDbStore.h"
|
||||||
|
#include "WorldSessionMgr.h"
|
||||||
|
|
||||||
PlayerbotHolder::PlayerbotHolder() : PlayerbotAIBase(false) {}
|
PlayerbotHolder::PlayerbotHolder() : PlayerbotAIBase(false) {}
|
||||||
class PlayerbotLoginQueryHolder : public LoginQueryHolder
|
class PlayerbotLoginQueryHolder : public LoginQueryHolder
|
||||||
@@ -64,7 +65,7 @@ void PlayerbotHolder::AddPlayerBot(ObjectGuid playerGuid, uint32 masterAccountId
|
|||||||
if (!accountId)
|
if (!accountId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WorldSession* masterSession = masterAccountId ? sWorld->FindSession(masterAccountId) : nullptr;
|
WorldSession* masterSession = masterAccountId ? sWorldSessionMgr->FindSession(masterAccountId) : nullptr;
|
||||||
Player* masterPlayer = masterSession ? masterSession->GetPlayer() : nullptr;
|
Player* masterPlayer = masterSession ? masterSession->GetPlayer() : nullptr;
|
||||||
|
|
||||||
bool isRndbot = !masterAccountId;
|
bool isRndbot = !masterAccountId;
|
||||||
@@ -115,7 +116,7 @@ void PlayerbotHolder::AddPlayerBot(ObjectGuid playerGuid, uint32 masterAccountId
|
|||||||
|
|
||||||
botLoading.insert(playerGuid);
|
botLoading.insert(playerGuid);
|
||||||
|
|
||||||
if (WorldSession* masterSession = sWorld->FindSession(masterAccountId))
|
if (WorldSession* masterSession = sWorldSessionMgr->FindSession(masterAccountId))
|
||||||
{
|
{
|
||||||
masterSession->AddQueryHolderCallback(CharacterDatabase.DelayQueryHolder(holder))
|
masterSession->AddQueryHolderCallback(CharacterDatabase.DelayQueryHolder(holder))
|
||||||
.AfterComplete([this](SQLQueryHolderBase const& holder)
|
.AfterComplete([this](SQLQueryHolderBase const& holder)
|
||||||
@@ -151,7 +152,7 @@ void PlayerbotHolder::HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder con
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 masterAccount = holder.GetMasterAccountId();
|
uint32 masterAccount = holder.GetMasterAccountId();
|
||||||
WorldSession* masterSession = masterAccount ? sWorld->FindSession(masterAccount) : nullptr;
|
WorldSession* masterSession = masterAccount ? sWorldSessionMgr->FindSession(masterAccount) : nullptr;
|
||||||
|
|
||||||
// Check if masterSession->GetPlayer() is valid
|
// Check if masterSession->GetPlayer() is valid
|
||||||
Player* masterPlayer = masterSession ? masterSession->GetPlayer() : nullptr;
|
Player* masterPlayer = masterSession ? masterSession->GetPlayer() : nullptr;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "PlayerbotTextMgr.h"
|
#include "PlayerbotTextMgr.h"
|
||||||
|
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
|
#include "WorldSessionMgr.h"
|
||||||
|
|
||||||
void PlayerbotTextMgr::replaceAll(std::string& str, const std::string& from, const std::string& to)
|
void PlayerbotTextMgr::replaceAll(std::string& str, const std::string& from, const std::string& to)
|
||||||
{
|
{
|
||||||
@@ -184,7 +185,7 @@ uint32 PlayerbotTextMgr::GetLocalePriority()
|
|||||||
uint32 topLocale = 0;
|
uint32 topLocale = 0;
|
||||||
|
|
||||||
// if no real players online, reset top locale
|
// if no real players online, reset top locale
|
||||||
if (!sWorld->GetActiveSessionCount())
|
if (!sWorldSessionMgr->GetActiveSessionCount())
|
||||||
{
|
{
|
||||||
ResetLocalePriority();
|
ResetLocalePriority();
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -72,26 +72,12 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PlayerbotsMetricScript : public MetricScript
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PlayerbotsMetricScript() : MetricScript("PlayerbotsMetricScript") {}
|
|
||||||
|
|
||||||
void OnMetricLogging() override
|
|
||||||
{
|
|
||||||
if (sMetric->IsEnabled())
|
|
||||||
{
|
|
||||||
sMetric->LogValue("db_queue_playerbots", uint64(PlayerbotsDatabase.QueueSize()), {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class PlayerbotsPlayerScript : public PlayerScript
|
class PlayerbotsPlayerScript : public PlayerScript
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PlayerbotsPlayerScript() : PlayerScript("PlayerbotsPlayerScript") {}
|
PlayerbotsPlayerScript() : PlayerScript("PlayerbotsPlayerScript") {}
|
||||||
|
|
||||||
void OnLogin(Player* player) override
|
void OnPlayerLogin(Player* player) override
|
||||||
{
|
{
|
||||||
if (!player->GetSession()->IsBot())
|
if (!player->GetSession()->IsBot())
|
||||||
{
|
{
|
||||||
@@ -122,7 +108,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnAfterUpdate(Player* player, uint32 diff) override
|
void OnPlayerAfterUpdate(Player* player, uint32 diff) override
|
||||||
{
|
{
|
||||||
if (PlayerbotAI* botAI = GET_PLAYERBOT_AI(player))
|
if (PlayerbotAI* botAI = GET_PLAYERBOT_AI(player))
|
||||||
{
|
{
|
||||||
@@ -135,7 +121,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CanPlayerUseChat(Player* player, uint32 type, uint32 /*lang*/, std::string& msg, Player* receiver) override
|
bool OnPlayerCanUseChat(Player* player, uint32 type, uint32 /*lang*/, std::string& msg, Player* receiver) override
|
||||||
{
|
{
|
||||||
if (type == CHAT_MSG_WHISPER)
|
if (type == CHAT_MSG_WHISPER)
|
||||||
{
|
{
|
||||||
@@ -150,7 +136,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnChat(Player* player, uint32 type, uint32 /*lang*/, std::string& msg, Group* group) override
|
void OnPlayerChat(Player* player, uint32 type, uint32 /*lang*/, std::string& msg, Group* group) override
|
||||||
{
|
{
|
||||||
for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
|
for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
|
||||||
{
|
{
|
||||||
@@ -164,7 +150,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnChat(Player* player, uint32 type, uint32 /*lang*/, std::string& msg) override
|
void OnPlayerChat(Player* player, uint32 type, uint32 /*lang*/, std::string& msg) override
|
||||||
{
|
{
|
||||||
if (type == CHAT_MSG_GUILD)
|
if (type == CHAT_MSG_GUILD)
|
||||||
{
|
{
|
||||||
@@ -185,7 +171,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnChat(Player* player, uint32 type, uint32 /*lang*/, std::string& msg, Channel* channel) override
|
void OnPlayerChat(Player* player, uint32 type, uint32 /*lang*/, std::string& msg, Channel* channel) override
|
||||||
{
|
{
|
||||||
if (PlayerbotMgr* playerbotMgr = GET_PLAYERBOT_MGR(player))
|
if (PlayerbotMgr* playerbotMgr = GET_PLAYERBOT_MGR(player))
|
||||||
{
|
{
|
||||||
@@ -198,7 +184,7 @@ public:
|
|||||||
sRandomPlayerbotMgr->HandleCommand(type, msg, player);
|
sRandomPlayerbotMgr->HandleCommand(type, msg, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OnBeforeCriteriaProgress(Player* player, AchievementCriteriaEntry const* /*criteria*/) override
|
bool OnPlayerBeforeCriteriaProgress(Player* player, AchievementCriteriaEntry const* /*criteria*/) override
|
||||||
{
|
{
|
||||||
if (sRandomPlayerbotMgr->IsRandomBot(player))
|
if (sRandomPlayerbotMgr->IsRandomBot(player))
|
||||||
{
|
{
|
||||||
@@ -207,7 +193,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OnBeforeAchiComplete(Player* player, AchievementEntry const* /*achievement*/) override
|
bool OnPlayerBeforeAchievementComplete(Player* player, AchievementEntry const* /*achievement*/) override
|
||||||
{
|
{
|
||||||
if (sRandomPlayerbotMgr->IsRandomBot(player))
|
if (sRandomPlayerbotMgr->IsRandomBot(player))
|
||||||
{
|
{
|
||||||
@@ -372,7 +358,6 @@ public:
|
|||||||
void AddPlayerbotsScripts()
|
void AddPlayerbotsScripts()
|
||||||
{
|
{
|
||||||
new PlayerbotsDatabaseScript();
|
new PlayerbotsDatabaseScript();
|
||||||
new PlayerbotsMetricScript();
|
|
||||||
new PlayerbotsPlayerScript();
|
new PlayerbotsPlayerScript();
|
||||||
new PlayerbotsMiscScript();
|
new PlayerbotsMiscScript();
|
||||||
new PlayerbotsServerScript();
|
new PlayerbotsServerScript();
|
||||||
|
|||||||
Reference in New Issue
Block a user