summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-11-15 17:04:31 +0300
committerAndrei Karas <akaras@inbox.ru>2015-11-15 17:04:31 +0300
commit0977134ffdad9ea0e79106fc633ebafd18209765 (patch)
treec0c21f68e7e40002ff9de01302d19ffb5e6783e7
parent679454f53aa95317f8a1d7a1698c743d98a02fad (diff)
downloadplus-0977134ffdad9ea0e79106fc633ebafd18209765.tar.gz
plus-0977134ffdad9ea0e79106fc633ebafd18209765.tar.bz2
plus-0977134ffdad9ea0e79106fc633ebafd18209765.tar.xz
plus-0977134ffdad9ea0e79106fc633ebafd18209765.zip
Add support for different per skill casting animations.
-rw-r--r--src/being/being.cpp26
-rw-r--r--src/being/being.h4
-rw-r--r--src/gui/widgets/skillinfo.cpp4
-rw-r--r--src/gui/widgets/skillinfo.h4
-rw-r--r--src/gui/windows/skilldialog.cpp9
5 files changed, 45 insertions, 2 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 5a4da79fc..31b0ddcc9 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -1342,6 +1342,24 @@ std::string Being::getAttackAction(const Attack *const attack1) const
return attack1->mAction;
}
+std::string Being::getCastAction(const SkillInfo *const skill) const
+{
+ if (!skill)
+ return getCastAction();
+
+ if (mHorseId != 0)
+ return skill->castingRideAction;
+ if (mMap)
+ {
+ const unsigned char mask = mMap->getBlockMask(mX, mY);
+ if (mask & BlockMask::AIR)
+ return skill->castingSkyAction;
+ else if (mask & BlockMask::WATER)
+ return skill->castingWaterAction;
+ }
+ return skill->castingAction;
+}
+
#define getSpriteAction(func, action) \
std::string Being::get##func##Action() const \
{ \
@@ -1359,9 +1377,9 @@ std::string Being::getAttackAction(const Attack *const attack1) const
}
getSpriteAction(Attack, ATTACK)
+getSpriteAction(Cast, CAST)
getSpriteAction(Dead, DEAD)
getSpriteAction(Spawn, SPAWN)
-getSpriteAction(Cast, CAST)
std::string Being::getStandAction() const
{
@@ -1447,7 +1465,11 @@ void Being::setAction(const BeingActionT &action, const int attackId)
}
break;
case BeingAction::CAST:
- currentAction = getCastAction();
+ if (skillDialog)
+ {
+ const SkillInfo *const info = skillDialog->getSkill(attackId);
+ currentAction = getCastAction(info);
+ }
break;
case BeingAction::HURT:
if (mInfo)
diff --git a/src/being/being.h b/src/being/being.h
index a31f39be5..461a8626f 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -68,6 +68,7 @@ class Text;
struct ChatObject;
struct HorseInfo;
+struct SkillInfo;
struct ParticleInfo;
extern volatile int cur_time;
@@ -599,6 +600,9 @@ class Being notfinal : public ActorSprite,
std::string getCastAction() const A_WARN_UNUSED;
+ std::string getCastAction(const SkillInfo *const skill) const
+ A_WARN_UNUSED;
+
std::string getMoveAction() const A_WARN_UNUSED;
std::string getDeadAction() const A_WARN_UNUSED;
diff --git a/src/gui/widgets/skillinfo.cpp b/src/gui/widgets/skillinfo.cpp
index 5e64103a9..2047ea31c 100644
--- a/src/gui/widgets/skillinfo.cpp
+++ b/src/gui/widgets/skillinfo.cpp
@@ -38,6 +38,10 @@ SkillInfo::SkillInfo() :
skillEffect(),
useButton(),
errorText(),
+ castingAction(),
+ castingRideAction(),
+ castingSkyAction(),
+ castingWaterAction(),
dataMap(),
model(nullptr),
data(nullptr),
diff --git a/src/gui/widgets/skillinfo.h b/src/gui/widgets/skillinfo.h
index 7b8faa7e4..95099db2c 100644
--- a/src/gui/widgets/skillinfo.h
+++ b/src/gui/widgets/skillinfo.h
@@ -49,6 +49,10 @@ struct SkillInfo final
std::string skillEffect;
std::string useButton;
std::string errorText;
+ std::string castingAction;
+ std::string castingRideAction;
+ std::string castingSkyAction;
+ std::string castingWaterAction;
SkillDataMap dataMap;
SkillModel *model;
SkillData *data;
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index 60eb32b64..7a46cf313 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -52,6 +52,7 @@
#include "utils/timer.h"
#include "resources/beingcommon.h"
+#include "resources/spriteaction.h"
#include "debug.h"
@@ -339,6 +340,14 @@ void SkillDialog::loadXmlFile(const std::string &fileName)
node, "castingSrcEffectId", -1);
skill->castingDstEffectId = XML::getProperty(
node, "castingDstEffectId", -1);
+ skill->castingAction = XML::getProperty(node,
+ "castingAction", SpriteAction::CAST);
+ skill->castingRideAction = XML::getProperty(node,
+ "castingRideAction", SpriteAction::CASTRIDE);
+ skill->castingSkyAction = XML::getProperty(node,
+ "castingSkyAction", SpriteAction::CASTSKY);
+ skill->castingWaterAction = XML::getProperty(node,
+ "castingWaterAction", SpriteAction::CASTWATER);
skill->useTextParameter = XML::getBoolProperty(
node, "useTextParameter", false);
skill->visible = skill->alwaysVisible;