summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog19
-rw-r--r--src/gui/gui.cpp4
-rw-r--r--src/localplayer.cpp29
-rw-r--r--src/localplayer.h2
4 files changed, 39 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 7c319597..5b1effe4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,14 +1,19 @@
+2006-02-05 Björn Steinbrink <B.Steinbrink@gmx.de>
+
+ * src/localplayer.cpp, src/localplayer.h, src/gui/gui.cpp: Made the
+ player walk to items prior to picking them up.
+
2006-02-04 Philipp Sehmisch <tmw@crushnet.org>
+
* data/graphics/tiles/Woodland.png: new path design
- * data/graphics/tiles/Woodland_ground.png,
+ * data/graphics/tiles/Woodland_ground.png,
data/graphics/tiles/Woodland_x2.png,
- data/graphics/tiles/Woodland_x3.png: splitted the tileset into three
+ data/graphics/tiles/Woodland_x3.png: splitted the tileset into three
tilesets with different tile sizes
(i kept the original tileset for backward compatiblity)
- * data/maps/new_9.1.tmx.gz: remapped with the oversized tile technology.
- made the forests less regular. made the unwalkable map borders more
- visual appealing
-
+ * data/maps/new_9.1.tmx.gz: remapped with the oversized tile
+ technology. made the forests less regular. made the unwalkable map
+ borders more visual appealing
2006-02-04 Björn Steinbrink <B.Steinbrink@gmx.de>
@@ -1738,4 +1743,4 @@
restore some doxygen comments, improved size adaption and made the
window a shorter.
* data/graphics/images/login_wallpaper.png: New login wallpaper by
- Momotaro. \ No newline at end of file
+ Momotaro.
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 491a4009..3d8d8a98 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -310,10 +310,6 @@ Gui::mousePress(int mx, int my, int button)
// Pick up some item
else if ((item = find_floor_item_by_cor(tilex, tiley)))
{
- int dx = tilex - player_node->x;
- int dy = tiley - player_node->y;
-
- if ((dx * dx + dy * dy) < 4)
player_node->pickUp(item);
}
// Just walk around
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index d76ebc30..1b3178e1 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -40,7 +40,7 @@ LocalPlayer::LocalPlayer(Uint32 id, Uint16 job, Map *map):
Player(id, job, map),
mInventory(new Inventory()),
mEquipment(new Equipment()),
- mTarget(NULL),
+ mTarget(NULL), mPickUpTarget(NULL),
mTrading(false)
{
}
@@ -72,6 +72,14 @@ void LocalPlayer::logic()
Being::logic();
}
+void LocalPlayer::nextStep()
+{
+ if (mPath.empty() && mPickUpTarget) {
+ pickUp(mPickUpTarget);
+ }
+ Player::nextStep();
+}
+
Being::Type LocalPlayer::getType() const
{
return LOCALPLAYER;
@@ -138,9 +146,19 @@ void LocalPlayer::dropItem(Item *item, int quantity)
void LocalPlayer::pickUp(FloorItem *item)
{
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_ITEM_PICKUP);
- outMsg.writeInt32(item->getId());
+ int dx = item->getX() - x;
+ int dy = item->getY() - y;
+
+ if (dx * dx + dy * dy < 4) {
+ MessageOut outMsg(mNetwork);
+ outMsg.writeInt16(CMSG_ITEM_PICKUP);
+ outMsg.writeInt32(item->getId());
+ mPickUpTarget = NULL;
+ } else {
+ setDestination(item->getX(), item->getY());
+ mPickUpTarget = item;
+ stopAttack();
+ }
}
void LocalPlayer::walk(Being::Direction dir)
@@ -228,6 +246,9 @@ void LocalPlayer::setDestination(Uint16 x, Uint16 y)
set_coordinates(temp, x, y, direction);
outMsg.writeInt16(0x0085);
outMsg.writeString(temp, 3);
+
+ mPickUpTarget = NULL;
+
Being::setDestination(x, y);
}
diff --git a/src/localplayer.h b/src/localplayer.h
index 56814e05..fe87fbab 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -49,6 +49,7 @@ class LocalPlayer : public Player
void setNetwork(Network *network) { mNetwork = network; }
virtual void logic();
+ virtual void nextStep();
virtual Type getType() const;
@@ -140,6 +141,7 @@ class LocalPlayer : public Player
protected:
Network *mNetwork;
Being *mTarget;
+ FloorItem *mPickUpTarget;
bool mTrading;
};