00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _TMWSERV_CHARACTER_HPP_
00022 #define _TMWSERV_CHARACTER_HPP_
00023
00024 #include <map>
00025 #include <string>
00026 #include <vector>
00027
00028 #include "common/inventorydata.hpp"
00029 #include "game-server/being.hpp"
00030
00031 class BuySell;
00032 class GameClient;
00033 class MessageIn;
00034 class MessageOut;
00035 class Point;
00036 class Trade;
00037
00038 struct Special
00039 {
00040 Special(int needed)
00041 {
00042 currentMana = 0;
00043 neededMana = needed;
00044 }
00045 int currentMana;
00046 int neededMana;
00047 };
00048
00052 class Character : public Being
00053 {
00054 public:
00055
00060 Character(MessageIn &msg);
00061
00062 ~Character();
00063
00067 void update();
00068
00072 void perform();
00073
00077 void respawn();
00078
00083 void useSpecial(int id);
00084
00088 void giveSpecial(int id);
00089
00093 GameClient *getClient() const
00094 { return mClient; }
00095
00099 void setClient(GameClient *c)
00100 { mClient = c; }
00101
00105 const Possessions &getPossessions() const
00106 { return mPossessions; }
00107
00111 Possessions &getPossessions()
00112 { return mPossessions; }
00113
00117 Trade *getTrading() const;
00118
00123 void setTrading(Trade *t);
00124
00128 BuySell *getBuySell() const;
00129
00134 void setBuySell(BuySell *t);
00135
00139 void cancelTransaction();
00140
00144 bool isBusy() const
00145 { return mTransaction != TRANS_NONE; }
00146
00147
00148
00149
00150
00151
00153 int
00154 getDatabaseID() const
00155 { return mDatabaseID; }
00156
00158 void
00159 setDatabaseID(int id)
00160 { mDatabaseID = id; }
00161
00163 int
00164 getGender() const
00165 { return mGender; }
00166
00168 void
00169 setGender(int gender)
00170 { mGender = gender; }
00171
00173 int
00174 getHairStyle() const
00175 { return mHairStyle; }
00176
00178 void
00179 setHairStyle(int style)
00180 { mHairStyle = style; }
00181
00183 int
00184 getHairColor() const
00185 { return mHairColor; }
00186
00188 void
00189 setHairColor(int color)
00190 { mHairColor = color; }
00191
00193 int
00194 getLevel() const
00195 { return mLevel; }
00196
00198 void
00199 setLevel(int level)
00200 { mLevel = level; }
00201
00203 int getAccountLevel() const
00204 { return mAccountLevel; }
00205
00207 void setAccountLevel(int l)
00208 { mAccountLevel = l; }
00209
00211 int getParty() const
00212 { return mParty; }
00213
00215 void setParty(int party)
00216 { mParty = party; }
00217
00222 void sendStatus();
00223
00228 int getMapId() const;
00229
00234 void setMapId(int);
00235
00239 void modifiedAttribute(int);
00240
00244 void disconnected();
00245
00250 std::map< std::string, std::string > questCache;
00251
00256 void receiveExperience(size_t skill, int experience);
00257
00261 int getExperience(int skill) const
00262 { return mExperience[skill]; }
00263
00267 void setExperience(int skill, int value)
00268 { mExperience[skill] = 0; receiveExperience(skill + CHAR_SKILL_BEGIN , value) ; }
00269
00273 int getHealth() const
00274 { return getModifiedAttribute(CHAR_ATTR_VITALITY); }
00275
00279 static int expForLevel(int level);
00280
00285 AttribmodResponseCode useCharacterPoint(size_t attribute);
00286
00291 AttribmodResponseCode useCorrectionPoint(size_t attribute);
00292
00293 void setCharacterPoints(int points)
00294 { mCharacterPoints = points; }
00295
00296 int getCharacterPoints() const
00297 { return mCharacterPoints; }
00298
00299 void setCorrectionPoints(int points)
00300 { mCorrectionPoints = points; }
00301
00302 int getCorrectionPoints() const
00303 { return mCorrectionPoints; }
00304
00308 virtual unsigned char getWalkMask() const
00309 { return 0x82; }
00310
00311 private:
00312 Character(const Character &);
00313 Character &operator=(const Character &);
00314
00315 static const float EXPCURVE_EXPONENT;
00316 static const float EXPCURVE_FACTOR;
00317 static const float LEVEL_SKILL_PRECEDENCE_FACTOR;
00318 static const int CHARPOINTS_PER_LEVELUP = 5;
00319 static const int CORRECTIONPOINTS_PER_LEVELUP = 2;
00320 static const int CORRECTIONPOINTS_MAX = 10;
00321
00322 static const AttackZone UNARMED_ATTACK_ZONE;
00323
00327 void levelup();
00328
00332 void flagAttribute(int);
00333
00337 int getExpNeeded(size_t skill);
00338
00342 int getExpGot(size_t skill);
00343
00347 void recalculateLevel();
00348
00349 enum TransactionType
00350 { TRANS_NONE, TRANS_TRADE, TRANS_BUYSELL };
00351
00352 GameClient *mClient;
00354 void *mTransactionHandler;
00355
00356 Possessions mPossessions;
00359 std::set<size_t> mModifiedAttributes;
00360 std::set<size_t> mModifiedExperience;
00361
00362 std::vector<unsigned int> mExperience;
00364 std::map<int, Special*> mSpecials;
00365
00366 int mDatabaseID;
00367 unsigned char mGender;
00368 unsigned char mHairStyle;
00369 unsigned char mHairColor;
00370 int mLevel;
00371 int mLevelProgress;
00372 int mCharacterPoints;
00373 int mCorrectionPoints;
00374 bool mUpdateLevelProgress;
00375 bool mRecalculateLevel;
00376 unsigned char mAccountLevel;
00377 int mParty;
00378 TransactionType mTransaction;
00380 protected:
00384 virtual Map::BlockType getBlockType() const
00385 { return Map::BLOCKTYPE_CHARACTER; }
00386 };
00387
00388 #endif // _TMWSERV_CHARACTER_HPP_