Skip to content

Commit

Permalink
PLAYER_SEARCHDIST
Browse files Browse the repository at this point in the history
Attempt to merge SEARCHDIST, still need to fix 'potion' because is not declared

Co-Authored-By: gigastar <26754137+gigastar@users.noreply.github.com>
  • Loading branch information
ralke23 and NRH-AA committed Sep 11, 2022
1 parent e147a1d commit b73d122
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/game.cpp
Expand Up @@ -698,7 +698,7 @@ void Game::playerMoveCreature(Player* player, Creature* movingCreature, const Po
if (!Position::areInRange<1, 1, 0>(movingCreatureOrigPos, player->getPosition())) {
//need to walk to the creature first before moving it
std::vector<Direction> listDir;
if (player->getPathTo(movingCreatureOrigPos, listDir, 0, 1, true, true)) {
if (player->getPathTo(movingCreatureOrigPos, listDir, 0, 1, true, true, PLAYER_SEARCHDIST)) {
g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk,
this, player->getID(), std::move(listDir))));
SchedulerTask* task = createSchedulerTask(RANGE_MOVE_CREATURE_INTERVAL, std::bind(&Game::playerMoveCreatureByID, this,
Expand Down Expand Up @@ -935,7 +935,7 @@ void Game::playerMoveItem(Player* player, const Position& fromPos,
if (!Position::areInRange<1, 1>(playerPos, mapFromPos)) {
//need to walk to the item first before using it
std::vector<Direction> listDir;
if (player->getPathTo(item->getPosition(), listDir, 0, 1, true, true)) {
if (player->getPathTo(item->getPosition(), listDir, 0, 1, true, true, PLAYER_SEARCHDIST)) {
g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk,
this, player->getID(), std::move(listDir))));

Expand Down Expand Up @@ -994,7 +994,7 @@ void Game::playerMoveItem(Player* player, const Position& fromPos,
}

std::vector<Direction> listDir;
if (player->getPathTo(walkPos, listDir, 0, 0, true, true)) {
if (player->getPathTo(walkPos, listDir, 0, 0, true, true, PLAYER_SEARCHDIST)) {
g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk,
this, player->getID(), std::move(listDir))));

Expand Down Expand Up @@ -1995,7 +1995,7 @@ void Game::playerUseItemEx(uint32_t playerId, const Position& fromPos, uint8_t f
}

std::vector<Direction> listDir;
if (player->getPathTo(walkToPos, listDir, 0, 1, true, true)) {
if (player->getPathTo(walkToPos, listDir, 0, 1, true, true, PLAYER_SEARCHDIST)) {
g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk, this, player->getID(), std::move(listDir))));

SchedulerTask* task = createSchedulerTask(RANGE_USE_ITEM_EX_INTERVAL, std::bind(&Game::playerUseItemEx, this,
Expand Down Expand Up @@ -2054,7 +2054,7 @@ void Game::playerUseItem(uint32_t playerId, const Position& pos, uint8_t stackPo
if (ret != RETURNVALUE_NOERROR) {
if (ret == RETURNVALUE_TOOFARAWAY) {
std::vector<Direction> listDir;
if (player->getPathTo(pos, listDir, 0, 1, true, true)) {
if (player->getPathTo(position, listDir, 0, 1, true, true, PLAYER_SEARCHDIST)) {
g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk,
this, player->getID(), std::move(listDir))));

Expand Down Expand Up @@ -2149,7 +2149,7 @@ void Game::playerUseWithCreature(uint32_t playerId, const Position& fromPos, uin
}

std::vector<Direction> listDir;
if (player->getPathTo(walkToPos, listDir, 0, 1, true, true)) {
if (player->getPathTo(walkToPos, listDir, 0, 1, true, true, PLAYER_SEARCHDIST)) {
g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk,
this, player->getID(), std::move(listDir))));

Expand Down Expand Up @@ -2249,7 +2249,7 @@ void Game::playerRotateItem(uint32_t playerId, const Position& pos, uint8_t stac

if (pos.x != 0xFFFF && !Position::areInRange<1, 1, 0>(pos, player->getPosition())) {
std::vector<Direction> listDir;
if (player->getPathTo(pos, listDir, 0, 1, true, true)) {
if (player->getPathTo(position, listDir, 0, 1, true, true, PLAYER_SEARCHDIST)) {
g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk,
this, player->getID(), std::move(listDir))));

Expand Down Expand Up @@ -2519,7 +2519,7 @@ void Game::playerRequestTrade(uint32_t playerId, const Position& pos, uint8_t st

if (!Position::areInRange<1, 1>(tradeItemPosition, playerPosition)) {
std::vector<Direction> listDir;
if (player->getPathTo(pos, listDir, 0, 1, true, true)) {
if (player->getPathTo(position, listDir, 0, 1, true, true, PLAYER_SEARCHDIST)) {
g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk,
this, player->getID(), std::move(listDir))));

Expand Down
2 changes: 2 additions & 0 deletions src/player.h
Expand Up @@ -100,6 +100,8 @@ using MuteCountMap = std::map<uint32_t, uint32_t>;
static constexpr int32_t PLAYER_MAX_SPEED = 1500;
static constexpr int32_t PLAYER_MIN_SPEED = 10;

static constexpr int32_t PLAYER_SEARCHDIST = 9;

class Player final : public Creature, public Cylinder
{
public:
Expand Down

0 comments on commit b73d122

Please sign in to comment.