diff --git a/src/creatures/combat/combat.cpp b/src/creatures/combat/combat.cpp index 65da2cfd..2224505f 100644 --- a/src/creatures/combat/combat.cpp +++ b/src/creatures/combat/combat.cpp @@ -129,7 +129,7 @@ void Combat::getCombatArea(const Position ¢erPos, const Position &targetPos, } if (area) { - area->getList(centerPos, targetPos, list); + area->getList(centerPos, targetPos, list, getDirectionTo(targetPos, centerPos)); } else { list.emplace_back(g_game().map.getOrCreateTile(targetPos)); } @@ -261,18 +261,14 @@ ReturnValue Combat::canTargetCreature(const std::shared_ptr &player, con ReturnValue Combat::canDoCombat(const std::shared_ptr &caster, const std::shared_ptr &tile, bool aggressive) { if (tile->hasProperty(CONST_PROP_BLOCKPROJECTILE)) { - return RETURNVALUE_NOTENOUGHROOM; + return RETURNVALUE_CANNOTTHROW; } if (aggressive && tile->hasFlag(TILESTATE_PROTECTIONZONE)) { return RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE; } - if (tile->hasFlag(TILESTATE_FLOORCHANGE)) { - return RETURNVALUE_NOTENOUGHROOM; - } - if (tile->getTeleportItem()) { - return RETURNVALUE_NOTENOUGHROOM; + return RETURNVALUE_CANNOTTHROW; } if (caster) { @@ -1945,7 +1941,9 @@ AreaCombat::~AreaCombat() { clear(); } -void AreaCombat::getList(const Position ¢erPos, const Position &targetPos, std::vector> &list) const { +void AreaCombat::getList(const Position ¢erPos, const Position &targetPos, std::vector> &list, const Direction dir) const { + auto casterPos = getNextPosition(dir, targetPos); + const std::unique_ptr &area = getArea(centerPos, targetPos); if (!area) { return; @@ -1957,17 +1955,19 @@ void AreaCombat::getList(const Position ¢erPos, const Position &targetPos, s const uint32_t rows = area->getRows(); const uint32_t cols = area->getCols(); - list.reserve(rows * cols); + list.reserve(rows * cols); Position tmpPos(targetPos.x - centerX, targetPos.y - centerY, targetPos.z); - for (uint32_t y = 0; y < rows; ++y, ++tmpPos.y, tmpPos.x -= cols) { - for (uint32_t x = 0; x < cols; ++x, ++tmpPos.x) { - if (area->getValue(y, x) != 0) { - if (g_game().isSightClear(targetPos, tmpPos, true)) { - list.emplace_back(g_game().map.getOrCreateTile(tmpPos)); - } + + for (uint32_t y = 0; y < rows; ++y) { + for (uint32_t x = 0; x < cols; ++x) { + if (area->getValue(y, x) != 0 && g_game().isSightClear(casterPos, tmpPos, true)) { + list.emplace_back(g_game().map.getOrCreateTile(tmpPos)); } + ++tmpPos.x; } + ++tmpPos.y; + tmpPos.x -= cols; } } diff --git a/src/creatures/combat/combat.hpp b/src/creatures/combat/combat.hpp index 4e7e0f6f..105445d1 100644 --- a/src/creatures/combat/combat.hpp +++ b/src/creatures/combat/combat.hpp @@ -163,7 +163,7 @@ class AreaCombat { // non-assignable AreaCombat &operator=(const AreaCombat &) = delete; - void getList(const Position ¢erPos, const Position &targetPos, std::vector> &list) const; + void getList(const Position ¢erPos, const Position &targetPos, std::vector> &list, const Direction dir) const; void setupArea(const std::list &list, uint32_t rows); void setupArea(int32_t length, int32_t spread); diff --git a/src/creatures/combat/spells.cpp b/src/creatures/combat/spells.cpp index 2bb4889c..642a2e46 100644 --- a/src/creatures/combat/spells.cpp +++ b/src/creatures/combat/spells.cpp @@ -562,13 +562,6 @@ bool Spell::playerInstantSpellCheck(const std::shared_ptr &player, const const auto &tile = g_game().map.getOrCreateTile(toPos); - ReturnValue ret = Combat::canDoCombat(player, tile, aggressive); - if (ret != RETURNVALUE_NOERROR) { - player->sendCancelMessage(ret); - g_game().addMagicEffect(player->getPosition(), CONST_ME_POFF); - return false; - } - if (blockingCreature && tile->getBottomVisibleCreature(player) != nullptr) { player->sendCancelMessage(RETURNVALUE_NOTENOUGHROOM); g_game().addMagicEffect(player->getPosition(), CONST_ME_POFF);