mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[Bots] Add IsInRaidOrGroup checks to ^attack and ^pull (#4654)
This commit is contained in:
parent
ed7023f336
commit
41009aa19b
17
zone/bot.cpp
17
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;
|
||||
|
||||
@ -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; }
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -141,11 +141,7 @@ void bot_command_depart(Client* c, const Seperator* sep)
|
||||
std::map<std::string, std::pair<uint8_t, uint8_t>> 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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user