diff options
Diffstat (limited to 'src/npc.cpp')
-rw-r--r-- | src/npc.cpp | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/src/npc.cpp b/src/npc.cpp index 630316e0..df43d548 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -28,8 +28,12 @@ #include "gui/npc_text.h" #include "gui/palette.h" +#ifdef TMWSERV_SUPPORT +#include "net/tmwserv/gameserver/player.h" +#else #include "net/messageout.h" -#include "net/protocol.h" +#include "net/ea/protocol.h" +#endif #include "resources/npcdb.h" @@ -39,8 +43,14 @@ int current_npc = 0; static const int NAME_X_OFFSET = 15; static const int NAME_Y_OFFSET = 30; +#ifdef TMWSERV_SUPPORT +NPC::NPC(Uint16 id, int job, Map *map): + Player(id, job, map) +#else NPC::NPC(int id, Uint16 job, Map *map, Network *network): - Player(id, job, map), mNetwork(network) + Player(id, job, map), + mNetwork(network) +#endif { NPCInfo info = NPCDB::get(job); @@ -109,17 +119,37 @@ Being::Type NPC::getType() const void NPC::talk() { - if (isTalking || !mNetwork) return; + if (isTalking) + return; isTalking = true; + +#ifdef TMWSERV_SUPPORT + Net::GameServer::Player::talkToNPC(mId, true); +#else + if (!mNetwork) + return; + MessageOut outMsg(mNetwork); outMsg.writeInt16(CMSG_NPC_TALK); + outMsg.writeInt16(CMSG_NPC_TALK); outMsg.writeInt32(mId); outMsg.writeInt8(0); +#endif } void NPC::updateCoords() { if (mName) - mName->adviseXY(mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET); + { +#ifdef TMWSERV_SUPPORT + const Vector &pos = getPosition(); + const int px = (int) pos.x + NAME_X_OFFSET; + const int py = (int) pos.y + NAME_Y_OFFSET; +#else + const int px = mPx + NAME_X_OFFSET; + const int py = mPy + NAME_Y_OFFSET; +#endif + mName->adviseXY(px, py); + } } |