diff options
-rw-r--r-- | src/being.cpp | 16 | ||||
-rw-r--r-- | src/being.h | 1 | ||||
-rw-r--r-- | src/statuseffect.cpp | 6 |
3 files changed, 19 insertions, 4 deletions
diff --git a/src/being.cpp b/src/being.cpp index 2be72360..68b1a791 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -78,7 +78,8 @@ Being::Being(int id, int job, Map *map): mSpriteIDs(VECTOREND_SPRITE, 0), mSpriteColors(VECTOREND_SPRITE, ""), mStatusParticleEffects(&mStunParticleEffects, false), - mChildParticleEffects(&mStatusParticleEffects, false) + mChildParticleEffects(&mStatusParticleEffects, false), + mMustResetParticles(false) { setMap(map); @@ -216,6 +217,7 @@ void Being::setMap(Map *map) // Clear particle effect list because child particles became invalid mChildParticleEffects.clear(); + mMustResetParticles = true; // Reset status particles on next redraw } void Being::controlParticle(Particle *particle) @@ -390,9 +392,21 @@ void Being::logic() } } + // Restart status/particle effects, if needed + if (mMustResetParticles) { + mMustResetParticles = false; + for (std::set<int>::iterator it = mStatusEffects.begin(); + it != mStatusEffects.end(); it++) { + const StatusEffect *effect = StatusEffect::getStatusEffect(*it, true); + if (effect && effect->particleEffectIsPersistent()) + updateStatusEffect(*it, true); + } + } + // Update particle effects mChildParticleEffects.setPositions((float) mPx + 16.0f, (float) mPy + 32.0f); + } void Being::draw(Graphics *graphics, int offsetX, int offsetY) const diff --git a/src/being.h b/src/being.h index de558f83..d7f78753 100644 --- a/src/being.h +++ b/src/being.h @@ -460,6 +460,7 @@ class Being : public Sprite static int instances; /**< Number of Being instances */ static ImageSet *emotionSet; /**< Emoticons used by beings */ + bool mMustResetParticles; /**< Reset particle status effects on next redraw? */ }; #endif diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index 8aeb66c6..6397f615 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -30,7 +30,8 @@ #define STATUS_EFFECTS_FILE "status-effects.xml" -StatusEffect::StatusEffect() +StatusEffect::StatusEffect() : + mPersistentParticleEffect(false) {} StatusEffect::~StatusEffect() @@ -156,13 +157,12 @@ void StatusEffect::load() startEffect->mParticleEffect = XML::getProperty(node, "start-particle", ""); startEffect->mIcon = XML::getProperty(node, "icon", ""); startEffect->mAction = XML::getProperty(node, "action", ""); + startEffect->mPersistentParticleEffect = (XML::getProperty(node, "persistent-particle-effect", "no")) != "no"; endEffect->mMessage = XML::getProperty(node, "end-message", ""); endEffect->mSFXEffect = XML::getProperty(node, "end-audio", ""); endEffect->mParticleEffect = XML::getProperty(node, "end-particle", ""); - endEffect->mPersistentParticleEffect = (XML::getProperty(node, "persistent-particle-effect", "no")) != "no"; - (*the_map)[1][index] = startEffect; (*the_map)[0][index] = endEffect; } |