diff options
Diffstat (limited to 'src/npc.cpp')
-rw-r--r-- | src/npc.cpp | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/src/npc.cpp b/src/npc.cpp index a6d60dbb..d0a1a523 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -1,9 +1,8 @@ /* - * Aethyra + * The Mana World * Copyright (C) 2004 The Mana World Development Team * - * This file is part of Aethyra based on original code - * from The Mana World. + * This file is part of The Mana World. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,19 +28,29 @@ #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" -bool NPC::mTalking = false; +bool NPC::isTalking = false; 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); @@ -110,18 +119,37 @@ Being::Type NPC::getType() const void NPC::talk() { - if (mTalking || !mNetwork) + if (isTalking) + return; + + isTalking = true; + +#ifdef TMWSERV_SUPPORT + Net::GameServer::Player::talkToNPC(mId, true); +#else + if (!mNetwork) return; - mTalking = true; 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); + } } |