diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-07-17 22:03:36 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-07-17 22:03:36 +0300 |
commit | 1ce5e20594dbf44d6311d217cdba3b217491fc0b (patch) | |
tree | 982c0042f9d50c48c9a3bceecbbc2682922af3e6 | |
parent | eed4e612309c788565eda120fa2ad30de50ca19e (diff) | |
download | manaplus-1ce5e20594dbf44d6311d217cdba3b217491fc0b.tar.gz manaplus-1ce5e20594dbf44d6311d217cdba3b217491fc0b.tar.bz2 manaplus-1ce5e20594dbf44d6311d217cdba3b217491fc0b.tar.xz manaplus-1ce5e20594dbf44d6311d217cdba3b217491fc0b.zip |
Freeze plater while casting skill.
-rw-r--r-- | src/being/localplayer.cpp | 25 | ||||
-rw-r--r-- | src/being/localplayer.h | 4 | ||||
-rw-r--r-- | src/net/eathena/beingrecv.cpp | 9 |
3 files changed, 33 insertions, 5 deletions
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; +} diff --git a/src/being/localplayer.h b/src/being/localplayer.h index 08974a621..b09e63828 100644 --- a/src/being/localplayer.h +++ b/src/being/localplayer.h @@ -423,6 +423,8 @@ class LocalPlayer final : public Being, bool canMove() const; + void freezeMoving(const int timeWaitTicks); + protected: void updateCoords() override final; @@ -493,6 +495,7 @@ class LocalPlayer final : public Being, int mTestParticleTime; unsigned long mTestParticleHash; int mSyncPlayerMoveDistance; + int mUnfreezeTime; unsigned char mWalkingDir; // The direction the player is walking in. /** Whether or not the name settings have changed */ bool mUpdateName; @@ -519,6 +522,7 @@ class LocalPlayer final : public Being, bool mWaitPing; bool mShowNavigePath; bool mAllowRename; + bool mFreezed; }; extern LocalPlayer *localPlayer; diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp index 3087824d5..af5edc74d 100644 --- a/src/net/eathena/beingrecv.cpp +++ b/src/net/eathena/beingrecv.cpp @@ -30,6 +30,8 @@ #include "being/mercenaryinfo.h" +#include "const/utils/timer.h" + #include "enums/resources/notifytypes.h" #include "particle/particleengine.h" @@ -961,9 +963,9 @@ void BeingRecv::processSkillCastingContinue(Net::MessageIn &msg, UNIMPLIMENTEDPACKETFIELD(0); return; } - else if (dstId != BeingId_zero) + Being *const srcBeing = actorManager->findBeing(srcId); + if (dstId != BeingId_zero) { // being to being - Being *const srcBeing = actorManager->findBeing(srcId); Being *const dstBeing = actorManager->findBeing(dstId); if (srcBeing) srcBeing->setAction(BeingAction::CAST, skillId); @@ -972,13 +974,14 @@ void BeingRecv::processSkillCastingContinue(Net::MessageIn &msg, } else if (dstX != 0 || dstY != 0) { // being to position - Being *const srcBeing = actorManager->findBeing(srcId); if (srcBeing) srcBeing->setAction(BeingAction::CAST, skillId); skillDialog->playCastingDstTileEffect(skillId, dstX, dstY, castTime); } + if (srcBeing == localPlayer) + localPlayer->freezeMoving(castTime / MILLISECONDS_IN_A_TICK); } void BeingRecv::processBeingStatusChange(Net::MessageIn &msg) |