Implement dash walking and zoom out again
This commit is contained in:
parent
2a225b99b7
commit
d0576da69d
|
@ -12,6 +12,11 @@ Panel
|
||||||
!text: tr('Enable smart walking')
|
!text: tr('Enable smart walking')
|
||||||
!tooltip: tr('Will detect when to use diagonal step based on the\nkeys you are pressing')
|
!tooltip: tr('Will detect when to use diagonal step based on the\nkeys you are pressing')
|
||||||
|
|
||||||
|
OptionCheckBox
|
||||||
|
id: dashWalk
|
||||||
|
!text: tr('Enable dash walking')
|
||||||
|
!tooltip: tr('Will boost your walk on high speed characters')
|
||||||
|
|
||||||
OptionCheckBox
|
OptionCheckBox
|
||||||
id: showPing
|
id: showPing
|
||||||
!text: tr('Show connection ping')
|
!text: tr('Show connection ping')
|
||||||
|
|
|
@ -5,6 +5,7 @@ local defaultOptions = {
|
||||||
fullscreen = false,
|
fullscreen = false,
|
||||||
classicControl = false,
|
classicControl = false,
|
||||||
smartWalk = false,
|
smartWalk = false,
|
||||||
|
dashWalk = false,
|
||||||
autoChaseOverride = true,
|
autoChaseOverride = true,
|
||||||
showStatusMessagesInConsole = true,
|
showStatusMessagesInConsole = true,
|
||||||
showEventMessagesInConsole = true,
|
showEventMessagesInConsole = true,
|
||||||
|
|
|
@ -15,14 +15,13 @@ limitZoom = false
|
||||||
currentViewMode = 0
|
currentViewMode = 0
|
||||||
smartWalkDirs = {}
|
smartWalkDirs = {}
|
||||||
smartWalkDir = nil
|
smartWalkDir = nil
|
||||||
walkFunction = g_game.walk
|
walkFunction = nil
|
||||||
|
|
||||||
function init()
|
function init()
|
||||||
g_ui.importStyle('styles/countwindow')
|
g_ui.importStyle('styles/countwindow')
|
||||||
|
|
||||||
connect(g_game, {
|
connect(g_game, {
|
||||||
onGameStart = onGameStart,
|
onGameStart = onGameStart,
|
||||||
onGMActions = onGMActions,
|
|
||||||
onGameEnd = onGameEnd,
|
onGameEnd = onGameEnd,
|
||||||
onLoginAdvice = onLoginAdvice,
|
onLoginAdvice = onLoginAdvice,
|
||||||
}, true)
|
}, true)
|
||||||
|
@ -119,7 +118,6 @@ function terminate()
|
||||||
|
|
||||||
disconnect(g_game, {
|
disconnect(g_game, {
|
||||||
onGameStart = onGameStart,
|
onGameStart = onGameStart,
|
||||||
onGMActions = onGMActions,
|
|
||||||
onGameEnd = onGameEnd,
|
onGameEnd = onGameEnd,
|
||||||
onLoginAdvice = onLoginAdvice
|
onLoginAdvice = onLoginAdvice
|
||||||
})
|
})
|
||||||
|
@ -139,6 +137,16 @@ function onGameStart()
|
||||||
else
|
else
|
||||||
g_game.disableFeature(GameForceFirstAutoWalkStep)
|
g_game.disableFeature(GameForceFirstAutoWalkStep)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
addEvent(function()
|
||||||
|
if not limitZoom or g_game.isGM() then
|
||||||
|
gameMapPanel:setMaxZoomOut(513)
|
||||||
|
gameMapPanel:setLimitVisibleRange(false)
|
||||||
|
else
|
||||||
|
gameMapPanel:setMaxZoomOut(11)
|
||||||
|
gameMapPanel:setLimitVisibleRange(true)
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function onGameEnd()
|
function onGameEnd()
|
||||||
|
@ -152,8 +160,6 @@ function show()
|
||||||
gameRootPanel:show()
|
gameRootPanel:show()
|
||||||
gameRootPanel:focus()
|
gameRootPanel:focus()
|
||||||
gameMapPanel:followCreature(g_game.getLocalPlayer())
|
gameMapPanel:followCreature(g_game.getLocalPlayer())
|
||||||
gameMapPanel:setMaxZoomOut(11)
|
|
||||||
gameMapPanel:setLimitVisibleRange(true)
|
|
||||||
setupViewMode(0)
|
setupViewMode(0)
|
||||||
updateStretchShrink()
|
updateStretchShrink()
|
||||||
logoutButton:setTooltip(tr('Logout'))
|
logoutButton:setTooltip(tr('Logout'))
|
||||||
|
@ -199,6 +205,7 @@ function onLoginAdvice(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
function forceExit()
|
function forceExit()
|
||||||
|
g_game.cancelLogin()
|
||||||
scheduleEvent(exit, 10)
|
scheduleEvent(exit, 10)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -284,11 +291,16 @@ end
|
||||||
|
|
||||||
function smartWalk(dir)
|
function smartWalk(dir)
|
||||||
if g_keyboard.getModifiers() == KeyboardNoModifier then
|
if g_keyboard.getModifiers() == KeyboardNoModifier then
|
||||||
if smartWalkDir then
|
local func = walkFunction
|
||||||
walkFunction(smartWalkDir)
|
if not func then
|
||||||
|
if modules.client_options.getOption('dashWalk') then
|
||||||
|
func = g_game.dashWalk
|
||||||
else
|
else
|
||||||
walkFunction(dir)
|
func = g_game.walk
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
local dire = smartWalkDir or dir
|
||||||
|
func(dire)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
|
@ -760,9 +772,3 @@ end
|
||||||
function limitZoom()
|
function limitZoom()
|
||||||
limitZoom = true
|
limitZoom = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function onGMActions()
|
|
||||||
if not limitZoom then return end
|
|
||||||
gameMapPanel:setMaxZoomOut(513)
|
|
||||||
gameMapPanel:setLimitVisibleRange(false)
|
|
||||||
end
|
|
||||||
|
|
|
@ -50,6 +50,10 @@ function terminate()
|
||||||
onGameEnd = offline,
|
onGameEnd = offline,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
disconnect(LocalPlayer, {
|
||||||
|
onPositionChange = updateCameraPosition
|
||||||
|
})
|
||||||
|
|
||||||
local gameRootPanel = modules.game_interface.getRootPanel()
|
local gameRootPanel = modules.game_interface.getRootPanel()
|
||||||
g_keyboard.unbindKeyPress('Alt+Left', gameRootPanel)
|
g_keyboard.unbindKeyPress('Alt+Left', gameRootPanel)
|
||||||
g_keyboard.unbindKeyPress('Alt+Right', gameRootPanel)
|
g_keyboard.unbindKeyPress('Alt+Right', gameRootPanel)
|
||||||
|
|
|
@ -782,7 +782,7 @@ Point Creature::getDrawOffset()
|
||||||
return drawOffset;
|
return drawOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Creature::getStepDuration(bool ignoreDiagonal)
|
int Creature::getStepDuration(bool ignoreDiagonal, Otc::Direction dir)
|
||||||
{
|
{
|
||||||
int speed = m_speed;
|
int speed = m_speed;
|
||||||
if(speed < 1)
|
if(speed < 1)
|
||||||
|
@ -792,7 +792,13 @@ int Creature::getStepDuration(bool ignoreDiagonal)
|
||||||
speed *= 2;
|
speed *= 2;
|
||||||
|
|
||||||
int groundSpeed = 0;
|
int groundSpeed = 0;
|
||||||
Position tilePos = m_lastStepToPosition;
|
Position tilePos;
|
||||||
|
|
||||||
|
if(dir == Otc::InvalidDirection)
|
||||||
|
tilePos = m_lastStepToPosition;
|
||||||
|
else
|
||||||
|
tilePos = m_position.translatedToDirection(dir);
|
||||||
|
|
||||||
if(!tilePos.isValid())
|
if(!tilePos.isValid())
|
||||||
tilePos = m_position;
|
tilePos = m_position;
|
||||||
const TilePtr& tile = g_map.getTile(tilePos);
|
const TilePtr& tile = g_map.getTile(tilePos);
|
||||||
|
|
|
@ -85,7 +85,7 @@ public:
|
||||||
uint8 getEmblem() { return m_emblem; }
|
uint8 getEmblem() { return m_emblem; }
|
||||||
bool isPassable() { return m_passable; }
|
bool isPassable() { return m_passable; }
|
||||||
Point getDrawOffset();
|
Point getDrawOffset();
|
||||||
int getStepDuration(bool ignoreDiagonal = false);
|
int getStepDuration(bool ignoreDiagonal = false, Otc::Direction dir = Otc::InvalidDirection);
|
||||||
Point getWalkOffset() { return m_walkOffset; }
|
Point getWalkOffset() { return m_walkOffset; }
|
||||||
Position getLastStepFromPosition() { return m_lastStepFromPosition; }
|
Position getLastStepFromPosition() { return m_lastStepFromPosition; }
|
||||||
Position getLastStepToPosition() { return m_lastStepToPosition; }
|
Position getLastStepToPosition() { return m_lastStepToPosition; }
|
||||||
|
|
|
@ -613,6 +613,70 @@ bool Game::walk(Otc::Direction direction)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Game::dashWalk(Otc::Direction direction)
|
||||||
|
{
|
||||||
|
if(!canPerformGameAction())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// must cancel follow before any new walk
|
||||||
|
if(isFollowing())
|
||||||
|
cancelFollow();
|
||||||
|
|
||||||
|
// must cancel auto walking
|
||||||
|
if(m_localPlayer->isAutoWalking()) {
|
||||||
|
m_protocolGame->sendStop();
|
||||||
|
m_localPlayer->stopAutoWalk();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_localPlayer->isWalking() && m_dashTimer.ticksElapsed() < std::max<int>(m_localPlayer->getStepDuration(false, direction) - m_ping, 30))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Position toPos = m_localPlayer->getPosition().translatedToDirection(direction);
|
||||||
|
TilePtr toTile = g_map.getTile(toPos);
|
||||||
|
// only do prewalks to walkable tiles (like grounds and not walls)
|
||||||
|
if(toTile && toTile->isWalkable()) {
|
||||||
|
if(!m_localPlayer->isWalking() && m_localPlayer->getWalkTicksElapsed() >= m_localPlayer->getStepDuration() + 100)
|
||||||
|
m_localPlayer->preWalk(direction);
|
||||||
|
// check walk to another floor (e.g: when above 3 parcels)
|
||||||
|
} else {
|
||||||
|
// check if can walk to a lower floor
|
||||||
|
auto canChangeFloorDown = [&]() -> bool {
|
||||||
|
Position pos = toPos;
|
||||||
|
if(!pos.down())
|
||||||
|
return false;
|
||||||
|
TilePtr toTile = g_map.getTile(pos);
|
||||||
|
if(toTile && toTile->hasElevation(3))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
// check if can walk to a higher floor
|
||||||
|
auto canChangeFloorUp = [&]() -> bool {
|
||||||
|
TilePtr fromTile = m_localPlayer->getTile();
|
||||||
|
if(!fromTile || !fromTile->hasElevation(3))
|
||||||
|
return false;
|
||||||
|
Position pos = toPos;
|
||||||
|
if(!pos.up())
|
||||||
|
return false;
|
||||||
|
TilePtr toTile = g_map.getTile(pos);
|
||||||
|
if(!toTile || !toTile->isWalkable())
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
if(canChangeFloorDown() || canChangeFloorUp() ||
|
||||||
|
(!toTile || toTile->isEmpty())) {
|
||||||
|
m_localPlayer->lockWalk();
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
forceWalk(direction);
|
||||||
|
m_dashTimer.restart();
|
||||||
|
m_lastWalkDir = direction;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Game::autoWalk(std::vector<Otc::Direction> dirs)
|
void Game::autoWalk(std::vector<Otc::Direction> dirs)
|
||||||
{
|
{
|
||||||
if(!canPerformGameAction())
|
if(!canPerformGameAction())
|
||||||
|
|
|
@ -143,6 +143,7 @@ public:
|
||||||
|
|
||||||
// walk related
|
// walk related
|
||||||
bool walk(Otc::Direction direction);
|
bool walk(Otc::Direction direction);
|
||||||
|
bool dashWalk(Otc::Direction direction);
|
||||||
void autoWalk(std::vector<Otc::Direction> dirs);
|
void autoWalk(std::vector<Otc::Direction> dirs);
|
||||||
void forceWalk(Otc::Direction direction);
|
void forceWalk(Otc::Direction direction);
|
||||||
void turn(Otc::Direction direction);
|
void turn(Otc::Direction direction);
|
||||||
|
@ -325,6 +326,7 @@ private:
|
||||||
uint m_pingSent;
|
uint m_pingSent;
|
||||||
uint m_pingReceived;
|
uint m_pingReceived;
|
||||||
stdext::timer m_pingTimer;
|
stdext::timer m_pingTimer;
|
||||||
|
Timer m_dashTimer;
|
||||||
uint m_seq;
|
uint m_seq;
|
||||||
int m_pingDelay;
|
int m_pingDelay;
|
||||||
Otc::FightModes m_fightMode;
|
Otc::FightModes m_fightMode;
|
||||||
|
|
|
@ -149,6 +149,7 @@ void Client::registerLuaFunctions()
|
||||||
g_lua.bindSingletonFunction("g_game", "forceLogout", &Game::forceLogout, &g_game);
|
g_lua.bindSingletonFunction("g_game", "forceLogout", &Game::forceLogout, &g_game);
|
||||||
g_lua.bindSingletonFunction("g_game", "safeLogout", &Game::safeLogout, &g_game);
|
g_lua.bindSingletonFunction("g_game", "safeLogout", &Game::safeLogout, &g_game);
|
||||||
g_lua.bindSingletonFunction("g_game", "walk", &Game::walk, &g_game);
|
g_lua.bindSingletonFunction("g_game", "walk", &Game::walk, &g_game);
|
||||||
|
g_lua.bindSingletonFunction("g_game", "dashWalk", &Game::dashWalk, &g_game);
|
||||||
g_lua.bindSingletonFunction("g_game", "autoWalk", &Game::autoWalk, &g_game);
|
g_lua.bindSingletonFunction("g_game", "autoWalk", &Game::autoWalk, &g_game);
|
||||||
g_lua.bindSingletonFunction("g_game", "forceWalk", &Game::forceWalk, &g_game);
|
g_lua.bindSingletonFunction("g_game", "forceWalk", &Game::forceWalk, &g_game);
|
||||||
g_lua.bindSingletonFunction("g_game", "turn", &Game::turn, &g_game);
|
g_lua.bindSingletonFunction("g_game", "turn", &Game::turn, &g_game);
|
||||||
|
|
Loading…
Reference in New Issue