From 88d81c7a31318708bb6aa306d65159a089fad8b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E4=BD=A9=E8=8C=B9?= Date: Thu, 22 Sep 2022 17:22:19 -0600 Subject: [PATCH] Tweak automation --- .../actions/CastCustomSpellAction.cpp | 4 ++++ src/strategy/actions/DestroyItemAction.cpp | 21 +++++++++++++++++++ .../actions/GuildManagementActions.cpp | 4 ++-- src/strategy/triggers/GuildTriggers.cpp | 5 ++++- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/strategy/actions/CastCustomSpellAction.cpp b/src/strategy/actions/CastCustomSpellAction.cpp index 691dfa92..3dbeeced 100644 --- a/src/strategy/actions/CastCustomSpellAction.cpp +++ b/src/strategy/actions/CastCustomSpellAction.cpp @@ -309,6 +309,10 @@ bool DisEnchantRandomItemAction::Execute(Event event) for (auto& item: items) { + // don't touch rare+ items if with real player/guild + if ((botAI->HasRealPlayerMaster() || botAI->IsInRealGuild()) && item->GetTemplate()->Quality > ITEM_QUALITY_UNCOMMON) + return false; + if(CastCustomSpellAction::Execute(Event("disenchant random item", "13262 "+ chat->FormatQItem(item->GetEntry())))) return true; } diff --git a/src/strategy/actions/DestroyItemAction.cpp b/src/strategy/actions/DestroyItemAction.cpp index 4318a738..12b08b2e 100644 --- a/src/strategy/actions/DestroyItemAction.cpp +++ b/src/strategy/actions/DestroyItemAction.cpp @@ -47,6 +47,27 @@ bool SmartDestroyItemAction::Execute(Event event) if (bagSpace < 90) return false; + // only destoy grey items if with real player/guild + if (botAI->HasRealPlayerMaster() && botAI->IsInRealGuild()) + { + std::set items; + FindItemsToTradeByQualityVisitor visitor(ITEM_QUALITY_POOR, 5); + IterateItems(&visitor, ITERATE_ITEMS_IN_BAGS); + items.insert(visitor.GetResult().begin(), visitor.GetResult().end()); + + for (auto& item : items) + { + FindItemByIdVisitor visitor(item->GetTemplate()->ItemId); + DestroyItem(&visitor); + + bagSpace = AI_VALUE(uint8, "bag space"); + + if (bagSpace < 90) + return true; + } + return true; + } + std::vector bestToDestroy = { ITEM_USAGE_NONE }; //First destroy anything useless. if (!AI_VALUE(bool, "can sell") && AI_VALUE(bool, "should get money")) // We need money so quest items are less important since they can't directly be sold. diff --git a/src/strategy/actions/GuildManagementActions.cpp b/src/strategy/actions/GuildManagementActions.cpp index a5d1de12..b4a4b5d1 100644 --- a/src/strategy/actions/GuildManagementActions.cpp +++ b/src/strategy/actions/GuildManagementActions.cpp @@ -163,7 +163,7 @@ bool GuildManageNearbyAction::Execute(Event event) Guild::Member* member = guild->GetMember(player->GetGUID()); uint32 dCount = AI_VALUE(uint32, "death count"); - if (dCount < 2 || !urand(0, 10)) + if ((dCount < 2 || !urand(0, 10)) && guild->GetRankRights(botMember->GetRankId() & GR_RIGHT_PROMOTE)) { if (!urand(0, 10)) { @@ -173,7 +173,7 @@ bool GuildManageNearbyAction::Execute(Event event) } } - if (dCount > 3 || !urand(0, 10)) + if ((dCount > 3 || !urand(0, 10)) && guild->GetRankRights(botMember->GetRankId() & GR_RIGHT_DEMOTE)) { if (!urand(0, 10)) { diff --git a/src/strategy/triggers/GuildTriggers.cpp b/src/strategy/triggers/GuildTriggers.cpp index ab4148f5..5a39a53a 100644 --- a/src/strategy/triggers/GuildTriggers.cpp +++ b/src/strategy/triggers/GuildTriggers.cpp @@ -27,6 +27,9 @@ bool LeaveLargeGuildTrigger::IsActive() if (botAI->IsAlt()) return false; + if (botAI->IsInRealGuild()) + return false; + GuilderType type = botAI->GetGuilderType(); Guild* guild = sGuildMgr->GetGuildById(bot->GetGuildId()); @@ -34,7 +37,7 @@ bool LeaveLargeGuildTrigger::IsActive() Player* leader = ObjectAccessor::FindPlayer(guild->GetLeaderGUID()); //Only leave the guild if we know the leader is not a real player. - if (!leader) + if (!leader || !GET_PLAYERBOT_AI(leader) || !GET_PLAYERBOT_AI(leader)->IsRealPlayer()) return false; PlayerbotAI* leaderBotAI = GET_PLAYERBOT_AI(leader);