From ee99b66d0417be57e3ebd8c338a03b964ca70827 Mon Sep 17 00:00:00 2001 From: Yunfan Li <56597220+liyunfan1223@users.noreply.github.com> Date: Sat, 2 Aug 2025 16:10:49 +0800 Subject: [PATCH 1/2] Sync with azerothcore (#1492) --- src/PlayerbotMgr.cpp | 2 +- src/RandomPlayerbotFactory.cpp | 2 +- src/TravelMgr.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PlayerbotMgr.cpp b/src/PlayerbotMgr.cpp index e00ab29e..027e2bab 100644 --- a/src/PlayerbotMgr.cpp +++ b/src/PlayerbotMgr.cpp @@ -168,7 +168,7 @@ void PlayerbotHolder::HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder con uint32 botAccountId = holder.GetAccountId(); // At login DBC locale should be what the server is set to use by default (as spells etc are hardcoded to ENUS this // allows channels to work as intended) - WorldSession* botSession = new WorldSession(botAccountId, "", nullptr, SEC_PLAYER, EXPANSION_WRATH_OF_THE_LICH_KING, + WorldSession* botSession = new WorldSession(botAccountId, "", 0x0, nullptr, SEC_PLAYER, EXPANSION_WRATH_OF_THE_LICH_KING, time_t(0), sWorld->GetDefaultDbcLocale(), 0, false, false, 0, true); botSession->HandlePlayerLoginFromDB(holder); // will delete lqh diff --git a/src/RandomPlayerbotFactory.cpp b/src/RandomPlayerbotFactory.cpp index a3d6a2c7..291d6825 100644 --- a/src/RandomPlayerbotFactory.cpp +++ b/src/RandomPlayerbotFactory.cpp @@ -785,7 +785,7 @@ void RandomPlayerbotFactory::CreateRandomBots() LOG_DEBUG("playerbots", "Creating random bot characters for account: [{}/{}]", accountNumber + 1, totalAccountCount); RandomPlayerbotFactory factory(accountId); - WorldSession* session = new WorldSession(accountId, "", nullptr, SEC_PLAYER, EXPANSION_WRATH_OF_THE_LICH_KING, + WorldSession* session = new WorldSession(accountId, "", 0x0, nullptr, SEC_PLAYER, EXPANSION_WRATH_OF_THE_LICH_KING, time_t(0), LOCALE_enUS, 0, false, false, 0, true); sessionBots.push_back(session); diff --git a/src/TravelMgr.cpp b/src/TravelMgr.cpp index def180ee..69d510b9 100644 --- a/src/TravelMgr.cpp +++ b/src/TravelMgr.cpp @@ -3336,7 +3336,7 @@ void TravelMgr::LoadQuestTravelTable() uint32 accountId = fields[0].Get(); WorldSession* session = - new WorldSession(accountId, "", nullptr, SEC_PLAYER, EXPANSION_WRATH_OF_THE_LICH_KING, time_t(0), + new WorldSession(accountId, "", 0x0, nullptr, SEC_PLAYER, EXPANSION_WRATH_OF_THE_LICH_KING, time_t(0), LOCALE_enUS, 0, false, false, 0, true); std::vector, uint32>> classSpecLevel; From a6c07ca16d1965a2e22433f2e6d4ae97b2e0301d Mon Sep 17 00:00:00 2001 From: brighton-chi Date: Sun, 3 Aug 2025 16:12:33 -0500 Subject: [PATCH 2/2] Improve attackaction failure message system (#1498) --- src/strategy/actions/AttackAction.cpp | 91 +++++++++++++-------------- 1 file changed, 43 insertions(+), 48 deletions(-) diff --git a/src/strategy/actions/AttackAction.cpp b/src/strategy/actions/AttackAction.cpp index 58c47128..e557a178 100644 --- a/src/strategy/actions/AttackAction.cpp +++ b/src/strategy/actions/AttackAction.cpp @@ -59,10 +59,7 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/) bool sameTarget = oldTarget == target && bot->GetVictim() == target; bool inCombat = botAI->GetState() == BOT_STATE_COMBAT; bool sameAttackMode = bot->HasUnitState(UNIT_STATE_MELEE_ATTACKING) == shouldMelee; - // there's no reason to do attack again - if (sameTarget && inCombat && sameAttackMode) - return false; - + if (bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE || bot->HasUnitState(UNIT_STATE_IN_FLIGHT)) { @@ -82,52 +79,53 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/) if (!target->IsInWorld()) { + if (verbose) + botAI->TellError(std::string(target->GetName()) + " is no longer in the world."); + return false; + } + + if ((sPlayerbotAIConfig->IsInPvpProhibitedZone(bot->GetZoneId()) || + sPlayerbotAIConfig->IsInPvpProhibitedArea(bot->GetAreaId())) + && (target->IsPlayer() || target->IsPet())) + { + if (verbose) + botAI->TellError("I cannot attack other players in PvP prohibited areas."); + + return false; + } + + if (bot->IsFriendlyTo(target)) + { + if (verbose) + botAI->TellError(std::string(target->GetName()) + " is friendly to me."); + return false; + } + + if (target->isDead()) + { + if (verbose) + botAI->TellError(std::string(target->GetName()) + " is dead."); + return false; + } + + if (!bot->IsWithinLOSInMap(target)) + { + if (verbose) + botAI->TellError(std::string(target->GetName()) + " is not in my sight."); + return false; + } + + if (sameTarget && inCombat && sameAttackMode) + { + if (verbose) + botAI->TellError("I am already attacking " + std::string(target->GetName()) + "."); return false; } if (!bot->IsValidAttackTarget(target)) { if (verbose) - botAI->TellError("I cannot attack an invalid target"); - - return false; - } - - std::ostringstream msg; - msg << target->GetName(); - - if (bot->IsFriendlyTo(target)) - { - msg << " is friendly to me"; - if (verbose) - botAI->TellError(msg.str()); - - return false; - } - - if (!bot->IsWithinLOSInMap(target)) - { - msg << " is not in my sight"; - if (verbose) - botAI->TellError(msg.str()); - - return false; - } - - if (target->isDead()) - { - msg << " is dead"; - if (verbose) - botAI->TellError(msg.str()); - - return false; - } - - if (sPlayerbotAIConfig->IsInPvpProhibitedZone(bot->GetZoneId()) - && (target->IsPlayer() || target->IsPet())) - { - if (verbose) - botAI->TellError("I cannot attack others in PvP prohibited zones"); + botAI->TellError("I cannot attack an invalid target."); return false; } @@ -141,9 +139,7 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/) ObjectGuid guid = target->GetGUID(); bot->SetSelection(target->GetGUID()); - - - context->GetValue("old target")->Set(oldTarget); + context->GetValue("old target")->Set(oldTarget); context->GetValue("current target")->Set(target); context->GetValue("available loot")->Get()->Add(guid); @@ -157,7 +153,6 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/) bot->StopMoving(); } - if (IsMovingAllowed() && !bot->HasInArc(CAST_ANGLE_IN_FRONT, target)) { sServerFacade->SetFacingTo(bot, target);