Fixed up movement controls again and fixed a typo.

* You can change direction while already moving
(There could be a better way for walking control, but this works fine for now)
This commit is contained in:
BeniS
2013-01-23 20:31:28 +13:00
parent caf86a9fc6
commit a2ddb472f5
7 changed files with 29 additions and 15 deletions

View File

@@ -318,7 +318,6 @@ void Creature::walk(const Position& oldPos, const Position& newPos)
m_walkFinishAnimEvent = nullptr;
}
// no direction need to be changed when the walk ends
m_walkTurnDirection = Otc::InvalidDirection;

View File

@@ -538,8 +538,7 @@ bool Game::walk(Otc::Direction direction)
if(m_lastWalkDir != direction) {
// must add a new walk event
float ticks = m_localPlayer->getStepTicksLeft();
if(ticks < 0)
ticks = 0;
if(ticks < 0) { ticks = 0; }
if(m_walkEvent) {
m_walkEvent->cancel();

View File

@@ -293,6 +293,7 @@ public:
std::string getWorldName() { return m_worldName; }
std::vector<uint8> getGMActions() { return m_gmActions; }
bool isGM() { return m_gmActions.size() > 0; }
Otc::Direction getLastWalkDir() { return m_lastWalkDir; }
std::string formatCreatureName(const std::string &name);
int findEmptyContainerId();

View File

@@ -95,7 +95,7 @@ void LocalPlayer::walk(const Position& oldPos, const Position& newPos)
// a prewalk was going on
if(m_preWalking) {
if(m_waitingWalkPong) {
if(newPos == m_lastPrewalkDestionation)
if(newPos == m_lastPrewalkDestination)
m_lastWalkPing = m_walkPingTimer.ticksElapsed();
m_waitingWalkPong = false;
@@ -105,7 +105,7 @@ void LocalPlayer::walk(const Position& oldPos, const Position& newPos)
m_preWalking = false;
m_lastPrewalkDone = true;
// if is to the last prewalk destination, updates the walk preserving the animation
if(newPos == m_lastPrewalkDestionation) {
if(newPos == m_lastPrewalkDestination) {
updateWalk();
// was to another direction, replace the walk
} else
@@ -127,7 +127,7 @@ void LocalPlayer::preWalk(Otc::Direction direction)
Position newPos = m_position.translatedToDirection(direction);
// avoid reanimating prewalks
if(m_preWalking && m_lastPrewalkDestionation == newPos)
if(m_preWalking && m_lastPrewalkDestination == newPos)
return;
m_waitingWalkPong = false;
@@ -143,7 +143,7 @@ void LocalPlayer::preWalk(Otc::Direction direction)
// start walking to direction
m_lastPrewalkDone = false;
m_lastPrewalkDestionation = newPos;
m_lastPrewalkDestination = newPos;
Creature::walk(m_position, newPos);
}
@@ -233,7 +233,7 @@ void LocalPlayer::stopWalk()
Creature::stopWalk(); // will call terminateWalk
m_lastPrewalkDone = true;
m_lastPrewalkDestionation = Position();
m_lastPrewalkDestination = Position();
}
void LocalPlayer::updateWalkOffset(int totalPixelsWalked)

View File

@@ -119,7 +119,7 @@ protected:
private:
// walk related
Timer m_walkPingTimer;
Position m_lastPrewalkDestionation;
Position m_lastPrewalkDestination;
Position m_autoWalkDestination;
Position m_lastAutoWalkPosition;
ScheduledEventPtr m_autoWalkEndEvent;

View File

@@ -242,6 +242,7 @@ void Client::registerLuaFunctions()
g_lua.bindSingletonFunction("g_game", "disableFeature", &Game::disableFeature, &g_game);
g_lua.bindSingletonFunction("g_game", "isGM", &Game::isGM, &g_game);
g_lua.bindSingletonFunction("g_game", "answerModalDialog", &Game::answerModalDialog, &g_game);
g_lua.bindSingletonFunction("g_game", "getLastWalkDir", &Game::getLastWalkDir, &g_game);
g_lua.registerSingletonClass("g_shaders");
g_lua.bindSingletonFunction("g_shaders", "createShader", &ShaderManager::createShader, &g_shaders);