summaryrefslogtreecommitdiff
path: root/src/being.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/being.h')
-rw-r--r--src/being.h117
1 files changed, 88 insertions, 29 deletions
diff --git a/src/being.h b/src/being.h
index 7d5ed989..3c3a9b73 100644
--- a/src/being.h
+++ b/src/being.h
@@ -22,34 +22,44 @@
#ifndef BEING_H
#define BEING_H
-#include <list>
-#include <memory>
-#include <string>
+#include <guichan/color.hpp>
+
#include <SDL_types.h>
+
#include <set>
+#include <string>
+#include <vector>
+#include "particlecontainer.h"
#include "position.h"
#include "sprite.h"
-#include "map.h"
-#include "animatedsprite.h"
-#include "particlecontainer.h"
+
+#include "resources/spritedef.h"
#define FIRST_IGNORE_EMOTE 14
#define STATUS_EFFECTS 32
+#define SPEECH_TIME 500
+#define SPEECH_MAX_TIME 1000
+
class AnimatedSprite;
-class Equipment;
+class Image;
class ItemInfo;
class Item;
class Map;
class Graphics;
-class ImageSet;
class Particle;
+class Position;
+class SpeechBubble;
class Text;
class StatusEffect;
-enum Gender {
+typedef std::list<Sprite*> Sprites;
+typedef Sprites::iterator SpriteIterator;
+
+enum Gender
+{
GENDER_MALE = 0,
GENDER_FEMALE = 1,
GENDER_UNSPECIFIED = 2
@@ -58,7 +68,8 @@ enum Gender {
class Being : public Sprite
{
public:
- enum Type {
+ enum Type
+ {
UNKNOWN,
PLAYER,
NPC,
@@ -68,7 +79,8 @@ class Being : public Sprite
/**
* Action the being is currently performing.
*/
- enum Action {
+ enum Action
+ {
STAND,
WALK,
ATTACK,
@@ -77,7 +89,8 @@ class Being : public Sprite
HURT
};
- enum Sprite {
+ enum Sprite
+ {
BASE_SPRITE = 0,
SHOE_SPRITE,
BOTTOMCLOTHES_SPRITE,
@@ -93,7 +106,8 @@ class Being : public Sprite
VECTOREND_SPRITE
};
- enum TargetCursorSize {
+ enum TargetCursorSize
+ {
TC_SMALL = 0,
TC_MEDIUM,
TC_LARGE,
@@ -107,13 +121,13 @@ class Being : public Sprite
Uint16 mJob; /**< Job (player job, npc, monster, ) */
Uint16 mX, mY; /**< Tile coordinates */
- Uint8 mAction; /**< Action the being is performing */
- Uint8 mFrame;
+ Action mAction; /**< Action the being is performing */
+ Uint16 mFrame;
Uint16 mWalkTime;
Uint8 mEmotion; /**< Currently showing emotion */
Uint8 mEmotionTime; /**< Time until emotion disappears */
- Uint16 mAttackSpeed; /**< Attack speed */
+ Uint16 mAttackSpeed; /**< Attack speed */
/**
* Constructor.
@@ -142,7 +156,7 @@ class Being : public Sprite
* @param text The text that should appear.
* @param time The amount of time the text should stay in milliseconds.
*/
- void setSpeech(const std::string &text, Uint32 time);
+ void setSpeech(const std::string &text, Uint32 time = 500);
/**
* Puts a damage bubble above this being.
@@ -152,6 +166,11 @@ class Being : public Sprite
virtual void takeDamage(int amount);
/**
+ * Puts a crit notification bubble above this being.
+ */
+ virtual void showCrit();
+
+ /**
* Handles an attack of another being by this being.
*
* @param victim The attacked being.
@@ -186,6 +205,11 @@ class Being : public Sprite
{ return mHairStyle; }
/**
+ * Get the number of hairstyles implemented
+ */
+ static int getNumOfHairstyles() { return mNumberOfHairstyles; }
+
+ /**
* Sets the hair style and color for this being.
*/
virtual void setHairStyle(int style, int color);
@@ -211,11 +235,24 @@ class Being : public Sprite
virtual void nextStep();
/**
+ * Triggers whether or not to show the name as a GM name.
+ * NOTE: This doesn't mean that just anyone can use this.
+ * If the server doesn't acknowlege you, you won't be shown
+ * as a GM on other people's clients.
+ */
+ virtual void setGM() { mIsGM = true; }
+
+ /**
* Performs being logic.
*/
virtual void logic();
/**
+ * Draws the speech text above the being.
+ */
+ void drawSpeech(int offsetX, int offsetY);
+
+ /**
* Draws the emotion picture above the being.
*/
void drawEmotion(Graphics *graphics, int offsetX, int offsetY);
@@ -253,7 +290,7 @@ class Being : public Sprite
/**
* Sets the current action.
*/
- virtual void setAction(Uint8 action);
+ virtual void setAction(Action action);
/**
* Returns the current direction.
@@ -266,6 +303,16 @@ class Being : public Sprite
void setDirection(Uint8 direction);
/**
+ * Gets the current action.
+ */
+ int getWalkTime() { return mWalkTime; }
+
+ /**
+ * Returns the direction the being is facing.
+ */
+ SpriteDirection getSpriteDirection() const;
+
+ /**
* Draws this being to the given graphics context.
*
* @see Sprite::draw(Graphics, int, int)
@@ -317,6 +364,8 @@ class Being : public Sprite
*/
void controlParticle(Particle *particle);
+ AnimatedSprite* getEmote(int index) { return emotionSet[index]; }
+
void setEmote(Uint8 emotion, Uint8 emote_time)
{
mEmotion = emotion;
@@ -356,8 +405,8 @@ class Being : public Sprite
internalTriggerEffect(effectId, false, true);
}
- const std::auto_ptr<Equipment> mEquipment;
-
+ // Target cursor being used by the being
+ Image *mTargetCursor;
static int getHairColorsNr();
@@ -365,6 +414,9 @@ class Being : public Sprite
static std::string getHairColor(int index);
+ virtual AnimatedSprite* getSprite(int index) const
+ { return mSprites[index]; }
+
protected:
/**
* Sets the new path for this being.
@@ -377,11 +429,6 @@ class Being : public Sprite
virtual void updateCoords() {}
/**
- * Returns the sprite direction of this being.
- */
- SpriteDirection getSpriteDirection() const;
-
- /**
* Trigger visual effect, with components
*
* \param effectId ID of the effect to trigger
@@ -416,12 +463,17 @@ class Being : public Sprite
Map *mMap; /**< Map on which this being resides */
std::string mName; /**< Name of character */
SpriteIterator mSpriteIterator;
+ bool mIsGM;
+ bool mParticleEffects; /**< Whether to display particles or not */
/** Engine-related infos about weapon. */
const ItemInfo* mEquippedWeapon;
+ static int mNumberOfHairstyles; /** Number of hair styles in use */
+
Path mPath;
- Text *mSpeech;
+ std::string mSpeech;
+ Text *mText;
Uint16 mHairStyle, mHairColor;
Gender mGender;
Uint32 mSpeechTime;
@@ -429,6 +481,8 @@ class Being : public Sprite
Uint16 mStunMode; /**< Stun mode; zero if not stunned */
std::set<int> mStatusEffects; /**< set of active status effects */
+ gcn::Color mNameColor;
+
std::vector<AnimatedSprite*> mSprites;
std::vector<int> mSpriteIDs;
std::vector<std::string> mSpriteColors;
@@ -443,9 +497,14 @@ class Being : public Sprite
*/
int getOffset(char pos, char neg) const;
- static int instances; /**< Number of Being instances */
- static ImageSet *emotionSet; /**< Emoticons used by beings */
- bool mMustResetParticles; /**< Reset particle status effects on next redraw? */
+ /** Reset particle status effects on next redraw? */
+ bool mMustResetParticles;
+
+ // Speech Bubble components
+ SpeechBubble *mSpeechBubble;
+
+ static int instances; /**< Number of Being instances */
+ static std::vector<AnimatedSprite*> emotionSet; /**< Emoticons used by beings */
};
#endif