summaryrefslogtreecommitdiff
path: root/src/being.h
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-05-17 19:16:11 -0600
committerJared Adams <jaxad0127@gmail.com>2010-05-17 21:49:16 -0600
commit3b4e7795c9ab3036988a1a7dfe6f5ed2ad12199d (patch)
treeed0e8cc5b608c31ac79e6d1de03d9ddfc74fa339 /src/being.h
parent51945aa1af6f2a6dc15027ef40cf0ccf424d46e1 (diff)
downloadMana-3b4e7795c9ab3036988a1a7dfe6f5ed2ad12199d.tar.gz
Mana-3b4e7795c9ab3036988a1a7dfe6f5ed2ad12199d.tar.bz2
Mana-3b4e7795c9ab3036988a1a7dfe6f5ed2ad12199d.tar.xz
Mana-3b4e7795c9ab3036988a1a7dfe6f5ed2ad12199d.zip
Remove Monster, Player, and NPC classes
Instead of having these three subclasses with minor differences, this commit merges them back into Being. In the future, we can make Beings that are talkable to some, attackable by others, etc. This also puts back support for monster equipment. Also changes remaining references to Being::Type and the constants to refer to ActorSprite::Type. Reviewed-by: Freeyorp
Diffstat (limited to 'src/being.h')
-rw-r--r--src/being.h165
1 files changed, 142 insertions, 23 deletions
diff --git a/src/being.h b/src/being.h
index 95f8c802..76b50dec 100644
--- a/src/being.h
+++ b/src/being.h
@@ -29,12 +29,11 @@
#include "position.h"
#include "vector.h"
-#include "resources/spritedef.h"
-
#include <guichan/color.hpp>
#include <SDL_types.h>
+#include <map>
#include <set>
#include <string>
#include <vector>
@@ -45,14 +44,24 @@
#define SPEECH_TIME 500
#define SPEECH_MAX_TIME 1000
+class BeingInfo;
class FlashText;
+class Guild;
class ItemInfo;
class Item;
class Particle;
+class Party;
class Position;
class SpeechBubble;
class Text;
+enum Gender
+{
+ GENDER_MALE = 0,
+ GENDER_FEMALE = 1,
+ GENDER_UNSPECIFIED = 2
+};
+
class Being : public ActorSprite, public ConfigListener
{
public:
@@ -100,10 +109,12 @@ class Being : public ActorSprite, public ConfigListener
* @param subtype partly determines the type of the being
* @param map the map the being is on
*/
- Being(int id, int subtype, Map *map);
+ Being(int id, Type type, int subtype, Map *map);
virtual ~Being();
+ Type getType() const { return mType; }
+
/**
* Removes all path nodes from this being.
*/
@@ -188,7 +199,7 @@ class Being : public ActorSprite, public ConfigListener
* @param damage the amount of damage recieved (0 means miss)
* @param type the attack type
*/
- virtual void takeDamage(Being *attacker, int damage, AttackType type);
+ void takeDamage(Being *attacker, int damage, AttackType type);
/**
* Handles an attack of another being by this being.
@@ -210,23 +221,82 @@ class Being : public ActorSprite, public ConfigListener
*
* @param name The name that should appear.
*/
- virtual void setName(const std::string &name);
+ void setName(const std::string &name);
bool getShowName() const
{ return mShowName; }
- virtual void setShowName(bool doShowName);
+ void setShowName(bool doShowName);
/**
- * Following are set from the server (mainly for players)
+ * Sets the name of the party the being is in. Shown in BeingPopup.
*/
void setPartyName(const std::string &name) { mPartyName = name; }
const std::string &getPartyName() const { return mPartyName; }
- virtual void setGuildName(const std::string &name);
+ /**
+ * Sets the name of the primary guild the being is in. Shown in
+ * BeingPopup (eventually).
+ */
+ void setGuildName(const std::string &name);
+
+ void setGuildPos(const std::string &pos);
+
+ /**
+ * Adds a guild to the being.
+ */
+ void addGuild(Guild *guild);
+
+ /**
+ * Removers a guild from the being.
+ */
+ void removeGuild(int id);
+
+ /**
+ * Returns a pointer to the specified guild that the being is in.
+ */
+ Guild *getGuild(const std::string &guildName) const;
+
+ /**
+ * Returns a pointer to the specified guild that the being is in.
+ */
+ Guild *getGuild(int id) const;
+
+ /**
+ * Returns all guilds the being is in.
+ */
+ const std::map<int, Guild*> &getGuilds() const
+ { return mGuilds; }
+
+ /**
+ * Removes all guilds the being is in.
+ */
+ void clearGuilds();
+
+ /**
+ * Get number of guilds the being belongs to.
+ */
+ short getNumberOfGuilds() const
+ { return mGuilds.size(); }
+
+ bool isInParty() const
+ { return mParty != NULL; }
+
+ void setParty(Party *party);
+
+ Party *getParty() const
+ { return mParty; }
+
+ /**
+ * Sets visible equipments for this being.
+ */
+ void setSprite(unsigned int slot, int id,
+ const std::string &color = "", bool isWeapon = false);
+
+ void setSpriteID(unsigned int slot, int id);
- virtual void setGuildPos(const std::string &pos);
+ void setSpriteColor(unsigned int slot, const std::string &color = "");
/**
* Get the number of hairstyles implemented
@@ -254,15 +324,27 @@ class Being : public ActorSprite, public ConfigListener
*/
void drawEmotion(Graphics *graphics, int offsetX, int offsetY);
- /**
- * Return Being's current Job (player job, npc, monster, creature )
- */
Uint16 getSubType() const { return mSubType; }
/**
- * Set Being's current Job (player job, npc, monster, creature )
+ * Set Being's subtype (mostly for view for monsters and NPCs)
*/
- virtual void setSubtype(Uint16 subtype) { mSubType = subtype; }
+ void setSubtype(Uint16 subtype);
+
+ const BeingInfo *getInfo() const
+ { return mInfo; }
+
+ TargetCursorSize getTargetCursorSize() const;
+
+ /**
+ * Gets the way the object is blocked by other objects.
+ */
+ unsigned char getWalkMask() const;
+
+ /**
+ * Gets the way the monster blocks pathfinding for other objects
+ */
+ Map::BlockType getBlockType() const;
/**
* Sets the walk speed.
@@ -364,12 +446,6 @@ class Being : public ActorSprite, public ConfigListener
void fireMissile(Being *target, const std::string &particle);
/**
- * Gets the way the object is blocked by other objects.
- */
- virtual unsigned char getWalkMask() const
- { return 0x00; } //can walk through everything
-
- /**
* Returns the path this being is following. An empty path is returned
* when this being isn't following any path currently.
*/
@@ -394,7 +470,7 @@ class Being : public ActorSprite, public ConfigListener
static void load();
- virtual void optionChanged(const std::string &value) {}
+ virtual void optionChanged(const std::string &value);
void flashName(int time);
@@ -403,6 +479,31 @@ class Being : public ActorSprite, public ConfigListener
void updateName();
+ /**
+ * Sets the gender of this being.
+ */
+ virtual void setGender(Gender gender);
+
+ Gender getGender() const
+ { return mGender; }
+
+ /**
+ * Whether or not this player is a GM.
+ */
+ bool isGM() const
+ { return mIsGM; }
+
+ /**
+ * Triggers whether or not to show the name as a GM name.
+ */
+ void setGM(bool gm);
+
+ bool canTalk();
+
+ void talkTo();
+
+ static bool isTalking();
+
protected:
/**
* Sets the new path for this being.
@@ -412,9 +513,13 @@ class Being : public ActorSprite, public ConfigListener
/**
* Updates name's location.
*/
- virtual void updateCoords();
+ void updateCoords();
+
+ void showName();
- virtual void showName();
+ void updateColors();
+
+ BeingInfo *mInfo;
/** The current sprite Frame number to be displayed */
int mFrame;
@@ -429,7 +534,9 @@ class Being : public ActorSprite, public ConfigListener
/** Time until the last speech sentence disappears */
int mSpeechTime;
+ int mAttackType;
int mAttackSpeed; /**< Attack speed */
+
Action mAction; /**< Action the being is performing */
Uint16 mSubType; /**< Subtype (graphical view, basically) */
@@ -457,6 +564,16 @@ class Being : public ActorSprite, public ConfigListener
Vector mDest; /**< destination coordinates. */
+ std::vector<int> mSpriteIDs;
+ std::vector<std::string> mSpriteColors;
+ Gender mGender;
+
+ // Character guild information
+ std::map<int, Guild*> mGuilds;
+ Party *mParty;
+
+ bool mIsGM;
+
private:
/**
@@ -466,6 +583,8 @@ class Being : public ActorSprite, public ConfigListener
*/
int getOffset(char pos, char neg) const;
+ const Type mType;
+
/** Speech Bubble components */
SpeechBubble *mSpeechBubble;