00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _TMWSERV_BEING_H_
00022 #define _TMWSERV_BEING_H_
00023
00024 #include <string>
00025 #include <vector>
00026 #include <list>
00027 #include "limits.h"
00028
00029 #include "defines.h"
00030 #include "game-server/actor.hpp"
00031
00032 class Being;
00033 class MapComposite;
00034 class AttackZone;
00035
00040 enum Direction
00041 {
00042 DIRECTION_UP = 1,
00043 DIRECTION_DOWN,
00044 DIRECTION_LEFT,
00045 DIRECTION_RIGHT
00046 };
00047
00051 enum
00052 {
00053 DAMAGE_PHYSICAL = 0,
00054 DAMAGE_MAGICAL,
00055 DAMAGE_OTHER
00056 };
00057
00062 struct Damage
00063 {
00064 unsigned short base;
00065 unsigned short delta;
00066 unsigned short cth;
00067 unsigned char element;
00068 unsigned char type;
00069 std::list<size_t> usedSkills;
00070 };
00071
00076 struct Attribute
00077 {
00078 unsigned short base;
00079 short mod;
00080 };
00081
00082 struct AttributeModifier
00083 {
00085 unsigned short duration;
00086 short value;
00087 unsigned char attr;
00094 unsigned char level;
00095 };
00096
00097 typedef std::vector< AttributeModifier > AttributeModifiers;
00098
00102 typedef std::vector<unsigned int> Hits;
00103
00108 class Being : public Actor
00109 {
00110 public:
00111
00117 enum Action {
00118 STAND,
00119 WALK,
00120 ATTACK,
00121 SIT,
00122 DEAD,
00123 HURT
00124 };
00125
00129 Being(ThingType type);
00130
00134 virtual void update();
00135
00141 virtual int damage(Actor *source, const Damage &damage);
00142
00146 virtual void died();
00147
00151 virtual void perform() {}
00152
00156 const Point &getDestination() const
00157 { return mDst; }
00158
00162 void setDestination(const Point &dst);
00163
00168 void clearDestination()
00169 { setDestination(getPosition()); }
00170
00174 const Point &getOldPosition() const
00175 { return mOld; }
00176
00180 void setDirection(int direction)
00181 { mDirection = direction; raiseUpdateFlags(UPDATEFLAG_DIRCHANGE); }
00182
00183 int getDirection() const
00184 { return mDirection; }
00185
00190 int getSpeed() const { return mSpeed; }
00191 void setSpeed(int s) { mSpeed = s; }
00192
00196 const Hits &getHitsTaken() const
00197 { return mHitsTaken; }
00198
00202 void clearHitsTaken()
00203 { mHitsTaken.clear(); }
00204
00208 void performAttack(const Damage &, const AttackZone *attackZone);
00209
00213 void setAction(Action action);
00214
00218 Action getAction() const
00219 { return mAction; }
00220
00224 virtual int getAttackType() const
00225 { return 0; }
00226
00230 void move();
00231
00235 void setAttribute(int n, int value)
00236 { mAttributes[n].base = value; }
00237
00241 int getAttribute(int n) const
00242 { return mAttributes[n].base; }
00243
00247 int getModifiedAttribute(int) const;
00248
00256 void applyModifier(int attr, int value, int duration = 0, int lvl = 0);
00257
00261 void dispellModifiers(int level);
00262
00266 virtual void modifiedAttribute(int) {}
00267
00269 const std::string &getName() const
00270 { return mName; }
00271
00273 void setName(const std::string &name)
00274 { mName = name; }
00275
00279 static int directionToAngle(int direction);
00280
00281 protected:
00282 static const int TICKS_PER_HP_REGENERATION = 100;
00283 Action mAction;
00284 std::vector< Attribute > mAttributes;
00285
00286 private:
00287 Being(const Being &rhs);
00288 Being &operator=(const Being &rhs);
00289
00290 std::list<PATH_NODE> mPath;
00291 Point mOld;
00292 Point mDst;
00293 unsigned short mSpeed;
00294 unsigned char mDirection;
00296 std::string mName;
00297 Hits mHitsTaken;
00298 AttributeModifiers mModifiers;
00299 int mHpRegenTimer;
00300 };
00301
00302 #endif // _TMWSERV_BEING_H_