From 1ce5e20594dbf44d6311d217cdba3b217491fc0b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 17 Jul 2016 22:03:36 +0300 Subject: Freeze plater while casting skill. --- src/being/localplayer.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/being/localplayer.cpp') diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 97845ae31..01e4466bf 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -158,6 +158,7 @@ LocalPlayer::LocalPlayer(const BeingId id, mTestParticleTime(0), mTestParticleHash(0L), mSyncPlayerMoveDistance(config.getBoolValue("syncPlayerMoveDistance")), + mUnfreezeTime(0), mWalkingDir(0), mUpdateName(true), mBlockAdvert(false), @@ -179,7 +180,8 @@ LocalPlayer::LocalPlayer(const BeingId id, mPathSetByMouse(false), mWaitPing(false), mShowNavigePath(false), - mAllowRename(false) + mAllowRename(false), + mFreezed(false) { logger->log1("LocalPlayer::LocalPlayer"); @@ -251,6 +253,13 @@ void LocalPlayer::logic() if (mActivityTime == 0 || mLastAction != -1) mActivityTime = cur_time; + if (mUnfreezeTime > 0 && + mUnfreezeTime <= tick_time) + { + mUnfreezeTime = 0; + mFreezed = false; + } + if ((mAction != BeingAction::MOVE || mNextStep) && !mNavigatePath.empty()) { mNextStep = false; @@ -2714,7 +2723,19 @@ void LocalPlayer::playerDeath() bool LocalPlayer::canMove() const { - return mAction != BeingAction::DEAD && + return !mFreezed && + mAction != BeingAction::DEAD && (serverFeatures->haveMoveWhileSit() || mAction != BeingAction::SIT); } + +void LocalPlayer::freezeMoving(const int timeWaitTicks) +{ + if (timeWaitTicks <= 0) + return; + const int nextTime = tick_time + timeWaitTicks; + if (mUnfreezeTime < nextTime) + mUnfreezeTime = nextTime; + if (mUnfreezeTime > 0) + mFreezed = true; +} -- cgit v1.2.3-60-g2f50