summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBlueSansDouze <bluesansdouze@gmail.com>2010-01-13 13:45:27 +0100
committerBlueSansDouze <bluesansdouze@gmail.com>2010-01-13 14:22:44 +0100
commit94bfab1a7d1ac3626d15c30b8c6668de9455f3ed (patch)
treee569de48e7553e86d2abf0822c2646c4b1c1f95a /src
parent61959f6a04c6a6712b5334ebd6bf21da4736431f (diff)
downloadmana-client-94bfab1a7d1ac3626d15c30b8c6668de9455f3ed.tar.gz
mana-client-94bfab1a7d1ac3626d15c30b8c6668de9455f3ed.tar.bz2
mana-client-94bfab1a7d1ac3626d15c30b8c6668de9455f3ed.tar.xz
mana-client-94bfab1a7d1ac3626d15c30b8c6668de9455f3ed.zip
Adds a follow manager for users
Right click contextual menu on player "follow" entry Cancel the following by moving with mouse or keys Adds a special behavior for map changes
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp4
-rw-r--r--src/gui/popupmenu.cpp9
-rw-r--r--src/gui/viewport.cpp1
-rw-r--r--src/localplayer.cpp5
-rw-r--r--src/localplayer.h29
-rw-r--r--src/net/ea/beinghandler.cpp25
6 files changed, 65 insertions, 8 deletions
diff --git a/src/game.cpp b/src/game.cpp
index ff947a24..c8f976a2 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -934,22 +934,26 @@ void Game::handleInput()
(joystick && joystick->isUp()))
{
direction |= Being::UP;
+ player_node->cancelFollow();
}
else if (keyboard.isKeyActive(keyboard.KEY_MOVE_DOWN) ||
(joystick && joystick->isDown()))
{
direction |= Being::DOWN;
+ player_node->cancelFollow();
}
if (keyboard.isKeyActive(keyboard.KEY_MOVE_LEFT) ||
(joystick && joystick->isLeft()))
{
direction |= Being::LEFT;
+ player_node->cancelFollow();
}
else if (keyboard.isKeyActive(keyboard.KEY_MOVE_RIGHT) ||
(joystick && joystick->isRight()))
{
direction |= Being::RIGHT;
+ player_node->cancelFollow();
}
if (keyboard.isKeyActive(keyboard.KEY_EMOTE) && direction != 0)
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index e6cd3f5b..21bab81e 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -126,9 +126,9 @@ void PopupMenu::showPopup(int x, int y, Being *being)
break;
}
- /*mBrowserBox->addRow(strprintf("@@follow|%s@@",
+ mBrowserBox->addRow(strprintf("@@follow|%s@@",
strprintf(_("Follow %s"),
- name.c_str()).c_str()));*/
+ name.c_str()).c_str()));
mBrowserBox->addRow(strprintf("@@guild|%s@@",
strprintf(_("Invite %s to join your guild"),
name.c_str()).c_str()));
@@ -263,11 +263,12 @@ void PopupMenu::handleLink(const std::string &link)
{
player_node->inviteToGuild(being);
}
- /*
+
// Follow Player action
else if (link == "follow")
{
- }*/
+ player_node->setFollow(being->getName());
+ }
// Pick Up Floor Item action
else if ((link == "pickup") && mFloorItem)
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index eb06ba0e..ec8cf341 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -390,6 +390,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
else
{
player_node->stopAttack();
+ player_node->cancelFollow();
mPlayerFollowMouse = true;
// Make the player go to the mouse position
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 86dcf7a2..11cb6655 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -106,7 +106,8 @@ LocalPlayer::LocalPlayer(int id, int job, Map *map):
#endif
mStorage(new Inventory(Net::getInventoryHandler()
->getSize(Net::InventoryHandler::STORAGE))),
- mMessageTime(0)
+ mMessageTime(0),
+ mPlayerFollowed("")
{
// Variable to keep the local player from doing certain actions before a map
// is initialized. e.g. drawing a player's name using the TextManager, since
@@ -1155,4 +1156,4 @@ void LocalPlayer::optionChanged(const std::string &value)
{
setShowName(config.getValue("showownname", 1));
}
-}
+} \ No newline at end of file
diff --git a/src/localplayer.h b/src/localplayer.h
index bc4f3647..52e3597e 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -374,6 +374,29 @@ class LocalPlayer : public Player
* Called when a option (set with config.addListener()) is changed
*/
void optionChanged(const std::string &value);
+
+ /**
+ * set a following player by right clicking.
+ */
+ void setFollow(std::string player) { mPlayerFollowed = player; }
+
+ /**
+ * setting the next destination of the following, in case of warp
+ */
+ void setNextDest(int x, int y) { mNextDestX = x; mNextDestY = y; }
+
+ int getNextDestX() const { return mNextDestX; }
+ int getNextDestY() const { return mNextDestY; }
+
+ /**
+ * stops a following
+ */
+ void cancelFollow() { mPlayerFollowed = ""; }
+
+ /**
+ * get following
+ */
+ std::string getFollow() const { return mPlayerFollowed; }
protected:
virtual void handleStatusEffect(StatusEffect *effect, int effectId);
@@ -413,6 +436,12 @@ class LocalPlayer : public Player
int mGMLevel;
Being *mTarget;
+
+ /** Follow system **/
+ std::string mPlayerFollowed;
+ int mNextDestX;
+ int mNextDestY;
+
FloorItem *mPickUpTarget;
bool mTrading;
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 932f88d9..45e58dee 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -111,7 +111,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
Being *srcBeing, *dstBeing;
Player *player;
int hairStyle, hairColor, flag;
-
+ std::string player_followed;
+
switch (msg.getId())
{
case SMSG_BEING_VISIBLE:
@@ -218,7 +219,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
dstBeing->setDirection(dir);
}
- msg.readInt8(); // unknown
+// msg.readInt8(); // unknown
msg.readInt8(); // unknown
msg.readInt8(); // unknown / sit
@@ -262,6 +263,16 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
if (!dstBeing)
break;
+
+ player_followed = player_node->getFollow();
+
+ if (!player_followed.empty())
+ {
+ if (dstBeing->getName() == player_followed)
+ {
+ player_node->setDestination(player_node->getNextDestX(), player_node->getNextDestY());
+ }
+ }
// If this is player's current target, clear it.
if (dstBeing == player_node->getTarget())
@@ -554,6 +565,16 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
msg.readCoordinatePair(srcX, srcY, dstX, dstY);
dstBeing->setTileCoords(srcX, srcY);
dstBeing->setDestination(dstX, dstY);
+
+ player_followed = player_node->getFollow();
+ if (!player_followed.empty())
+ {
+ if (dstBeing->getName() == player_followed)
+ {
+ player_node->setNextDest(dstX, dstY);
+ player_node->setDestination(srcX, srcY);
+ }
+ }
}
else
{