Handle command and trade check for summoned bot

This commit is contained in:
Yunfan Li
2024-08-07 17:45:21 +08:00
parent c0836c26e6
commit e88a93d65e
4 changed files with 26 additions and 26 deletions

View File

@@ -655,11 +655,7 @@ void PlayerbotAI::HandleCommand(uint32 type, std::string const text, Player* fro
} }
if (!IsAllowedCommand(filtered) && if (!IsAllowedCommand(filtered) &&
(master != fromPlayer || (!GetSecurity()->CheckLevelFor(PLAYERBOT_SECURITY_ALLOW_ALL, type != CHAT_MSG_WHISPER, fromPlayer)))
!GetSecurity()->CheckLevelFor(PLAYERBOT_SECURITY_ALLOW_ALL, type != CHAT_MSG_WHISPER, fromPlayer)))
return;
if (!IsAllowedCommand(filtered) && master != fromPlayer)
return; return;
if (type == CHAT_MSG_RAID_WARNING && filtered.find(bot->GetName()) != std::string::npos && if (type == CHAT_MSG_RAID_WARNING && filtered.find(bot->GetName()) != std::string::npos &&

View File

@@ -55,14 +55,16 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea
// } // }
Group* group = from->GetGroup(); Group* group = from->GetGroup();
if (group) if (group && group == bot->GetGroup() && !ignoreGroup && botAI->GetMaster() == from)
{ {
for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next()) return PLAYERBOT_SECURITY_ALLOW_ALL;
{ }
Player* player = gref->GetSource();
if (player == bot && !ignoreGroup) if (group && group == bot->GetGroup() && !ignoreGroup && botAI->GetMaster() != from)
return PLAYERBOT_SECURITY_ALLOW_ALL; {
} if (reason)
*reason = PLAYERBOT_DENY_NOT_YOURS;
return PLAYERBOT_SECURITY_TALK;
} }
if (sPlayerbotAIConfig->groupInvitationPermission <= 0) if (sPlayerbotAIConfig->groupInvitationPermission <= 0)
@@ -137,13 +139,6 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea
return PLAYERBOT_SECURITY_INVITE; return PLAYERBOT_SECURITY_INVITE;
} }
for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next())
{
Player* player = gref->GetSource();
if (player == from)
return PLAYERBOT_SECURITY_ALLOW_ALL;
}
if (group->IsFull()) if (group->IsFull())
{ {
if (reason) if (reason)
@@ -169,11 +164,17 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea
if (reason) if (reason)
*reason = PLAYERBOT_DENY_INVITE; *reason = PLAYERBOT_DENY_INVITE;
return PLAYERBOT_SECURITY_INVITE; return PLAYERBOT_SECURITY_INVITE;
} }
return PLAYERBOT_SECURITY_ALLOW_ALL; if (botAI->GetMaster() == from)
return PLAYERBOT_SECURITY_ALLOW_ALL;
if (reason)
*reason = PLAYERBOT_DENY_NOT_YOURS;
return PLAYERBOT_SECURITY_INVITE;
} }
bool PlayerbotSecurity::CheckLevelFor(PlayerbotSecurityLevel level, bool silent, Player* from, bool ignoreGroup) bool PlayerbotSecurity::CheckLevelFor(PlayerbotSecurityLevel level, bool silent, Player* from, bool ignoreGroup)

View File

@@ -1215,9 +1215,6 @@ void RandomPlayerbotMgr::Revive(Player* player)
void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector<WorldLocation>& locs, bool hearth) void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector<WorldLocation>& locs, bool hearth)
{ {
if (bot->IsBeingTeleported())
return;
if (bot->InBattleground()) if (bot->InBattleground())
return; return;

View File

@@ -10,8 +10,10 @@
#include "GuildTaskMgr.h" #include "GuildTaskMgr.h"
#include "ItemUsageValue.h" #include "ItemUsageValue.h"
#include "ItemVisitors.h" #include "ItemVisitors.h"
#include "PlayerbotMgr.h"
#include "PlayerbotSecurity.h" #include "PlayerbotSecurity.h"
#include "Playerbots.h" #include "Playerbots.h"
#include "RandomPlayerbotMgr.h"
#include "SetCraftAction.h" #include "SetCraftAction.h"
bool TradeStatusAction::Execute(Event event) bool TradeStatusAction::Execute(Event event)
@@ -180,8 +182,12 @@ bool TradeStatusAction::CheckTrade()
} }
return isGettingItem; return isGettingItem;
} }
if (!bot->GetSession())
if (!sRandomPlayerbotMgr->IsRandomBot(bot)) {
return false;
}
uint32 accountId = bot->GetSession()->GetAccountId();
if (!sPlayerbotAIConfig->IsInRandomAccountList(accountId))
{ {
int32 botItemsMoney = CalculateCost(bot, true); int32 botItemsMoney = CalculateCost(bot, true);
int32 botMoney = bot->GetTradeData()->GetMoney() + botItemsMoney; int32 botMoney = bot->GetTradeData()->GetMoney() + botItemsMoney;