summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-07-18 15:27:19 +0300
committerAndrei Karas <akaras@inbox.ru>2016-07-18 15:27:19 +0300
commit5ec1b3eaa504bc8f9443a340e579e000d4516651 (patch)
tree1273ad4e33941142a23e1b5586a45636e0d06045
parent1ce5e20594dbf44d6311d217cdba3b217491fc0b (diff)
downloadplus-5ec1b3eaa504bc8f9443a340e579e000d4516651.tar.gz
plus-5ec1b3eaa504bc8f9443a340e579e000d4516651.tar.bz2
plus-5ec1b3eaa504bc8f9443a340e579e000d4516651.tar.xz
plus-5ec1b3eaa504bc8f9443a340e579e000d4516651.zip
Highlight skill attack range with border, while casting skill.
-rw-r--r--src/being/being.cpp48
-rw-r--r--src/being/being.h16
-rw-r--r--src/net/eathena/beingrecv.cpp9
-rw-r--r--src/net/eathena/beingrecv.h1
4 files changed, 72 insertions, 2 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 95142fecc..0b52592d4 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -242,6 +242,10 @@ Being::Being(const BeingId id,
mKarma(0),
mManner(0),
mAreaSize(11),
+ mCastEndTime(0),
+ mCastX1(0),
+ mCastSize(0),
+ mCastY1(0),
#ifdef EATHENA_SUPPORT
mCreatorId(BeingId_zero),
#endif
@@ -257,7 +261,8 @@ Being::Being(const BeingId id,
mAway(false),
mInactive(false),
mNeedPosUpdate(true),
- mPetAi(true)
+ mPetAi(true),
+ mDrawCast(false)
{
for (int f = 0; f < 20; f ++)
{
@@ -1783,6 +1788,12 @@ void Being::logic() restrict2
(*it)->update(time);
#endif
+ if (mCastEndTime != 0 && mCastEndTime < tick_time)
+ {
+ mCastEndTime = 0;
+ mDrawCast = false;
+ }
+
if (mAnimationEffect)
{
mAnimationEffect->update(time);
@@ -3486,9 +3497,25 @@ void Being::drawPlayer(Graphics *restrict const graphics,
drawBeingCursor(graphics, px, py);
drawPlayerSpriteAt(graphics, px, py);
#endif
+ if (mDrawCast)
+ drawCasting(graphics, offsetX, offsetY);
}
}
+void Being::drawCasting(Graphics *const graphics,
+ const int offsetX,
+ const int offsetY) const
+{
+ graphics->setColor(userPalette->getColorWithAlpha(
+ UserColorId::ATTACK_RANGE_BORDER));
+
+ graphics->drawRectangle(Rect(
+ mCastX1 + offsetX,
+ mCastY1 + offsetY,
+ mCastSize,
+ mCastSize));
+}
+
void Being::drawBeingCursor(Graphics *const graphics,
const int offsetX,
const int offsetY) const
@@ -5002,6 +5029,25 @@ void Being::serverRemove() restrict2 noexcept2
mTrickDead = false;
}
+void Being::addCast(const int dstX,
+ const int dstY,
+ const int skillId A_UNUSED,
+ const int range A_UNUSED,
+ const int waitTimeTicks)
+{
+ if (waitTimeTicks <= 0)
+ {
+ mCastEndTime = 0;
+ mDrawCast = false;
+ return;
+ }
+ mCastEndTime = tick_time + waitTimeTicks;
+ mDrawCast = true;
+ mCastX1 = (dstX - range) * mapTileSize;
+ mCastY1 = (dstY - range) * mapTileSize;
+ mCastSize = range * mapTileSize * 2 + mapTileSize;
+}
+
#ifdef EATHENA_SUPPORT
void Being::removeHorse() restrict2
{
diff --git a/src/being/being.h b/src/being/being.h
index bf05d091b..810044956 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -1038,6 +1038,12 @@ class Being notfinal : public ActorSprite,
void serverRemove() restrict2 noexcept2;
+ void addCast(const int dstX,
+ const int dstY,
+ const int skillId,
+ const int range,
+ const int waitTimeTicks);
+
protected:
void drawPlayerSpriteAt(Graphics *restrict const graphics,
const int x,
@@ -1170,6 +1176,10 @@ class Being notfinal : public ActorSprite,
const int offsetX,
const int offsetY) const A_NONNULL(2);
+ void drawCasting(Graphics *const graphics,
+ const int offsetX,
+ const int offsetY) const A_NONNULL(2);
+
const ActorTypeT mType;
/** Speech Bubble components */
@@ -1255,6 +1265,11 @@ class Being notfinal : public ActorSprite,
int mKarma;
int mManner;
int mAreaSize;
+ int mCastEndTime;
+ int mCastX1;
+ int mCastSize;
+ int mCastY1;
+ int mCastHeight;
#ifdef EATHENA_SUPPORT
BeingId mCreatorId;
#endif
@@ -1271,6 +1286,7 @@ class Being notfinal : public ActorSprite,
bool mInactive;
bool mNeedPosUpdate;
bool mPetAi;
+ bool mDrawCast;
};
extern std::list<BeingCacheEntry*> beingInfoCache;
diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp
index af5edc74d..3970913f5 100644
--- a/src/net/eathena/beingrecv.cpp
+++ b/src/net/eathena/beingrecv.cpp
@@ -925,6 +925,7 @@ void BeingRecv::processSkillCasting(Net::MessageIn &msg)
srcId, dstId,
dstX, dstY,
skillId,
+ 0,
castTime);
}
@@ -938,12 +939,13 @@ void BeingRecv::processSkillCasting2(Net::MessageIn &msg)
const int skillId = msg.readInt16("skill id");
msg.readInt32("property"); // can be used to trigger effect
const int castTime = msg.readInt32("cast time");
- msg.readInt32("skill range");
+ const int range = msg.readInt32("skill range");
processSkillCastingContinue(msg,
srcId, dstId,
dstX, dstY,
skillId,
+ range,
castTime);
}
@@ -953,6 +955,7 @@ void BeingRecv::processSkillCastingContinue(Net::MessageIn &msg,
const int dstX,
const int dstY,
const int skillId,
+ const int range,
const int castTime)
{
if (!effectManager)
@@ -979,6 +982,10 @@ void BeingRecv::processSkillCastingContinue(Net::MessageIn &msg,
skillDialog->playCastingDstTileEffect(skillId,
dstX, dstY,
castTime);
+ srcBeing->addCast(dstX, dstY,
+ skillId,
+ range,
+ castTime / MILLISECONDS_IN_A_TICK);
}
if (srcBeing == localPlayer)
localPlayer->freezeMoving(castTime / MILLISECONDS_IN_A_TICK);
diff --git a/src/net/eathena/beingrecv.h b/src/net/eathena/beingrecv.h
index 1a005e31f..317cfc3be 100644
--- a/src/net/eathena/beingrecv.h
+++ b/src/net/eathena/beingrecv.h
@@ -124,6 +124,7 @@ namespace EAthena
const int dstX,
const int dstY,
const int skillId,
+ const int range,
const int castTime);
} // namespace BeingRecv
} // namespace EAthena