mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-16 02:10:28 +00:00
Resolved issues with herb gathering (#926)
* Check game objects loot tables and determine if loot is valid * Removed LOS checks since they already occur and removed enemy near node check * Dismount if mounted, decresed interaction distance, added looting delay * Decreased interaction distance * oops, wrong file * Check game objects loot tables and determine if loot is valid
This commit is contained in:
@@ -51,29 +51,11 @@ bool AddGatheringLootAction::AddLoot(ObjectGuid guid)
|
||||
if (loot.IsEmpty() || !wo)
|
||||
return false;
|
||||
|
||||
if (!bot->IsWithinLOSInMap(wo))
|
||||
return false;
|
||||
|
||||
if (loot.skillId == SKILL_NONE)
|
||||
return false;
|
||||
|
||||
if (!loot.IsLootPossible(bot))
|
||||
return false;
|
||||
|
||||
if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, wo), INTERACTION_DISTANCE))
|
||||
{
|
||||
std::list<Unit*> targets;
|
||||
Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(bot, bot, sPlayerbotAIConfig->lootDistance);
|
||||
Acore::UnitListSearcher<Acore::AnyUnfriendlyUnitInObjectRangeCheck> searcher(bot, targets, u_check);
|
||||
Cell::VisitAllObjects(bot, searcher, sPlayerbotAIConfig->lootDistance * 1.5f);
|
||||
if (!targets.empty())
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "Kill that " << targets.front()->GetName() << " so I can loot freely";
|
||||
botAI->TellError(out.str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return AddAllLootAction::AddLoot(guid);
|
||||
}
|
||||
|
||||
@@ -79,9 +79,16 @@ bool OpenLootAction::DoLoot(LootObject& lootObject)
|
||||
return false;
|
||||
|
||||
Creature* creature = botAI->GetCreature(lootObject.guid);
|
||||
if (creature && bot->GetDistance(creature) > INTERACTION_DISTANCE)
|
||||
if (creature && bot->GetDistance(creature) > INTERACTION_DISTANCE - 2.0f)
|
||||
return false;
|
||||
|
||||
// Dismount if the bot is mounted
|
||||
if (bot->IsMounted())
|
||||
{
|
||||
bot->Dismount();
|
||||
botAI->SetNextCheckDelay(sPlayerbotAIConfig->lootDelay); // Small delay to avoid animation issues
|
||||
}
|
||||
|
||||
if (creature && creature->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE))
|
||||
{
|
||||
WorldPacket packet(CMSG_LOOT, 8);
|
||||
@@ -116,7 +123,7 @@ bool OpenLootAction::DoLoot(LootObject& lootObject)
|
||||
}
|
||||
|
||||
GameObject* go = botAI->GetGameObject(lootObject.guid);
|
||||
if (go && bot->GetDistance(go) > INTERACTION_DISTANCE)
|
||||
if (go && bot->GetDistance(go) > INTERACTION_DISTANCE - 2.0f)
|
||||
return false;
|
||||
|
||||
if (go && (go->GetGoState() != GO_STATE_READY))
|
||||
@@ -418,6 +425,7 @@ bool StoreLootAction::Execute(Event event)
|
||||
WorldPacket packet(CMSG_AUTOSTORE_LOOT_ITEM, 1);
|
||||
packet << itemindex;
|
||||
bot->GetSession()->HandleAutostoreLootItemOpcode(packet);
|
||||
botAI->SetNextCheckDelay(sPlayerbotAIConfig->lootDelay);
|
||||
|
||||
if (proto->Quality > ITEM_QUALITY_NORMAL && !urand(0, 50) && botAI->HasStrategy("emote", BOT_STATE_NON_COMBAT) && sPlayerbotAIConfig->randomBotEmote)
|
||||
botAI->PlayEmote(TEXT_EMOTE_CHEER);
|
||||
|
||||
@@ -13,9 +13,9 @@ bool LootAvailableTrigger::IsActive()
|
||||
{
|
||||
return AI_VALUE(bool, "has available loot") &&
|
||||
(sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "loot target"),
|
||||
INTERACTION_DISTANCE) ||
|
||||
INTERACTION_DISTANCE - 2.0f) ||
|
||||
AI_VALUE(GuidVector, "all targets").empty()) &&
|
||||
!AI_VALUE2(bool, "combat", "self target") && !AI_VALUE2(bool, "mounted", "self target");
|
||||
!AI_VALUE2(bool, "combat", "self target");
|
||||
}
|
||||
|
||||
bool FarFromCurrentLootTrigger::IsActive()
|
||||
@@ -24,7 +24,7 @@ bool FarFromCurrentLootTrigger::IsActive()
|
||||
if (!loot.IsLootPossible(bot))
|
||||
return false;
|
||||
|
||||
return AI_VALUE2(float, "distance", "loot target") > INTERACTION_DISTANCE;
|
||||
return AI_VALUE2(float, "distance", "loot target") >= INTERACTION_DISTANCE - 2.0f;
|
||||
}
|
||||
|
||||
bool CanLootTrigger::IsActive() { return AI_VALUE(bool, "can loot"); }
|
||||
|
||||
Reference in New Issue
Block a user