diff --git a/TODO b/TODO index d138757a..bb08df7c 100644 --- a/TODO +++ b/TODO @@ -48,6 +48,7 @@ handle corrupt errors in dat/spr throw exceptions when fail to read a file fix C++ exceptions messages inside onExtendedOpcode rework outfit masks drawing +complete rework on autowalk * framework rework Settings/g_configs diff --git a/src/otclient/core/game.cpp b/src/otclient/core/game.cpp index ff5fdac2..33e07e41 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/core/game.cpp @@ -49,6 +49,7 @@ void Game::resetGameStates() m_denyBotCall = false; #endif m_dead = false; + m_autoWalking = false; m_serverBeat = 50; m_canReportBugs = false; m_fightMode = Otc::FightBalanced; @@ -254,8 +255,9 @@ void Game::processCreatureTeleport(const CreaturePtr& creature) creature->stopWalk(); // locks the walk for a while when teleporting - if(creature == m_localPlayer) + if(creature == m_localPlayer) { m_localPlayer->lockWalk(); + } } void Game::processChannelList(const std::vector>& channelList) @@ -393,6 +395,11 @@ void Game::processAttackCancel() void Game::processWalkCancel(Otc::Direction direction) { m_localPlayer->cancelWalk(direction); + + if(m_autoWalking) { + m_protocolGame->sendAutoWalk(std::vector()); + m_autoWalking = false; + } } void Game::loginWorld(const std::string& account, const std::string& password, const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName) @@ -441,6 +448,12 @@ void Game::walk(Otc::Direction direction) if(isFollowing()) cancelFollow(); + if(m_autoWalking) { + m_protocolGame->sendAutoWalk(std::vector(1, direction)); + m_autoWalking = false; + return; + } + if(!m_localPlayer->canWalk(direction)) return; @@ -459,6 +472,11 @@ void Game::autoWalk(const std::vector& dirs) if(!canPerformGameAction()) return; + if(dirs.size() == 1 && !m_autoWalking) { + walk(dirs.front()); + return; + } + if(dirs.size() > 255) return; @@ -466,6 +484,16 @@ void Game::autoWalk(const std::vector& dirs) cancelFollow(); m_protocolGame->sendAutoWalk(dirs); + m_autoWalking = true; +} + +void Game::stopAutoWalk() +{ + if(!canPerformGameAction()) + return; + + m_protocolGame->sendAutoWalk(std::vector()); + m_autoWalking = false; } void Game::forceWalk(Otc::Direction direction) @@ -535,6 +563,7 @@ void Game::stop() cancelFollow(); m_protocolGame->sendStop(); + m_autoWalking = false; } void Game::look(const ThingPtr& thing) diff --git a/src/otclient/core/game.h b/src/otclient/core/game.h index 23d626fb..2a246fcf 100644 --- a/src/otclient/core/game.h +++ b/src/otclient/core/game.h @@ -129,6 +129,7 @@ public: // walk related void walk(Otc::Direction direction); void autoWalk(const std::vector& dirs); + void stopAutoWalk(); void forceWalk(Otc::Direction direction); void turn(Otc::Direction direction); void stop(); @@ -277,6 +278,7 @@ private: bool m_denyBotCall; bool m_dead; + bool m_autoWalking; int m_serverBeat; Otc::FightModes m_fightMode; Otc::ChaseModes m_chaseMode; diff --git a/src/otclient/otclient.cpp b/src/otclient/otclient.cpp index ebe2536a..6a9962ea 100644 --- a/src/otclient/otclient.cpp +++ b/src/otclient/otclient.cpp @@ -98,6 +98,7 @@ void OTClient::init(const std::vector& args) g_modules.ensureModuleLoaded("game"); // addons 1000-9999 g_modules.autoLoadModules(9999); + g_map.load(); // load otclientrc.lua if(g_resources.fileExists("/otclientrc.lua")) {