diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-07-23 17:00:11 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-07-23 17:00:11 +0000 |
commit | 919bcd64912d88993b56e931b0eea880b466947b (patch) | |
tree | 23686fa6d5a0b5beccb536d9108358221b07f09d /src/game-server/testing.cpp | |
parent | 091a57aca17453b08e2a912a6ed19c09131e2123 (diff) | |
download | manaserv-919bcd64912d88993b56e931b0eea880b466947b.tar.gz manaserv-919bcd64912d88993b56e931b0eea880b466947b.tar.bz2 manaserv-919bcd64912d88993b56e931b0eea880b466947b.tar.xz manaserv-919bcd64912d88993b56e931b0eea880b466947b.zip |
Commented out code unavailable from client side. Added support for NPCs.
Diffstat (limited to 'src/game-server/testing.cpp')
-rw-r--r-- | src/game-server/testing.cpp | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/src/game-server/testing.cpp b/src/game-server/testing.cpp index 01cb4e4f..7b875eaf 100644 --- a/src/game-server/testing.cpp +++ b/src/game-server/testing.cpp @@ -5,14 +5,52 @@ #include <cassert> #include "defines.h" +#include "game-server/gamehandler.hpp" #include "game-server/item.hpp" #include "game-server/itemmanager.hpp" #include "game-server/mapcomposite.hpp" #include "game-server/mapmanager.hpp" -#include "game-server/monstermanager.hpp" -#include "game-server/spawnarea.hpp" +#include "game-server/npc.hpp" #include "game-server/state.hpp" -#include "game-server/trigger.hpp" +#include "net/messageout.hpp" + +// For testing purpose only, the NPC class is not meant to be inherited!! +struct DummyNPC: NPC +{ + DummyNPC(): NPC(110) {} + + void prompt(Character *q, bool restart) + { + if (restart) + { + MessageOut msg(GPMSG_NPC_MESSAGE); + msg.writeShort(getPublicID()); + std::string text = "What do you want?"; + msg.writeString(text, text.length()); + gameHandler->sendTo(q, msg); + } + else + { + MessageOut msg(GPMSG_NPC_CHOICE); + msg.writeShort(getPublicID()); + std::string text = "Guns! Lots of guns!:Nothing"; + msg.writeString(text, text.length()); + gameHandler->sendTo(q, msg); + } + } + + void select(Character *q, int c) + { + if (c == 1) + { + MessageOut msg(GPMSG_NPC_MESSAGE); + msg.writeShort(getPublicID()); + std::string text = "Sorry, this is a heroic-fantasy game, I do not have any gun."; + msg.writeString(text, text.length()); + gameHandler->sendTo(q, msg); + } + } +}; static void dropItem(MapComposite *map, int x, int y, int type) { @@ -34,6 +72,12 @@ void testingMap(MapComposite *map) // Drop some items dropItem(map, 58 * 32 + 16, 20 * 32 + 16, 508); dropItem(map, 58 * 32 + 16, 21 * 32 + 16, 524); + + // Add an NPC + NPC *q = new DummyNPC; + q->setMap(map); + q->setPosition(Point(50 * 32 + 16, 19 * 32 + 16)); + GameState::insert(q); } break; } } |