summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-08-28 18:32:11 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-08-28 18:32:11 +0000
commit566a6fb8d0fc35267b43721f7e1802ba3475af3d (patch)
treef5d3e09bda9e8e66be885b581f28cad4130ca645 /src/net
parentb506fe0ff8a2039167aa7c349087af4dd03e1921 (diff)
downloadmana-client-566a6fb8d0fc35267b43721f7e1802ba3475af3d.tar.gz
mana-client-566a6fb8d0fc35267b43721f7e1802ba3475af3d.tar.bz2
mana-client-566a6fb8d0fc35267b43721f7e1802ba3475af3d.tar.xz
mana-client-566a6fb8d0fc35267b43721f7e1802ba3475af3d.zip
Added support for being effects through the eAthena levelup message, and check
whether the being exists before referencing it. Re-enabled proper MP bar display. Improved handling of a warp to the same map.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/beinghandler.cpp34
-rw-r--r--src/net/playerhandler.cpp19
-rw-r--r--src/net/protocol.h2
3 files changed, 32 insertions, 23 deletions
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp
index c43c674f..7a0be952 100644
--- a/src/net/beinghandler.cpp
+++ b/src/net/beinghandler.cpp
@@ -36,7 +36,9 @@
#include "../main.h"
#include "../particle.h"
#include "../sound.h"
+#include <iostream>
#include "../player_relations.h"
+#include "../npc.h"
const int EMOTION_TIME = 150; /**< Duration of emotion icon */
@@ -49,7 +51,7 @@ BeingHandler::BeingHandler(bool enableSync):
SMSG_BEING_MOVE2,
SMSG_BEING_REMOVE,
SMSG_BEING_ACTION,
- SMSG_BEING_LEVELUP,
+ SMSG_BEING_SELFEFFECT,
SMSG_BEING_EMOTION,
SMSG_BEING_CHANGE_LOOKS,
SMSG_BEING_CHANGE_LOOKS2,
@@ -208,6 +210,9 @@ void BeingHandler::handleMessage(MessageIn *msg)
player_node->stopAttack();
}
+ if (dstBeing == current_npc)
+ current_npc = NULL;
+
if (msg->readInt8() == 1)
{
dstBeing->setAction(Being::DEAD);
@@ -258,27 +263,17 @@ void BeingHandler::handleMessage(MessageIn *msg)
}
break;
- case SMSG_BEING_LEVELUP:
+ case SMSG_BEING_SELFEFFECT: {
id = (Uint32)msg->readInt32();
+ if (!beingManager->findBeing(id))
+ break;
+
+ int effectType = msg->readInt32();
+
+ beingManager->findBeing(id)->triggerEffect(effectType);
- if (id == player_node->getId()) {
- logger->log("Level up");
- sound.playSfx("sfx/levelup.ogg");
- }
- else {
- logger->log("Someone else went level up");
- }
- Particle *levelupFX;
- if (msg->readInt32() == 0) { // type
- levelupFX = particleEngine->addEffect(
- "graphics/particles/levelup.particle.xml", 0, 0);
- }
- else {
- levelupFX = particleEngine->addEffect(
- "graphics/particles/skillup.particle.xml", 0, 0);
- }
- beingManager->findBeing(id)->controlParticle(levelupFX);
break;
+ }
case SMSG_BEING_EMOTION:
if (!(dstBeing = beingManager->findBeing(msg->readInt32())))
@@ -513,3 +508,4 @@ void BeingHandler::handleMessage(MessageIn *msg)
break;
}
}
+
diff --git a/src/net/playerhandler.cpp b/src/net/playerhandler.cpp
index 463868db..27d4e601 100644
--- a/src/net/playerhandler.cpp
+++ b/src/net/playerhandler.cpp
@@ -52,6 +52,9 @@ extern BuyDialog *buyDialog;
extern SellDialog *sellDialog;
extern Window *buySellDialog;
+static const int MAP_TELEPORT_SCROLL_DISTANCE = 8; /* Max. distance we are willing to scroll after a teleport;
+ ** everything beyond will reset the port hard. */
+
/**
* Listener used for handling the overweigth message.
*/
@@ -118,6 +121,7 @@ void PlayerHandler::handleMessage(MessageIn *msg)
case SMSG_PLAYER_WARP:
{
std::string mapPath = msg->readString(16);
+ bool nearby;
Uint16 x = msg->readInt16();
Uint16 y = msg->readInt16();
@@ -129,13 +133,22 @@ void PlayerHandler::handleMessage(MessageIn *msg)
*/
player_node->stopAttack();
- // Switch the actual map, deleting the previous one
+ nearby = (engine->getCurrentMapName() == mapPath);
+ // Switch the actual map, deleting the previous one if necessary
engine->changeMap(mapPath);
current_npc = 0;
- float scrollOffsetX = (x - player_node->mX) * 32;
- float scrollOffsetY = (y - player_node->mY) * 32;
+ float scrollOffsetX = 0.0f;
+ float scrollOffsetY = 0.0f;
+
+ /* Scroll if neccessary */
+ if (!nearby
+ || (abs(x - player_node->mX) > MAP_TELEPORT_SCROLL_DISTANCE)
+ || (abs(y - player_node->mY) > MAP_TELEPORT_SCROLL_DISTANCE)) {
+ scrollOffsetX = (x - player_node->mX) * 32;
+ scrollOffsetY = (y - player_node->mY) * 32;
+ }
player_node->setAction(Being::STAND);
player_node->mFrame = 0;
diff --git a/src/net/protocol.h b/src/net/protocol.h
index a2aa50c3..49c177a2 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -63,7 +63,7 @@
#define SMSG_BEING_REMOVE 0x0080
#define SMSG_BEING_CHANGE_LOOKS 0x00c3
#define SMSG_BEING_CHANGE_LOOKS2 0x01d7 /**< Same as 0x00c3, but 16 bit ID */
-#define SMSG_BEING_LEVELUP 0x019b
+#define SMSG_BEING_SELFEFFECT 0x019b
#define SMSG_BEING_EMOTION 0x00c0
#define SMSG_BEING_ACTION 0x008a /**< Attack, sit, stand up, ... */
#define SMSG_BEING_CHAT 0x008d /**< A being talks */