From 3fcd6a549fc825f4185a6dc248922e02988caed5 Mon Sep 17 00:00:00 2001 From: Fate Date: Sun, 7 Dec 2008 04:00:55 -0700 Subject: Added client-side status change handlers (text, icon, particle effect, audio). --- src/being.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'src/being.cpp') diff --git a/src/being.cpp b/src/being.cpp index 7c6d91e7..5f7ad73f 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -33,6 +33,7 @@ #include "sound.h" #include "localplayer.h" #include "text.h" +#include "statuseffect.h" #include "resources/itemdb.h" #include "resources/resourcemanager.h" @@ -72,6 +73,7 @@ Being::Being(int id, int job, Map *map): mGender(2), mSpeechTime(0), mPx(0), mPy(0), + mStunMode(0), mSprites(VECTOREND_SPRITE, NULL), mSpriteIDs(VECTOREND_SPRITE, 0), mSpriteColors(VECTOREND_SPRITE, ""), @@ -441,6 +443,67 @@ Being::getType() const return UNKNOWN; } +void +Being::setStatusEffectBlock(int offset, Uint16 newEffects) +{ + for (int i = 0; i < STATUS_EFFECTS; i++) { + int index = StatusEffect::blockEffectIndexToEffectIndex(offset + i); + if (index != -1) + setStatusEffect(index, (newEffects & (1 << i)) > 0); + } +} + +void +Being::handleStatusEffect(StatusEffect *effect, int effectId) +{ + if (!effect) + return; + + effect->playSFX(); + + SpriteAction action = effect->getAction(); + if (action != ACTION_INVALID) + setAction(action); + + Particle *particle = effect->getParticle(); + + if (particle) { + if (effectId >= 0) + mStatusParticleEffects.setLocally(effectId, particle); + else { + mStunParticleEffects.clearLocally(); + mStunParticleEffects.addLocally(particle); + } + } +} + +void +Being::updateStunMode(int oldMode, int newMode) +{ + handleStatusEffect(StatusEffect::getStatusEffect(oldMode, false), -1); + handleStatusEffect(StatusEffect::getStatusEffect(newMode, true), -1); +} + +void +Being::updateStatusEffect(int index, bool newStatus) +{ + handleStatusEffect(StatusEffect::getStatusEffect(index, newStatus), index); +} + +void +Being::setStatusEffect(int index, bool active) +{ + const bool wasActive = mStatusEffects.find(index) != mStatusEffects.end(); + + if (active != wasActive) { + updateStatusEffect(index, active); + if (active) + mStatusEffects.insert(index); + else + mStatusEffects.erase(index); + } +} + int Being::getOffset(char pos, char neg) const { -- cgit v1.2.3-70-g09d2