summaryrefslogtreecommitdiff
path: root/src/localplayer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/localplayer.h')
-rw-r--r--src/localplayer.h257
1 files changed, 217 insertions, 40 deletions
diff --git a/src/localplayer.h b/src/localplayer.h
index 0b9ba712..7ced3fdf 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -1,34 +1,53 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_LOCALPLAYER_H
-#define _TMW_LOCALPLAYER_H
+#ifndef LOCALPLAYER_H
+#define LOCALPLAYER_H
+
+#include <memory>
+#include <vector>
#include "player.h"
-#include <memory>
+#ifdef EATHENA_SUPPORT
+// TODO move into some sane place...
+#define MAX_SLOT 2
+#define INVENTORY_SIZE 102
+#define STORAGE_SIZE 301
+#else
+#define INVENTORY_SIZE 50
+#endif
+
+class Equipment;
class FloorItem;
+class ImageSet;
class Inventory;
class Item;
+class Map;
+#ifdef EATHENA_SUPPORT
+class Network;
+#endif
+
+#ifdef TMWSERV_SUPPORT
/**
* Attributes used during combat. Available to all the beings.
@@ -113,26 +132,43 @@ enum
NB_CHARACTER_ATTRIBUTES = CHAR_SKILL_END
};
+#endif
+
/**
* The local player character.
*/
class LocalPlayer : public Player
{
public:
- enum Attribute {
+ enum Attribute
+ {
+#ifdef TMWSERV_SUPPORT
STR = 0, AGI, DEX, VIT, INT, WIL, CHR
+#else
+ STR = 0, AGI, VIT, INT, DEX, LUK
+#endif
};
/**
* Constructor.
*/
+#ifdef TMWSERV_SUPPORT
LocalPlayer();
+#else
+ LocalPlayer(Uint32 id, Uint16 job, Map *map);
+#endif
/**
* Destructor.
*/
~LocalPlayer();
+ virtual void setName(const std::string &name);
+
+#ifdef EATHENA_SUPPORT
+ void setNetwork(Network *network) { mNetwork = network; }
+ Network *getNetwork() {return mNetwork; }
+#endif
virtual void logic();
/**
@@ -142,11 +178,18 @@ class LocalPlayer : public Player
virtual void nextStep();
/**
- * Draws the name text below the being.
+ * Returns the player's inventory.
*/
- virtual void
- drawName(Graphics *, int, int) {};
+ Inventory* getInventory() const { return mInventory; }
+
+#ifdef EATHENA_SUPPORT
+ /**
+ * Returns the player's storage
+ */
+ Inventory* getStorage() const { return mStorage; }
+#endif
+#ifdef TMWSERV_SUPPORT
/**
* Check the player has permission to invite users to specific guild
*/
@@ -164,6 +207,7 @@ class LocalPlayer : public Player
void clearInventory();
void setInvItem(int index, int id, int amount);
+#endif
/**
* Move the Inventory item from the old slot to the new slot.
@@ -171,14 +215,6 @@ class LocalPlayer : public Player
void moveInvItem(Item *item, int newIndex);
/**
- * Searches for the specified item by it's identification.
- *
- * @param itemId The id of the item to be searched.
- * @return Item found on success, NULL on failure.
- */
- Item* searchForItem(int itemId);
-
- /**
* Equips an item.
*/
void equipItem(Item *item);
@@ -186,16 +222,33 @@ class LocalPlayer : public Player
/**
* Unequips an item.
*/
+#ifdef TMWSERV_SUPPORT
void unequipItem(int slot);
+#else
+ void unequipItem(Item *item);
+#endif
+#ifdef TMWSERV_SUPPORT
void useItem(int slot);
+#else
+ void useItem(Item *item);
+#endif
void dropItem(Item *item, int quantity);
+#ifdef TMWSERV_SUPPORT
void splitItem(Item *item, int quantity);
+#endif
void pickUp(FloorItem *item);
+#ifdef EATHENA_SUPPORT
+ /**
+ * Sets the attack range.
+ */
+ void setAttackRange(int range) { mAttackRange = range; }
+#endif
+
/**
* Gets the attack range.
*/
@@ -223,28 +276,56 @@ class LocalPlayer : public Player
*/
void setTrading(bool trading) { mTrading = trading; }
+#ifdef TMWSERV_SUPPORT
void attack();
-
void useSpecial(int id);
+#else
+ void attack(Being *target = NULL, bool keep = false);
+#endif
- Being* getTarget() const;
+ /**
+ * 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();
+
+#ifdef EATHENA_SUPPORT
+ void stopAttack();
+#endif
/**
* Overridden to do nothing. The attacks of the local player are
* displayed as soon as the player attacks, not when the server says
* the player does.
+ *
+ * @param victim The attacked being.
+ * @param damage The amount of damage dealt (0 means miss).
*/
+ virtual void handleAttack(Being *victim, int damage) {}
virtual void handleAttack() {}
/**
+ * Returns the current target of the player. Returns 0 if no being is
+ * currently targeted.
+ */
+ Being* getTarget() const;
+
+
+ /**
* Sets the target being of the player.
*/
- void setTarget(Being* target) { mTarget = target; }
+ void setTarget(Being* target);
/**
* Sets a new destination for this being to walk to.
*/
- void setDestination(Uint16 x, Uint16 y);
+#ifdef TMWSERV_SUPPORT
+ void setDestination(int x, int y);
+#else
+ virtual void setDestination(Uint16 x, Uint16 y);
+#endif
/**
* Sets a new direction to keep walking in.
@@ -267,6 +348,11 @@ class LocalPlayer : public Player
*/
bool withinAttackRange(Being *target);
+#ifdef EATHENA_SUPPORT
+ void raiseAttribute(Attribute attr);
+ void raiseSkill(Uint16 skillId);
+#else
+
/**
* Stops the player dead in his tracks
*/
@@ -281,23 +367,61 @@ class LocalPlayer : public Player
* Uses a correction point to lower an attribute
*/
void lowerAttribute(size_t attr);
+#endif
void toggleSit();
void emote(Uint8 emotion);
void revive();
- int getHP() const
- { return mHP; }
+#ifdef EATHENA_SUPPORT
+ /**
+ * Accessors for mInStorage
+ */
+ bool getInStorage() { return mInStorage; }
+ void setInStorage(bool inStorage) { mInStorage = inStorage; }
+
+ /**
+ * Sets the amount of XP. Shows XP gaining effect if the player is on
+ * a map.
+ */
+ void setXp(int xp);
+
+ /**
+ * Returns the amount of experience points.
+ */
+ int getXp() const { return mXp; }
+
+ Uint32 mCharId; /**< Used only during character selection. */
+
+ Uint32 mJobXp;
+ Uint32 mJobLevel;
+ Uint32 mXpForNextLevel, mJobXpForNextLevel;
+ Uint16 mMp, mMaxMp;
- int getMaxHP() const
- { return mMaxHP; }
+ Uint16 mAttackRange;
- void setHP(int value)
- { mHP = value; }
+ Uint8 mAttr[6];
+ Uint8 mAttrUp[6];
- void setMaxHP(int value)
- { mMaxHP = value; }
+ Sint16 ATK, MATK, DEF, MDEF, HIT, FLEE;
+ Sint16 ATK_BONUS, MATK_BONUS, DEF_BONUS, MDEF_BONUS, FLEE_BONUS;
+
+ Uint16 mStatPoint, mSkillPoint;
+ Uint16 mStatsPointsToAttribute;
+#endif
+
+ int getHp() const
+ { return mHp; }
+
+ int getMaxHp() const
+ { return mMaxHp; }
+
+ void setHp(int value)
+ { mHp = value; }
+
+ void setMaxHp(int value)
+ { mMaxHp = value; }
int getLevel() const
{ return mLevel; }
@@ -305,11 +429,13 @@ class LocalPlayer : public Player
void setLevel(int value)
{ mLevel = value; }
+#ifdef TMWSERV_SUPPORT
void setLevelProgress(int percent)
{ mLevelProgress = percent; }
int getLevelProgress() const
{ return mLevelProgress; }
+#endif
int getMoney() const
{ return mMoney; }
@@ -320,9 +446,16 @@ class LocalPlayer : public Player
int getTotalWeight() const
{ return mTotalWeight; }
+ void setTotalWeight(int value)
+ { mTotalWeight = value; }
+
int getMaxWeight() const
{ return mMaxWeight; }
+ void setMaxWeight(int value)
+ { mMaxWeight = value; }
+
+#ifdef TMWSERV_SUPPORT
int getAttributeBase(int num) const
{ return mAttributeBase[num]; }
@@ -357,14 +490,31 @@ class LocalPlayer : public Player
static const SkillInfo& getSkillInfo(int skill);
std::pair<int, int> getExperience(int skill);
+#endif
+ bool mUpdateName; /** Whether or not the name settings have changed */
+
+ bool mMapInitialized; /** Whether or not the map is available yet */
+
+ float mLastAttackTime; /**< Used to synchronize the charge dialog */
- Inventory *mInventory;
const std::auto_ptr<Equipment> mEquipment;
protected:
+ virtual void
+ handleStatusEffect(StatusEffect *effect, int effectId);
+
void walk(unsigned char dir);
+#ifdef EATHENA_SUPPORT
+ Network *mNetwork;
+ int mXp; /**< Experience points. */
+ bool mInStorage; /**< Whether storage is currently accessible */
+ int mTargetTime; /** How long the being has been targeted **/
+ int mLastTarget; /** Time stamp of last targeting action, -1 if none. */
+#endif
+
+#ifdef TMWSERV_SUPPORT
// Character status:
std::vector<int> mAttributeBase;
std::vector<int> mAttributeEffective;
@@ -372,29 +522,56 @@ class LocalPlayer : public Player
std::vector<int> mExpNext;
int mCharacterPoints;
int mCorrectionPoints;
- int mLevel;
int mLevelProgress;
+#endif
+ int mLevel;
int mMoney;
int mTotalWeight;
int mMaxWeight;
- int mHP;
- int mMaxHP;
+ int mHp;
+ int mMaxHp;
Being *mTarget;
FloorItem *mPickUpTarget;
bool mTrading;
bool mGoingToTarget;
- int mLastAction; /**< Time stamp of the last action, -1 if none. */
- int mWalkingDir; /**< The direction the player is walking in. */
- int mDestX; /**< X coordinate of destination. */
- int mDestY; /**< Y coordinate of destination. */
+ bool mKeepAttacking; /** Whether or not to continue to attack */
+ int mLastAction; /**< Time stamp of the last action, -1 if none. */
+ int mWalkingDir; /**< The direction the player is walking in. */
+ int mDestX; /**< X coordinate of destination. */
+ int mDestY; /**< Y coordinate of destination. */
+#ifdef TMWSERV_SUPPORT
int mLocalWalkTime; /**< Timestamp used to control keyboard walk
messages flooding */
+#endif
+
+ std::vector<int> mStatusEffectIcons;
+ Inventory *mInventory;
+#ifdef EATHENA_SUPPORT
+ Inventory *mStorage;
+#endif
+
+ // Load the target cursors into memory
+ void initTargetCursor();
+
+ /**
+ * Helper function for loading target cursors
+ */
+ void loadTargetCursor(std::string filename, int width, int height,
+ bool outRange, Being::TargetCursorSize size);
+
+ /** Images of the target cursor. */
+ ImageSet *mTargetCursorImages[2][NUM_TC];
+
+ /** Animated target cursors. */
+ SimpleAnimation *mTargetCursor[2][NUM_TC];
+
+#ifdef TMWSERV_SUPPORT
std::list<std::string> mExpMessages; /**< Queued exp messages*/
int mExpMessageTime;
-
+#endif
};
extern LocalPlayer *player_node;