Beispiel #1
0
void LocalPlayer::cancelWalk(Otc::Direction direction)
{
    // only cancel client side walks
    if(m_walking && m_preWalking)
        stopWalk();

    m_lastPrewalkDone = true;
    m_idleTimer.restart();
    lockWalk();

    if(m_autoWalkDestination.isValid()) {
        g_game.stop();
        auto self = asLocalPlayer();
        if(m_autoWalkContinueEvent)
            m_autoWalkContinueEvent->cancel();
        m_autoWalkContinueEvent = g_dispatcher.scheduleEvent([self]() {
            if(self->m_autoWalkDestination.isValid())
                self->autoWalk(self->m_autoWalkDestination);
        }, 500);
    }

    // turn to the cancel direction
    if(direction != Otc::InvalidDirection)
        setDirection(direction);

    callLuaField("onCancelWalk", direction);
}
Beispiel #2
0
void LocalPlayer::terminateWalk()
{
    Creature::terminateWalk();
    m_preWalking = false;
    m_idleTimer.restart();

    auto self = asLocalPlayer();

    if(m_autoWalking) {
        if(m_autoWalkEndEvent)
            m_autoWalkEndEvent->cancel();
        m_autoWalkEndEvent = g_dispatcher.scheduleEvent([self] {
            self->m_autoWalking = false;
        }, 100);
    }
}