diff --git a/zone/bot.cpp b/zone/bot.cpp index e0f25bf12..99621dd0a 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -12380,6 +12380,23 @@ bool Bot::BotPassiveCheck() { return false; } +bool Bot::ValidStateCheck(Mob* other, bool same_raid_group) { + if ( + GetBotStance() == Stance::Passive || + GetHoldFlag() || + GetAppearance() == eaDead || + IsFeared() || + IsSilenced() || + IsAmnesiad() || + GetHP() < 0 || + !IsInGroupOrRaid(other, same_raid_group) + ) { + return false; + } + + return true; +} + bool Bot::IsValidSpellTypeSubType(uint16 spell_type, uint16 sub_type, uint16 spell_id) { if (sub_type == UINT16_MAX) { return true; diff --git a/zone/bot.h b/zone/bot.h index ed6766a86..1523a2174 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -526,6 +526,7 @@ public: void DoAttackRounds(Mob* target, int hand); bool BotPassiveCheck(); + bool ValidStateCheck(Mob* other, bool same_raid_group = false); Raid* GetStoredRaid() { return _storedRaid; } void SetStoredRaid(Raid* stored_raid) { _storedRaid = stored_raid; } bool GetVerifiedRaid() { return _verifiedRaid; } diff --git a/zone/bot_commands/attack.cpp b/zone/bot_commands/attack.cpp index 05344da12..6c8cef9cb 100644 --- a/zone/bot_commands/attack.cpp +++ b/zone/bot_commands/attack.cpp @@ -54,34 +54,33 @@ void bot_command_attack(Client *c, const Seperator *sep) Bot *first_attacker = nullptr; sbl.erase(std::remove(sbl.begin(), sbl.end(), nullptr), sbl.end()); for (auto bot_iter : sbl) { - - if (bot_iter->GetAppearance() != eaDead && bot_iter->GetBotStance() != Stance::Passive) { - - if (!first_attacker) { - first_attacker = bot_iter; - } - ++attacker_count; - - bot_iter->SetAttackFlag(); + if (!bot_iter->ValidStateCheck(c)) { + continue; } + + if (!first_attacker) { + first_attacker = bot_iter; + } + + ++attacker_count; + + bot_iter->SetAttackFlag(); } - if (attacker_count == 1 && first_attacker) { - c->Message( - Chat::Green, - fmt::format( - "Attacking {}.", - target_mob->GetCleanName() - ).c_str() - ); - } else { - c->Message( - Chat::Green, - fmt::format( - "{} of your bots are attacking {}.", - sbl.size(), - target_mob->GetCleanName() - ).c_str() - ); + if (first_attacker) { + std::string message; + + if (attacker_count == 1) { + message = fmt::format("Attacking {}.", target_mob->GetCleanName()); + } else { + message = fmt::format("{} of your bots are attacking {}.", sbl.size(), target_mob->GetCleanName()); + } + + c->Message(Chat::Green, message.c_str()); } + else { + c->Message(Chat::Yellow,fmt::format("None of your bots are capable of attacking {}.", target_mob->GetCleanName()).c_str()); + } + + return; } diff --git a/zone/bot_commands/cast.cpp b/zone/bot_commands/cast.cpp index 5ac4d65c3..6ac5119fb 100644 --- a/zone/bot_commands/cast.cpp +++ b/zone/bot_commands/cast.cpp @@ -477,11 +477,7 @@ void bot_command_cast(Client* c, const Seperator* sep) Bot* first_found = nullptr; for (auto bot_iter : sbl) { - if (!bot_iter->IsInGroupOrRaid(c)) { - continue; - } - - if (bot_iter->GetBotStance() == Stance::Passive || bot_iter->GetHoldFlag() || bot_iter->GetAppearance() == eaDead || bot_iter->IsFeared() || bot_iter->IsSilenced() || bot_iter->IsAmnesiad() || bot_iter->GetHP() < 0) { + if (!bot_iter->ValidStateCheck(c)) { continue; } diff --git a/zone/bot_commands/depart.cpp b/zone/bot_commands/depart.cpp index 82c7fee50..c9deda5ad 100644 --- a/zone/bot_commands/depart.cpp +++ b/zone/bot_commands/depart.cpp @@ -141,11 +141,7 @@ void bot_command_depart(Client* c, const Seperator* sep) std::map> list_zones; for (auto bot_iter : sbl) { - if (!bot_iter->IsInGroupOrRaid(tar, !single)) { - continue; - } - - if (bot_iter->GetBotStance() == Stance::Passive || bot_iter->GetHoldFlag() || bot_iter->GetAppearance() == eaDead || bot_iter->IsFeared() || bot_iter->IsSilenced() || bot_iter->IsAmnesiad() || bot_iter->GetHP() < 0) { + if (!bot_iter->ValidStateCheck(c)) { continue; } diff --git a/zone/bot_commands/discipline.cpp b/zone/bot_commands/discipline.cpp index c937dea34..ce29e0292 100644 --- a/zone/bot_commands/discipline.cpp +++ b/zone/bot_commands/discipline.cpp @@ -125,11 +125,7 @@ void bot_command_discipline(Client* c, const Seperator* sep) Bot* first_found = nullptr; for (auto bot_iter : sbl) { - if (!bot_iter->IsInGroupOrRaid(c)) { - continue; - } - - if (bot_iter->GetBotStance() == Stance::Passive || bot_iter->GetHoldFlag() || bot_iter->GetAppearance() == eaDead || bot_iter->IsFeared() || bot_iter->IsSilenced() || bot_iter->IsAmnesiad() || bot_iter->GetHP() < 0) { + if (!bot_iter->ValidStateCheck(c)) { continue; } diff --git a/zone/bot_commands/pull.cpp b/zone/bot_commands/pull.cpp index 22c27ee25..093cf9bc3 100644 --- a/zone/bot_commands/pull.cpp +++ b/zone/bot_commands/pull.cpp @@ -63,7 +63,7 @@ void bot_command_pull(Client *c, const Seperator *sep) Bot* bot_puller = nullptr; for (auto bot_iter : sbl) { - if (bot_iter->GetAppearance() == eaDead || bot_iter->GetBotStance() == Stance::Passive) { + if (!bot_iter->ValidStateCheck(c)) { continue; }