summaryrefslogtreecommitdiff
path: root/src/being.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/being.h')
-rw-r--r--src/being.h85
1 files changed, 72 insertions, 13 deletions
diff --git a/src/being.h b/src/being.h
index d722092e..3c3a9b73 100644
--- a/src/being.h
+++ b/src/being.h
@@ -26,9 +26,9 @@
#include <SDL_types.h>
+#include <set>
#include <string>
#include <vector>
-#include <bitset>
#include "particlecontainer.h"
#include "position.h"
@@ -53,6 +53,8 @@ class Position;
class SpeechBubble;
class Text;
+class StatusEffect;
+
typedef std::list<Sprite*> Sprites;
typedef Sprites::iterator SpriteIterator;
@@ -112,7 +114,6 @@ class Being : public Sprite
NUM_TC
};
-
/**
* Directions, to be used as bitmask values
*/
@@ -121,7 +122,7 @@ class Being : public Sprite
Uint16 mJob; /**< Job (player job, npc, monster, ) */
Uint16 mX, mY; /**< Tile coordinates */
Action mAction; /**< Action the being is performing */
- Uint16 mFrame;
+ Uint16 mFrame;
Uint16 mWalkTime;
Uint8 mEmotion; /**< Currently showing emotion */
Uint8 mEmotionTime; /**< Time until emotion disappears */
@@ -180,14 +181,16 @@ class Being : public Sprite
/**
* Returns the name of the being.
*/
- const std::string& getName() const { return mName; }
+ const std::string &getName() const
+ { return mName; }
/**
* Sets the name for the being.
*
* @param name The name that should appear.
*/
- virtual void setName(const std::string &name) { mName = name; }
+ virtual void setName(const std::string &name)
+ { mName = name; }
/**
* Gets the hair color for this being.
@@ -331,12 +334,14 @@ class Being : public Sprite
/**
* Get the current X pixel offset.
*/
- int getXOffset() const { return getOffset(LEFT, RIGHT); }
+ int getXOffset() const
+ { return getOffset(LEFT, RIGHT); }
/**
* Get the current Y pixel offset.
*/
- int getYOffset() const { return getOffset(UP, DOWN); }
+ int getYOffset() const
+ { return getOffset(UP, DOWN); }
/**
* Returns the horizontal size of the current base sprite of the being
@@ -367,12 +372,45 @@ class Being : public Sprite
mEmotionTime = emote_time;
}
+ /**
+ * Sets the being's stun mode. If zero, the being is `normal',
+ * otherwise it is `stunned' in some fashion.
+ */
+ void setStunMode(int stunMode)
+ {
+ if (mStunMode != stunMode)
+ updateStunMode(mStunMode, stunMode);
+ mStunMode = stunMode;
+ };
+
+ void setStatusEffect(int index, bool active);
+
+ /**
+ * A status effect block is a 16 bit mask of status effects.
+ * We assign each such flag a block ID of offset + bitnr.
+ *
+ * These are NOT the same as the status effect indices.
+ */
+ void setStatusEffectBlock(int offset, Uint16 flags);
+
+ /**
+ * Triggers a visual effect, such as `level up'
+ *
+ * Only draws the visual effect, does not play sound effects
+ *
+ * \param effectId ID of the effect to trigger
+ */
+ virtual void triggerEffect(int effectId)
+ {
+ internalTriggerEffect(effectId, false, true);
+ }
+
// Target cursor being used by the being
Image *mTargetCursor;
- static int getHairColorsNr(void);
+ static int getHairColorsNr();
- static int getHairStylesNr(void);
+ static int getHairStylesNr();
static std::string getHairColor(int index);
@@ -399,6 +437,26 @@ class Being : public Sprite
*/
void internalTriggerEffect(int effectId, bool sfx, bool gfx);
+ /**
+ * Notify self that the stun mode has been updated. Invoked by
+ * setStunMode if something changed.
+ */
+ virtual void updateStunMode(int oldMode, int newMode);
+
+ /**
+ * Notify self that a status effect has flipped.
+ * The new flag is passed.
+ */
+ virtual void updateStatusEffect(int index, bool newStatus);
+
+ /**
+ * Handle an update to a status or stun effect
+ *
+ * \param The StatusEffect to effect
+ * \param effectId -1 for stun, otherwise the effect index
+ */
+ virtual void handleStatusEffect(StatusEffect *effect, int effectId);
+
Uint32 mId; /**< Unique sprite id */
Uint16 mWalkSpeed; /**< Walking speed */
Uint8 mDirection; /**< Facing direction */
@@ -408,8 +466,6 @@ class Being : public Sprite
bool mIsGM;
bool mParticleEffects; /**< Whether to display particles or not */
- typedef std::bitset<STATUS_EFFECTS> StatusEffects;
-
/** Engine-related infos about weapon. */
const ItemInfo* mEquippedWeapon;
@@ -422,8 +478,8 @@ class Being : public Sprite
Gender mGender;
Uint32 mSpeechTime;
Sint32 mPx, mPy; /**< Pixel coordinates */
- Uint16 mStunMode; /**< Stun mode; zero if not stunned */
- StatusEffects mStatusEffects; /**< Bitset of active status effects */
+ Uint16 mStunMode; /**< Stun mode; zero if not stunned */
+ std::set<int> mStatusEffects; /**< set of active status effects */
gcn::Color mNameColor;
@@ -441,6 +497,9 @@ class Being : public Sprite
*/
int getOffset(char pos, char neg) const;
+ /** Reset particle status effects on next redraw? */
+ bool mMustResetParticles;
+
// Speech Bubble components
SpeechBubble *mSpeechBubble;