autowalk improvement, but still needs to be reworked

This commit is contained in:
Eduardo Bart 2012-06-03 12:49:48 -03:00
parent d49cad31e2
commit 05d6e8c3e1
4 changed files with 34 additions and 1 deletions

1
TODO
View File

@ -48,6 +48,7 @@ handle corrupt errors in dat/spr
throw exceptions when fail to read a file throw exceptions when fail to read a file
fix C++ exceptions messages inside onExtendedOpcode fix C++ exceptions messages inside onExtendedOpcode
rework outfit masks drawing rework outfit masks drawing
complete rework on autowalk
* framework * framework
rework Settings/g_configs rework Settings/g_configs

View File

@ -49,6 +49,7 @@ void Game::resetGameStates()
m_denyBotCall = false; m_denyBotCall = false;
#endif #endif
m_dead = false; m_dead = false;
m_autoWalking = false;
m_serverBeat = 50; m_serverBeat = 50;
m_canReportBugs = false; m_canReportBugs = false;
m_fightMode = Otc::FightBalanced; m_fightMode = Otc::FightBalanced;
@ -254,8 +255,9 @@ void Game::processCreatureTeleport(const CreaturePtr& creature)
creature->stopWalk(); creature->stopWalk();
// locks the walk for a while when teleporting // locks the walk for a while when teleporting
if(creature == m_localPlayer) if(creature == m_localPlayer) {
m_localPlayer->lockWalk(); m_localPlayer->lockWalk();
}
} }
void Game::processChannelList(const std::vector<std::tuple<int, std::string>>& channelList) 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) void Game::processWalkCancel(Otc::Direction direction)
{ {
m_localPlayer->cancelWalk(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) 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()) if(isFollowing())
cancelFollow(); cancelFollow();
if(m_autoWalking) {
m_protocolGame->sendAutoWalk(std::vector<Otc::Direction>(1, direction));
m_autoWalking = false;
return;
}
if(!m_localPlayer->canWalk(direction)) if(!m_localPlayer->canWalk(direction))
return; return;
@ -459,6 +472,11 @@ void Game::autoWalk(const std::vector<Otc::Direction>& dirs)
if(!canPerformGameAction()) if(!canPerformGameAction())
return; return;
if(dirs.size() == 1 && !m_autoWalking) {
walk(dirs.front());
return;
}
if(dirs.size() > 255) if(dirs.size() > 255)
return; return;
@ -466,6 +484,16 @@ void Game::autoWalk(const std::vector<Otc::Direction>& dirs)
cancelFollow(); cancelFollow();
m_protocolGame->sendAutoWalk(dirs); 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) void Game::forceWalk(Otc::Direction direction)
@ -535,6 +563,7 @@ void Game::stop()
cancelFollow(); cancelFollow();
m_protocolGame->sendStop(); m_protocolGame->sendStop();
m_autoWalking = false;
} }
void Game::look(const ThingPtr& thing) void Game::look(const ThingPtr& thing)

View File

@ -129,6 +129,7 @@ public:
// walk related // walk related
void walk(Otc::Direction direction); void walk(Otc::Direction direction);
void autoWalk(const std::vector<Otc::Direction>& dirs); void autoWalk(const std::vector<Otc::Direction>& dirs);
void stopAutoWalk();
void forceWalk(Otc::Direction direction); void forceWalk(Otc::Direction direction);
void turn(Otc::Direction direction); void turn(Otc::Direction direction);
void stop(); void stop();
@ -277,6 +278,7 @@ private:
bool m_denyBotCall; bool m_denyBotCall;
bool m_dead; bool m_dead;
bool m_autoWalking;
int m_serverBeat; int m_serverBeat;
Otc::FightModes m_fightMode; Otc::FightModes m_fightMode;
Otc::ChaseModes m_chaseMode; Otc::ChaseModes m_chaseMode;

View File

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