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); }
void LocalPlayer::onAppear() { Creature::onAppear(); // on teleports lock the walk if(!m_oldPosition.isInRange(m_position,1,1)) lockWalk(); }
void LocalPlayer::setHealth(double health, double maxHealth) { if(m_health != health || m_maxHealth != maxHealth) { double oldHealth = m_health; double oldMaxHealth = m_maxHealth; m_health = health; m_maxHealth = maxHealth; callLuaField("onHealthChange", health, maxHealth, oldHealth, oldMaxHealth); // cannot walk while dying if(health == 0) { if(isPreWalking()) stopWalk(); lockWalk(); } } }