autowalk improvement, but still needs to be reworked

master
Eduardo Bart 12 years ago
parent d49cad31e2
commit 05d6e8c3e1

@ -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

@ -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<std::tuple<int, std::string>>& 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<Otc::Direction>());
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<Otc::Direction>(1, direction));
m_autoWalking = false;
return;
}
if(!m_localPlayer->canWalk(direction))
return;
@ -459,6 +472,11 @@ void Game::autoWalk(const std::vector<Otc::Direction>& 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<Otc::Direction>& dirs)
cancelFollow();
m_protocolGame->sendAutoWalk(dirs);
m_autoWalking = true;
}
void Game::stopAutoWalk()
{
if(!canPerformGameAction())
return;
m_protocolGame->sendAutoWalk(std::vector<Otc::Direction>());
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)

@ -129,6 +129,7 @@ public:
// walk related
void walk(Otc::Direction direction);
void autoWalk(const std::vector<Otc::Direction>& 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;

@ -98,6 +98,7 @@ void OTClient::init(const std::vector<std::string>& args)
g_modules.ensureModuleLoaded("game");
// addons 1000-9999
g_modules.autoLoadModules(9999);
g_map.load();
// load otclientrc.lua
if(g_resources.fileExists("/otclientrc.lua")) {

Loading…
Cancel
Save