summaryrefslogtreecommitdiff
path: root/src/being.h
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-03-15 17:28:16 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-03-15 17:28:16 +0100
commit21e8d502d07c6cae9580a34dde7587d58e6d3a28 (patch)
treefd8c9fa711d0e2e60f50333f82dbe43ebd9214a5 /src/being.h
parent25a2abd09e3b76115ed0b6b1a02cdddc6c1c5bfc (diff)
downloadmana-21e8d502d07c6cae9580a34dde7587d58e6d3a28.tar.gz
mana-21e8d502d07c6cae9580a34dde7587d58e6d3a28.tar.bz2
mana-21e8d502d07c6cae9580a34dde7587d58e6d3a28.tar.xz
mana-21e8d502d07c6cae9580a34dde7587d58e6d3a28.zip
Basically merged the two movement algorithms into one.
This was made in favour of the manaserv way of doing things. I also added a way to keep the original server speed value so the pixel value can be recomputed at each map change, as this was necessary since the speed is given before the first map is loaded. The code is much more simpler now about movement handling, and we can already see improvements on other characters movements in The Mana World with this. Everything can't be perfect the first time; here are bugs identified so far: - Monsters direction isn't updated on TmwAthena for obscure reasons. - Remote players walking animation is sometimes reset on each steps. - When changing map, the local player sometimes walks randomly until the player reacts. Stay tuned!
Diffstat (limited to 'src/being.h')
-rw-r--r--src/being.h79
1 files changed, 21 insertions, 58 deletions
diff --git a/src/being.h b/src/being.h
index 7f6f8007..fcd2b8f8 100644
--- a/src/being.h
+++ b/src/being.h
@@ -118,7 +118,8 @@ class Being : public ActorSprite, public Mana::Listener
virtual ~Being();
- Type getType() const { return mType; }
+ Type getType() const
+ { return mType; }
/**
* Removes all path nodes from this being.
@@ -126,37 +127,6 @@ class Being : public ActorSprite, public Mana::Listener
void clearPath();
/**
- * Returns the time spent in the current action.
- */
- int getActionTime() const { return mActionTime; }
-
- /**
- * Set the current action time.
- * @see Ea::BeingHandler that set it to tick time.
- */
- void setActionTime(int actionTime) { mActionTime = actionTime; }
-
- /**
- * Makes this being take the next tile of its path.
- * TODO: Used by eAthena only?
- */
- virtual void nextTile();
-
- /**
- * Get the current X pixel offset.
- * TODO: Used by eAthena only?
- */
- int getXOffset() const
- { return getOffset(LEFT, RIGHT); }
-
- /**
- * Get the current Y pixel offset.
- * TODO: Used by eAthena only?
- */
- int getYOffset() const
- { return getOffset(UP, DOWN); }
-
- /**
* Creates a path for the being from current position to ex and ey
*/
void setDestination(int ex, int ey);
@@ -164,25 +134,20 @@ class Being : public ActorSprite, public Mana::Listener
/**
* Returns the destination for this being.
*/
- const Vector &getDestination() const { return mDest; }
+ const Vector &getDestination() const
+ { return mDest; }
/**
* Returns the tile x coord
*/
int getTileX() const
- { return mX; }
+ { return mPos.x / mMap->getTileWidth(); }
/**
* Returns the tile y coord
*/
int getTileY() const
- { return mY; }
-
- /**
- * Sets the tile x and y coord
- */
- void setTileCoords(int x, int y)
- { mX = x; mY = y; }
+ { return mPos.y / mMap->getTileHeight(); }
/**
* Puts a "speech balloon" above this being for the specified amount
@@ -343,18 +308,18 @@ class Being : public ActorSprite, public Mana::Listener
Map::BlockType getBlockType() const;
/**
- * Sets the walk speed.
- * in pixels per second for eAthena,
+ * Sets the move speed.
+ * in ticks per tile for eAthena,
* in tiles per second for Manaserv.
*/
- void setWalkSpeed(Vector speed) { mWalkSpeed = speed; }
+ void setMoveSpeed(Vector speed);
/**
- * Gets the walk speed.
- * in pixels per second for eAthena,
+ * Gets the original Move speed.
+ * in ticks per tile for eAthena,
* in tiles per second for Manaserv (0.1 precision).
*/
- Vector getWalkSpeed() const { return mWalkSpeed; }
+ Vector getMoveSpeed() const { return mMoveSpeed; }
/**
* Sets the attack speed.
@@ -483,6 +448,8 @@ class Being : public ActorSprite, public Mana::Listener
void event(Channels channel, const Mana::Event &event);
+ void setMap(Map *map);
+
protected:
/**
* Sets the new path for this being.
@@ -500,7 +467,7 @@ class Being : public ActorSprite, public Mana::Listener
BeingInfo *mInfo;
- int mActionTime; /**< Time spent in current action */
+ int mActionTime; /**< Time spent in current action. TODO: Remove use of it */
/** Time until the last speech sentence disappears */
int mSpeechTime;
@@ -547,13 +514,6 @@ class Being : public ActorSprite, public Mana::Listener
private:
- /**
- * Calculates the offset in the given directions.
- * If walking in direction 'neg' the value is negated.
- * TODO: Used by eAthena only?
- */
- int getOffset(char pos, char neg) const;
-
const Type mType;
/** Speech Bubble components */
@@ -561,13 +521,16 @@ class Being : public ActorSprite, public Mana::Listener
/**
* Walk speed for x and y movement values.
- * In pixels per second for eAthena,
+ * In ticks per tile for eAthena,
* In pixels per ticks for Manaserv.
* @see MILLISECONDS_IN_A_TICK
*/
- Vector mWalkSpeed;
+ Vector mMoveSpeed;
- int mX, mY; /**< Position in tile */
+ /**
+ * Being speed in pixel per ticks. Used internally for the being logic.
+ */
+ Vector mSpeedPixelsPerTick;
int mDamageTaken;