Fix silly for 963 and improve walk

master
Eduardo Bart 12 years ago
parent 97e1c9d5a9
commit 9bd983ab51

@ -41,18 +41,18 @@ function init()
end
function bindKeys()
g_keyboard.bindKeyPress('Up', smartWalk, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Right', smartWalk, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Down', smartWalk, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Left', smartWalk, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Numpad8', function() g_game.walk(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Numpad9', function() g_game.walk(NorthEast) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Numpad6', function() g_game.walk(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Numpad3', function() g_game.walk(SouthEast) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Numpad2', function() g_game.walk(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Numpad1', function() g_game.walk(SouthWest) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Numpad4', function() g_game.walk(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Numpad7', function() g_game.walk(NorthWest) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Up', function() smartWalk(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Right', function() smartWalk(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Down', function() smartWalk(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Left', function() smartWalk(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Numpad8', function() smartWalk(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Numpad9', function() smartWalk(NorthEast) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Numpad6', function() smartWalk(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Numpad3', function() smartWalk(SouthEast) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Numpad2', function() smartWalk(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Numpad1', function() smartWalk(SouthWest) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Numpad4', function() smartWalk(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Numpad7', function() smartWalk(NorthWest) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Ctrl+Up', function() g_game.turn(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Ctrl+Right', function() g_game.turn(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
g_keyboard.bindKeyPress('Ctrl+Down', function() g_game.turn(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
@ -152,7 +152,7 @@ function tryLogout()
anchor=AnchorHorizontalCenter}, yesCallback, noCallback)
end
function smartWalk()
function smartWalk(defaultDir)
local dir
if Options.getOption('smartWalk') then
if g_keyboard.isKeyPressed('Up') and g_keyboard.isKeyPressed('Left') then
@ -166,15 +166,7 @@ function smartWalk()
end
end
if not dir then
if g_keyboard.isKeyPressed('Up') then
dir = North
elseif g_keyboard.isKeyPressed('Down') then
dir = South
elseif g_keyboard.isKeyPressed('Left') then
dir = West
elseif g_keyboard.isKeyPressed('Right') then
dir = East
end
dir = defaultDir
end
if Options.getOption('walkBooster') then

@ -467,10 +467,10 @@ void Game::safeLogout()
m_protocolGame->sendLogout();
}
void Game::walk(Otc::Direction direction)
bool Game::walk(Otc::Direction direction)
{
if(!canPerformGameAction())
return;
return false;
// must cancel follow before any new walk
if(isFollowing())
@ -479,11 +479,11 @@ void Game::walk(Otc::Direction direction)
// msut cancel auto walking and wait next try
if(m_localPlayer->isAutoWalking()) {
m_protocolGame->sendStop();
return;
return false;
}
if(!m_localPlayer->canWalk(direction))
return;
return false;
Position toPos = m_localPlayer->getPosition().translatedToDirection(direction);
TilePtr toTile = g_map.getTile(toPos);
@ -521,12 +521,13 @@ void Game::walk(Otc::Direction direction)
(!toTile || toTile->isEmpty())) {
m_localPlayer->lockWalk();
} else
return;
return false;
}
g_lua.callGlobalField("g_game", "onWalk", direction);
forceWalk(direction);
return true;
}
void Game::autoWalk(const std::vector<Otc::Direction>& dirs)
@ -778,9 +779,10 @@ void Game::attack(CreaturePtr creature)
setAttackingCreature(creature);
if(m_clientVersion >= 963)
m_seq = creature->getId();
else
if(m_clientVersion >= 963) {
if(creature)
m_seq = creature->getId();
} else
m_seq++;
m_protocolGame->sendAttack(creature ? creature->getId() : 0, m_seq);
@ -800,9 +802,10 @@ void Game::follow(CreaturePtr creature)
setFollowingCreature(creature);
if(m_clientVersion >= 963)
m_seq = creature->getId();
else
if(m_clientVersion >= 963) {
if(creature)
m_seq = creature->getId();
} else
m_seq++;
m_protocolGame->sendFollow(creature ? creature->getId() : 0, m_seq);

@ -133,7 +133,7 @@ public:
void safeLogout();
// walk related
void walk(Otc::Direction direction);
bool walk(Otc::Direction direction);
void autoWalk(const std::vector<Otc::Direction>& dirs);
void forceWalk(Otc::Direction direction);
void turn(Otc::Direction direction);

Loading…
Cancel
Save