00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef LOCALPLAYER_H
00023 #define LOCALPLAYER_H
00024
00025 #include <memory>
00026 #include <vector>
00027
00028 #include "player.h"
00029
00030 class Equipment;
00031 class FloorItem;
00032 class ImageSet;
00033 class Inventory;
00034 class Item;
00035 class Map;
00036
00037 #ifdef TMWSERV_SUPPORT
00038
00042 enum
00043 {
00044 BASE_ATTR_BEGIN = 0,
00045 BASE_ATTR_PHY_ATK_MIN = BASE_ATTR_BEGIN,
00046 BASE_ATTR_PHY_ATK_DELTA,
00048 BASE_ATTR_MAG_ATK,
00049 BASE_ATTR_PHY_RES,
00050 BASE_ATTR_MAG_RES,
00051 BASE_ATTR_EVADE,
00052 BASE_ATTR_HIT,
00053 BASE_ATTR_HP,
00054 BASE_ATTR_HP_REGEN,
00055 BASE_ATTR_END,
00056 BASE_ATTR_NB = BASE_ATTR_END - BASE_ATTR_BEGIN,
00057
00058 BASE_ELEM_BEGIN = BASE_ATTR_END,
00059 BASE_ELEM_NEUTRAL = BASE_ELEM_BEGIN,
00060 BASE_ELEM_FIRE,
00061 BASE_ELEM_WATER,
00062 BASE_ELEM_EARTH,
00063 BASE_ELEM_AIR,
00064 BASE_ELEM_SACRED,
00065 BASE_ELEM_DEATH,
00066 BASE_ELEM_END,
00067 BASE_ELEM_NB = BASE_ELEM_END - BASE_ELEM_BEGIN,
00068
00069 NB_BEING_ATTRIBUTES = BASE_ELEM_END
00070 };
00071
00075 enum
00076 {
00077 CHAR_ATTR_BEGIN = NB_BEING_ATTRIBUTES,
00078 CHAR_ATTR_STRENGTH = CHAR_ATTR_BEGIN,
00079 CHAR_ATTR_AGILITY,
00080 CHAR_ATTR_DEXTERITY,
00081 CHAR_ATTR_VITALITY,
00082 CHAR_ATTR_INTELLIGENCE,
00083 CHAR_ATTR_WILLPOWER,
00084 CHAR_ATTR_END,
00085 CHAR_ATTR_NB = CHAR_ATTR_END - CHAR_ATTR_BEGIN,
00086
00087 CHAR_SKILL_BEGIN = CHAR_ATTR_END,
00088
00089 CHAR_SKILL_WEAPON_BEGIN = CHAR_SKILL_BEGIN,
00090 CHAR_SKILL_WEAPON_NONE = CHAR_SKILL_WEAPON_BEGIN,
00091 CHAR_SKILL_WEAPON_KNIFE,
00092 CHAR_SKILL_WEAPON_SWORD,
00093 CHAR_SKILL_WEAPON_POLEARM,
00094 CHAR_SKILL_WEAPON_STAFF,
00095 CHAR_SKILL_WEAPON_WHIP,
00096 CHAR_SKILL_WEAPON_BOW,
00097 CHAR_SKILL_WEAPON_SHOOTING,
00098 CHAR_SKILL_WEAPON_MACE,
00099 CHAR_SKILL_WEAPON_AXE,
00100 CHAR_SKILL_WEAPON_THROWN,
00101 CHAR_SKILL_WEAPON_END,
00102 CHAR_SKILL_WEAPON_NB = CHAR_SKILL_WEAPON_END - CHAR_SKILL_WEAPON_BEGIN,
00103
00104 CHAR_SKILL_MAGIC_BEGIN = CHAR_SKILL_WEAPON_END,
00105 CHAR_SKILL_MAGIC_IAMJUSTAPLACEHOLDER = CHAR_SKILL_MAGIC_BEGIN,
00106
00107 CHAR_SKILL_MAGIC_END,
00108 CHAR_SKILL_MAGIC_NB = CHAR_SKILL_MAGIC_END - CHAR_SKILL_MAGIC_BEGIN,
00109
00110 CHAR_SKILL_CRAFT_BEGIN = CHAR_SKILL_MAGIC_END,
00111 CHAR_SKILL_CRAFT_IAMJUSTAPLACEHOLDER = CHAR_SKILL_CRAFT_BEGIN,
00112
00113 CHAR_SKILL_CRAFT_END,
00114 CHAR_SKILL_CRAFT_NB = CHAR_SKILL_CRAFT_END - CHAR_SKILL_CRAFT_BEGIN,
00115
00116 CHAR_SKILL_END = CHAR_SKILL_CRAFT_END,
00117 CHAR_SKILL_NB = CHAR_SKILL_END - CHAR_SKILL_BEGIN,
00118
00119 NB_CHARACTER_ATTRIBUTES = CHAR_SKILL_END
00120 };
00121
00122 #endif
00123
00127 class LocalPlayer : public Player
00128 {
00129 public:
00130 enum Attribute
00131 {
00132 #ifdef TMWSERV_SUPPORT
00133 STR = 0, AGI, DEX, VIT, INT, WIL, CHR
00134 #else
00135 STR = 0, AGI, VIT, INT, DEX, LUK
00136 #endif
00137 };
00138
00142 #ifdef TMWSERV_SUPPORT
00143 LocalPlayer();
00144 #else
00145 LocalPlayer(int id, int job, Map *map);
00146 #endif
00147
00151 ~LocalPlayer();
00152
00153 virtual void setName(const std::string &name);
00154
00155 virtual void logic();
00156
00157 virtual void setAction(Action action, int attackType = 0);
00158
00163 virtual void nextStep();
00164
00168 Inventory *getInventory() const { return mInventory; }
00169
00173 Inventory *getStorage() const { return mStorage; }
00174
00175 #ifdef TMWSERV_SUPPORT
00176
00179 bool checkInviteRights(const std::string &guildName);
00180
00184 void inviteToGuild(Being *being);
00185
00186 void clearInventory();
00187 void setInvItem(int index, int id, int amount);
00188 #endif
00189
00193 void inviteToParty(const std::string &name);
00194
00198 void inviteToParty(Player *player);
00199
00203 void moveInvItem(Item *item, int newIndex);
00204
00208 void equipItem(Item *item);
00209
00213 void unequipItem(Item *item);
00214
00215 void useItem(Item *item);
00216
00217 void dropItem(Item *item, int quantity);
00218
00219 #ifdef TMWSERV_SUPPORT
00220 void splitItem(Item *item, int quantity);
00221 #endif
00222
00223 void pickUp(FloorItem *item);
00224
00225 #ifdef EATHENA_SUPPORT
00226
00229 void setAttackRange(int range) { mAttackRange = range; }
00230 #endif
00231
00235 int getAttackRange();
00236
00240 void trade(Being *being) const;
00241
00245 void tradeReply(bool accept);
00246
00251 bool tradeRequestOk() const;
00252
00257 void setTrading(bool trading) { mTrading = trading; }
00258
00259 #ifdef TMWSERV_SUPPORT
00260 void attack();
00261 void useSpecial(int id);
00262 #else
00263 void attack(Being *target = NULL, bool keep = false);
00264 #endif
00265
00269 virtual void setGM();
00270
00271 void stopAttack();
00272
00282 virtual void handleAttack(Being *victim, int damage, AttackType type) {}
00283 virtual void handleAttack() {}
00284
00289 Being* getTarget() const;
00290
00294 void setTarget(Being* target);
00295
00299 #ifdef TMWSERV_SUPPORT
00300 void setDestination(int x, int y);
00301 #else
00302 virtual void setDestination(Uint16 x, Uint16 y);
00303 #endif
00304
00308 void setWalkingDir(int dir);
00309
00313 int getWalkingDir() const
00314 { return mWalkingDir; }
00315
00319 void setGotoTarget(Being *target);
00320
00324 bool withinAttackRange(Being *target);
00325
00326 #ifdef EATHENA_SUPPORT
00327 void raiseSkill(Uint16 skillId);
00328 #else
00329
00333 void stopWalking(bool sendToServer = true);
00334
00338 void raiseAttribute(size_t attr);
00339
00343 void lowerAttribute(size_t attr);
00344 #endif
00345
00346 void toggleSit();
00347 void emote(Uint8 emotion);
00348
00349 void revive();
00350
00354 void pickedUp(const std::string &item);
00355
00359 bool getInStorage() { return mInStorage; }
00360 void setInStorage(bool inStorage);
00361
00362 #ifdef EATHENA_SUPPORT
00363
00367 void setXp(int xp);
00368
00372 int getXp() const { return mXp; }
00373
00374 Uint32 mCharId;
00376 Uint32 mJobXp;
00377 Uint32 mJobLevel;
00378 Uint32 mXpForNextLevel, mJobXpForNextLevel;
00379 Uint16 mMp, mMaxMp;
00380
00381 Uint16 mAttackRange;
00382
00383 Uint8 mAttr[6];
00384 Uint8 mAttrUp[6];
00385
00386 int ATK, MATK, DEF, MDEF, HIT, FLEE;
00387 int ATK_BONUS, MATK_BONUS, DEF_BONUS, MDEF_BONUS, FLEE_BONUS;
00388
00389 Uint16 mStatPoint, mSkillPoint;
00390 Uint16 mStatsPointsToAttribute;
00391 #endif
00392
00393 int getHp() const
00394 { return mHp; }
00395
00396 int getMaxHp() const
00397 { return mMaxHp; }
00398
00399 void setHp(int value)
00400 { mHp = value; }
00401
00402 void setMaxHp(int value)
00403 { mMaxHp = value; }
00404
00405 int getLevel() const
00406 { return mLevel; }
00407
00408 void setLevel(int value)
00409 { mLevel = value; }
00410
00411 #ifdef TMWSERV_SUPPORT
00412 void setLevelProgress(int percent)
00413 { mLevelProgress = percent; }
00414
00415 int getLevelProgress() const
00416 { return mLevelProgress; }
00417 #endif
00418
00419 int getMoney() const
00420 { return mMoney; }
00421
00422 void setMoney(int value)
00423 { mMoney = value; }
00424
00425 int getTotalWeight() const
00426 { return mTotalWeight; }
00427
00428 void setTotalWeight(int value)
00429 { mTotalWeight = value; }
00430
00431 int getMaxWeight() const
00432 { return mMaxWeight; }
00433
00434 void setMaxWeight(int value)
00435 { mMaxWeight = value; }
00436
00437 #ifdef TMWSERV_SUPPORT
00438 int getAttributeBase(int num) const
00439 { return mAttributeBase[num]; }
00440
00441 void setAttributeBase(int num, int value)
00442 { mAttributeBase[num] = value; }
00443
00444 int getAttributeEffective(int num) const
00445 { return mAttributeEffective[num]; }
00446
00447 void setAttributeEffective(int num, int value)
00448 { mAttributeEffective[num] = value; }
00449
00450 int getCharacterPoints() const
00451 { return mCharacterPoints; }
00452
00453 void setCharacterPoints(int n)
00454 { mCharacterPoints = n; }
00455
00456 int getCorrectionPoints() const
00457 { return mCorrectionPoints; }
00458
00459 void setCorrectionPoints(int n)
00460 { mCorrectionPoints = n; }
00461
00462 void setExperience(int skill, int current, int next);
00463
00464 struct SkillInfo {
00465 std::string name;
00466 std::string icon;
00467 };
00468
00469 static const SkillInfo& getSkillInfo(int skill);
00470
00471 std::pair<int, int> getExperience(int skill);
00472 #endif
00473
00474 bool mUpdateName;
00476 bool mMapInitialized;
00478 float mLastAttackTime;
00480 const std::auto_ptr<Equipment> mEquipment;
00481
00482 protected:
00483 virtual void handleStatusEffect(StatusEffect *effect, int effectId);
00484
00485 void walk(unsigned char dir);
00486
00487 bool mInStorage;
00488 #ifdef EATHENA_SUPPORT
00489 int mXp;
00490 int mTargetTime;
00491 #endif
00492 int mLastTarget;
00494 #ifdef TMWSERV_SUPPORT
00495
00496 std::vector<int> mAttributeBase;
00497 std::vector<int> mAttributeEffective;
00498 std::vector<int> mExpCurrent;
00499 std::vector<int> mExpNext;
00500 int mCharacterPoints;
00501 int mCorrectionPoints;
00502 int mLevelProgress;
00503 #endif
00504 int mLevel;
00505 int mMoney;
00506 int mTotalWeight;
00507 int mMaxWeight;
00508 int mHp;
00509 int mMaxHp;
00510
00511 Being *mTarget;
00512 FloorItem *mPickUpTarget;
00513
00514 bool mTrading;
00515 bool mGoingToTarget;
00516 bool mKeepAttacking;
00517 int mLastAction;
00518 int mWalkingDir;
00519 int mDestX;
00520 int mDestY;
00522 std::vector<int> mStatusEffectIcons;
00523
00524 Inventory *mInventory;
00525
00526 #ifdef TMWSERV_SUPPORT
00527 int mLocalWalkTime;
00529 #endif
00530
00531 Inventory *mStorage;
00532
00533
00534 void initTargetCursor();
00535
00539 void loadTargetCursor(std::string filename, int width, int height,
00540 bool outRange, Being::TargetCursorSize size);
00541
00543 ImageSet *mTargetCursorImages[2][NUM_TC];
00544
00546 SimpleAnimation *mTargetCursor[2][NUM_TC];
00547
00548 #ifdef TMWSERV_SUPPORT
00549 std::list<std::string> mExpMessages;
00550 int mExpMessageTime;
00551 #endif
00552 };
00553
00554 extern LocalPlayer *player_node;
00555
00556 #endif