summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-11-24 22:47:33 +0300
committerAndrei Karas <akaras@inbox.ru>2015-11-24 22:47:33 +0300
commitba2ad8131522e3bba0570580fdee3d5f3e0b7ffa (patch)
tree654ad26eb4212105ee64c9bd51e334eb05a22c2e
parent1d1ac3f13f96f0fa69fc57ea61af6e59d4e910a9 (diff)
downloadplus-ba2ad8131522e3bba0570580fdee3d5f3e0b7ffa.tar.gz
plus-ba2ad8131522e3bba0570580fdee3d5f3e0b7ffa.tar.bz2
plus-ba2ad8131522e3bba0570580fdee3d5f3e0b7ffa.tar.xz
plus-ba2ad8131522e3bba0570580fdee3d5f3e0b7ffa.zip
Add support for spirit balls effect.
-rw-r--r--src/being/being.cpp51
-rw-r--r--src/being/being.h9
-rw-r--r--src/defaults.cpp2
3 files changed, 60 insertions, 2 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 58fb9b2b7..ae0491372 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -200,6 +200,7 @@ Being::Being(const BeingId id,
mHorseInfo(nullptr),
mDownHorseSprites(),
mUpHorseSprites(),
+ mSpiritParticles(),
#endif
mX(0),
mY(0),
@@ -340,6 +341,9 @@ Being::~Being()
mPets.clear();
removeAllItemsParticles();
+#ifdef EATHENA_SUPPORT
+ mSpiritParticles.clear();
+#endif
}
void Being::createSpeechBubble()
@@ -4244,4 +4248,51 @@ void Being::setTrickDead(const bool b)
}
}
+void Being::setSpiritBalls(const unsigned int balls)
+{
+ if (!Particle::enabled)
+ {
+ mSpiritBalls = balls;
+ return;
+ }
+
+ if (balls > mSpiritBalls)
+ {
+ const int effectId = paths.getIntValue("spiritEffectId");
+ if (effectId != -1)
+ addSpiritBalls(balls - mSpiritBalls, effectId);
+ }
+ else if (balls < mSpiritBalls)
+ {
+ removeSpiritBalls(mSpiritBalls - balls);
+ }
+ mSpiritBalls = balls;
+}
+
+void Being::addSpiritBalls(const unsigned int balls,
+ const int effectId)
+{
+ if (!effectManager)
+ return;
+ for (unsigned int f = 0; f < balls; f ++)
+ {
+ Particle *const particle = effectManager->triggerReturn(
+ effectId,
+ this);
+ mSpiritParticles.push_back(particle);
+ }
+}
+
+void Being::removeSpiritBalls(const unsigned int balls)
+{
+ if (!particleEngine)
+ return;
+ for (unsigned int f = 0; f < balls && !mSpiritParticles.empty(); f ++)
+ {
+ Particle *const particle = mSpiritParticles.back();
+ mChildParticleEffects.removeLocally(particle);
+ mSpiritParticles.pop_back();
+ }
+}
+
#endif
diff --git a/src/being/being.h b/src/being/being.h
index 10e1b8482..bab1cc254 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -921,8 +921,7 @@ class Being notfinal : public ActorSprite,
std::string getBuyBoard() const A_WARN_UNUSED
{ return mBuyBoard; }
- void setSpiritBalls(const unsigned int balls)
- { mSpiritBalls = balls; }
+ void setSpiritBalls(const unsigned int balls);
unsigned int getSpiritBalls() const A_WARN_UNUSED
{ return mSpiritBalls; }
@@ -1081,6 +1080,11 @@ class Being notfinal : public ActorSprite,
std::vector<int> &slotRemap,
const int val);
+ void addSpiritBalls(const unsigned int balls,
+ const int effectId);
+
+ void removeSpiritBalls(const unsigned int balls);
+
void dumpSprites() const;
const ActorTypeT mType;
@@ -1112,6 +1116,7 @@ class Being notfinal : public ActorSprite,
HorseInfo *mHorseInfo;
std::vector<AnimatedSprite*> mDownHorseSprites;
std::vector<AnimatedSprite*> mUpHorseSprites;
+ std::vector<Particle*> mSpiritParticles;
#endif
int mX; // position in tiles
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 38573de9d..45cec23a8 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -523,6 +523,8 @@ DefaultsData* getPathsDefaults()
AddDEF("skillHitEffectId", -1);
AddDEF("skillMissEffectId", -1);
+ AddDEF("spiritEffectId", -1);
+
AddDEF("minimaps", "graphics/minimaps/");
AddDEF("maps", "maps/");
AddDEF("sfx", "sfx/");