Permission check and readability improvements (#997)

* AiFactory check by spell instead of level

* Ignore group security for guild invitation
This commit is contained in:
Yunfan Li
2025-02-24 03:09:59 +08:00
committed by GitHub
parent 114eeb3b37
commit 95c2ba9105
5 changed files with 9 additions and 13 deletions

View File

@@ -322,7 +322,7 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa
case CLASS_WARRIOR:
if (tab == 2)
engine->addStrategiesNoInit("tank", "tank assist", "aoe", nullptr);
else if (player->GetLevel() < 36 || tab == 0)
else if (tab == 0 || !player->HasSpell(1680)) // Whirlwind
engine->addStrategiesNoInit("arms", "aoe", "dps assist", /*"behind",*/ nullptr);
else
engine->addStrategiesNoInit("fury", "aoe", "dps assist", /*"behind",*/ nullptr);
@@ -356,7 +356,7 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa
engine->addStrategiesNoInit("heal", "cure", "dps assist", nullptr);
else
{
if (player->GetLevel() >= 20 && !player->HasAura(16931) /*thick hide*/)
if (player->HasSpell(768) /*cat form*/&& !player->HasAura(16931) /*thick hide*/)
{
engine->addStrategiesNoInit("cat", "dps assist", nullptr);
}

View File

@@ -2068,7 +2068,7 @@ bool PlayerbotAI::IsMainTank(Player* player)
Group* group = player->GetGroup();
if (!group)
{
return false;
return IsTank(player);
}
ObjectGuid mainTank = ObjectGuid();
Group::MemberSlotList const& slots = group->GetMemberSlots();

View File

@@ -139,7 +139,7 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea
return PLAYERBOT_SECURITY_INVITE;
}
if (group->IsFull())
if (!ignoreGroup && group->IsFull())
{
if (reason)
*reason = PLAYERBOT_DENY_FULL_GROUP;
@@ -147,7 +147,7 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea
return PLAYERBOT_SECURITY_TALK;
}
if (group->GetLeaderGUID() != bot->GetGUID())
if (!ignoreGroup && group->GetLeaderGUID() != bot->GetGUID())
{
if (reason)
*reason = PLAYERBOT_DENY_NOT_LEADER;

View File

@@ -36,8 +36,8 @@ uint32 LfgJoinAction::GetRoles()
case CLASS_DRUID:
if (spec == 2)
return PLAYER_ROLE_HEALER;
else if (spec == 1)
return (PLAYER_ROLE_TANK | PLAYER_ROLE_DAMAGE);
else if (spec == 1 && bot->HasAura(16931) /* thick hide */)
return PLAYER_ROLE_TANK;
else
return PLAYER_ROLE_DAMAGE;
break;
@@ -206,6 +206,7 @@ bool LfgAcceptAction::Execute(Event event)
if (bot->IsInCombat() || bot->isDead())
{
/// @FIXME: Race condition
LOG_INFO("playerbots", "Bot {} {}:{} <{}> is in combat and refuses LFG proposal {}",
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(),
bot->GetName().c_str(), id);
@@ -219,7 +220,7 @@ bool LfgAcceptAction::Execute(Event event)
botAI->GetAiObjectContext()->GetValue<uint32>("lfg proposal")->Set(0);
bot->ClearUnitState(UNIT_STATE_ALL_STATE);
/// @FIXME: Race condition
sLFGMgr->UpdateProposal(id, bot->GetGUID(), true);
if (sRandomPlayerbotMgr->IsRandomBot(bot) && !bot->GetGroup())

View File

@@ -1583,11 +1583,6 @@ bool MovementAction::MoveAway(Unit* target, float distance, bool backwards)
// just calculates average position of group and runs away from that position
bool MovementAction::MoveFromGroup(float distance)
{
// LOG_ERROR("playerbots", "MovementAction::MoveFromGroup");
//if (Player* master = botAI->GetMaster())
//{
// return MoveAway(master);
//}
if (Group* group = bot->GetGroup())
{
uint32 mapId = bot->GetMapId();