From 8dec6f96aa85bf6873c5a6598e538b7fb8853d8e Mon Sep 17 00:00:00 2001 From: Leandro Date: Mon, 25 Mar 2024 22:31:55 -0300 Subject: [PATCH] fix: auto loot reachable corpses only (#2473) --- src/creatures/creature.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/creatures/creature.cpp b/src/creatures/creature.cpp index 6ee605769a7..6101ff0473d 100644 --- a/src/creatures/creature.cpp +++ b/src/creatures/creature.cpp @@ -813,7 +813,17 @@ bool Creature::dropCorpse(std::shared_ptr lastHitCreature, std::shared player->sendLootMessage(lootMessage.str()); } - if (player->checkAutoLoot(monster->isRewardBoss()) && corpseContainer && mostDamageCreature->getPlayer()) { + stdext::arraylist dirList(128); + FindPathParams fpp; + fpp.minTargetDist = 0; + fpp.maxTargetDist = 1; + fpp.fullPathSearch = true; + fpp.clearSight = true; + fpp.maxSearchDist = 0; + + auto isReachable = g_game().map.getPathMatching(player->getPosition(), dirList, FrozenPathingConditionCall(corpse->getPosition()), fpp); + + if (player->checkAutoLoot(monster->isRewardBoss()) && corpseContainer && mostDamageCreature->getPlayer() && isReachable) { g_dispatcher().addEvent([player, corpseContainer, corpsePosition = corpse->getPosition()] { g_game().playerQuickLootCorpse(player, corpseContainer, corpsePosition); },