summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/being/being.cpp74
-rw-r--r--src/being/being.h11
-rw-r--r--src/net/eathena/beingrecv.cpp5
-rw-r--r--src/net/eathena/beingrecv.h1
4 files changed, 75 insertions, 16 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 73e088fe7..6bb166dc2 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -154,6 +154,7 @@ Being::Being(const BeingId id,
mInfo(BeingInfo::unknown),
mEmotionSprite(nullptr),
mAnimationEffect(nullptr),
+ mCastingEffect(nullptr),
mBadges(),
mSpriteAction(SpriteAction::STAND),
mName(),
@@ -244,9 +245,11 @@ Being::Being(const BeingId id,
mManner(0),
mAreaSize(11),
mCastEndTime(0),
- mCastX1(0),
- mCastSize(0),
- mCastY1(0),
+ mCastRectX(0),
+ mCastRectSize(0),
+ mCastRectY(0),
+ mCastAnimationX(0),
+ mCastAnimationY(0),
#ifdef EATHENA_SUPPORT
mCreatorId(BeingId_zero),
#endif
@@ -336,6 +339,7 @@ Being::~Being()
delete2(mText);
delete2(mEmotionSprite);
delete2(mAnimationEffect);
+ delete2(mCastingEffect);
mBadgesCount = 0;
#ifdef EATHENA_SUPPORT
delete2(mChat);
@@ -1592,6 +1596,8 @@ void Being::setAction(const BeingActionT &restrict action,
mEmotionSprite->play(currentAction);
if (mAnimationEffect)
mAnimationEffect->play(currentAction);
+ if (mCastingEffect)
+ mCastingEffect->play(currentAction);
for_each_badges()
{
AnimatedSprite *const sprite = mBadges[f];
@@ -1663,6 +1669,8 @@ void Being::setDirection(const uint8_t direction) restrict2
mEmotionSprite->setSpriteDirection(dir);
if (mAnimationEffect)
mAnimationEffect->setSpriteDirection(dir);
+ if (mCastingEffect)
+ mCastingEffect->setSpriteDirection(dir);
for_each_badges()
{
@@ -1793,6 +1801,7 @@ void Being::logic() restrict2
{
mCastEndTime = 0;
mDrawCast = false;
+ delete2(mCastingEffect);
}
if (mAnimationEffect)
@@ -1801,6 +1810,12 @@ void Being::logic() restrict2
if (mAnimationEffect->isTerminated())
delete2(mAnimationEffect)
}
+ if (mCastingEffect)
+ {
+ mCastingEffect->update(time);
+ if (mCastingEffect->isTerminated())
+ delete2(mCastingEffect)
+ }
for_each_badges()
{
AnimatedSprite *restrict const sprite = mBadges[f];
@@ -3511,10 +3526,17 @@ void Being::drawCasting(Graphics *const graphics,
UserColorId::ATTACK_RANGE_BORDER));
graphics->drawRectangle(Rect(
- mCastX1 + offsetX,
- mCastY1 + offsetY,
- mCastSize,
- mCastSize));
+ mCastRectX + offsetX,
+ mCastRectY + offsetY,
+ mCastRectSize,
+ mCastRectSize));
+
+ if (mCastingEffect)
+ {
+ mCastingEffect->draw(graphics,
+ mCastAnimationX + offsetX,
+ mCastAnimationY + offsetY);
+ }
}
void Being::drawBeingCursor(Graphics *const graphics,
@@ -5032,8 +5054,9 @@ void Being::serverRemove() restrict2 noexcept2
void Being::addCast(const int dstX,
const int dstY,
- const int skillId A_UNUSED,
- const int range A_UNUSED,
+ const int skillId,
+ const int skillLevel,
+ const int range,
const int waitTimeTicks)
{
if (waitTimeTicks <= 0)
@@ -5044,9 +5067,36 @@ void Being::addCast(const int dstX,
}
mCastEndTime = tick_time + waitTimeTicks;
mDrawCast = true;
- mCastX1 = (dstX - range) * mapTileSize;
- mCastY1 = (dstY - range) * mapTileSize;
- mCastSize = range * mapTileSize * 2 + mapTileSize;
+ mCastRectX = (dstX - range) * mapTileSize;
+ mCastRectY = (dstY - range) * mapTileSize;
+ mCastRectSize = range * mapTileSize * 2 + mapTileSize;
+ SkillData *const data = skillDialog->getSkillDataByLevel(
+ skillId,
+ skillLevel);
+ delete2(mCastingEffect);
+ if (data)
+ {
+ const std::string castingAnimation = data->castingAnimation;
+ if (!castingAnimation.empty())
+ {
+ mCastingEffect = AnimatedSprite::load(
+ paths.getStringValue("sprites") + castingAnimation);
+ if (mCastingEffect)
+ {
+ mCastAnimationX = mCastRectX +
+ (mCastRectSize - mCastingEffect->getWidth()) / 2;
+ mCastAnimationY = mCastRectY +
+ (mCastRectSize - mCastingEffect->getHeight()) / 2;
+ }
+ else
+ {
+ reportAlways("Skill %d/%d casting animation '%s' load failed",
+ skillId,
+ skillLevel,
+ castingAnimation.c_str());
+ }
+ }
+ }
}
#ifdef EATHENA_SUPPORT
diff --git a/src/being/being.h b/src/being/being.h
index 810044956..3ee2c5ed1 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -1041,6 +1041,7 @@ class Being notfinal : public ActorSprite,
void addCast(const int dstX,
const int dstY,
const int skillId,
+ const int skillLevel,
const int range,
const int waitTimeTicks);
@@ -1090,6 +1091,7 @@ class Being notfinal : public ActorSprite,
BeingInfo *restrict mInfo;
AnimatedSprite *restrict mEmotionSprite;
AnimatedSprite *restrict mAnimationEffect;
+ AnimatedSprite *restrict mCastingEffect;
AnimatedSprite *restrict mBadges[BadgeIndex::BadgeIndexSize];
std::string mSpriteAction;
@@ -1266,10 +1268,11 @@ class Being notfinal : public ActorSprite,
int mManner;
int mAreaSize;
int mCastEndTime;
- int mCastX1;
- int mCastSize;
- int mCastY1;
- int mCastHeight;
+ int mCastRectX;
+ int mCastRectSize;
+ int mCastRectY;
+ int mCastAnimationX;
+ int mCastAnimationY;
#ifdef EATHENA_SUPPORT
BeingId mCreatorId;
#endif
diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp
index 3970913f5..16004ac82 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,
+ 1,
0,
castTime);
}
@@ -937,6 +938,7 @@ void BeingRecv::processSkillCasting2(Net::MessageIn &msg)
const int dstX = msg.readInt16("dst x");
const int dstY = msg.readInt16("dst y");
const int skillId = msg.readInt16("skill id");
+ const int skillLevel = msg.readInt16("skill level");
msg.readInt32("property"); // can be used to trigger effect
const int castTime = msg.readInt32("cast time");
const int range = msg.readInt32("skill range");
@@ -945,6 +947,7 @@ void BeingRecv::processSkillCasting2(Net::MessageIn &msg)
srcId, dstId,
dstX, dstY,
skillId,
+ skillLevel,
range,
castTime);
}
@@ -955,6 +958,7 @@ void BeingRecv::processSkillCastingContinue(Net::MessageIn &msg,
const int dstX,
const int dstY,
const int skillId,
+ const int skillLevel,
const int range,
const int castTime)
{
@@ -984,6 +988,7 @@ void BeingRecv::processSkillCastingContinue(Net::MessageIn &msg,
castTime);
srcBeing->addCast(dstX, dstY,
skillId,
+ skillLevel,
range,
castTime / MILLISECONDS_IN_A_TICK);
}
diff --git a/src/net/eathena/beingrecv.h b/src/net/eathena/beingrecv.h
index 317cfc3be..a8044a175 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 skillLevel,
const int range,
const int castTime);
} // namespace BeingRecv