diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-03-21 19:44:11 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2013-03-25 20:32:37 +0100 |
commit | 4e9e0ac87b4dc16f19ac4f930d52c4cc0a2c6f64 (patch) | |
tree | 1b77436b4623c8c1fc4419758e623753899fd818 /src/game-server/npc.h | |
parent | 7aeb3b4a6c34a8f679719c207e51394d7e48828b (diff) | |
download | manaserv-4e9e0ac87b4dc16f19ac4f930d52c4cc0a2c6f64.tar.gz manaserv-4e9e0ac87b4dc16f19ac4f930d52c4cc0a2c6f64.tar.bz2 manaserv-4e9e0ac87b4dc16f19ac4f930d52c4cc0a2c6f64.tar.xz manaserv-4e9e0ac87b4dc16f19ac4f930d52c4cc0a2c6f64.zip |
Changed NPC to an NpcComponent added to a Being
Diffstat (limited to 'src/game-server/npc.h')
-rw-r--r-- | src/game-server/npc.h | 83 |
1 files changed, 47 insertions, 36 deletions
diff --git a/src/game-server/npc.h b/src/game-server/npc.h index 49dd4bfa..1a0b4e8e 100644 --- a/src/game-server/npc.h +++ b/src/game-server/npc.h @@ -1,6 +1,7 @@ /* * The Mana Server * Copyright (C) 2007-2010 The Mana World Development Team + * Copyright (C) 2012 The Mana Developers * * This file is part of The Mana Server. * @@ -21,26 +22,31 @@ #ifndef GAMESERVER_NPC_H #define GAMESERVER_NPC_H -#include "game-server/being.h" +#include "game-server/component.h" #include "scripting/script.h" class Character; /** - * Class describing a non-player character. + * Component describing a non-player character. */ -class NPC : public Being +class NpcComponent : public Component { public: - NPC(const std::string &name, int id); + static const ComponentType type = CT_Npc; - ~NPC(); + NpcComponent(int npcId); + + ~NpcComponent(); /** * Sets the function that should be called when this NPC is talked to. */ void setTalkCallback(Script::Ref function); + Script::Ref getTalkCallback() const + { return mTalkCallback; } + /** * Sets the function that should be called each update. */ @@ -49,52 +55,57 @@ class NPC : public Being /** * Calls the update callback, if any. */ - void update(); + void update(Entity &entity); /** * Sets whether the NPC is enabled. + * + * When disabling an NPC, it does currently not cancel already started + * conversations with this NPC! */ void setEnabled(bool enabled); - /** - * Prompts NPC. - */ - void prompt(Character *, bool restart); - - /** - * Selects an NPC proposition. - */ - void select(Character *, int index); - - /** - * The player has choosen an integer. - */ - void integerReceived(Character *ch, int value); - - /** - * The player has entered an string. - */ - void stringReceived(Character *ch, const std::string &value); + bool isEnabled() const + { return mEnabled; } /** * Gets NPC ID. */ - int getNPC() const - { return mID; } - - protected: - /** - * Gets the way a monster blocks pathfinding for other objects - */ - virtual BlockType getBlockType() const - { return BLOCKTYPE_CHARACTER; } // blocks like a player character + int getNpcId() const + { return mNpcId; } private: - unsigned short mID; /**< ID of the NPC. */ - bool mEnabled; /**< Whether NPC is enabled */ + int mNpcId; + bool mEnabled; Script::Ref mTalkCallback; Script::Ref mUpdateCallback; }; + +namespace Npc { + +/** + * Starts a conversation with the NPC. + */ +void start(Being *npc, Character *ch); + +/** + * Resumes an NPC conversation. + */ +void resume(Character *ch); + +/** + * The player has made a choice or entered an integer. + */ +void integerReceived(Character *ch, int value); + +/** + * The player has entered an string. + */ +void stringReceived(Character *ch, const std::string &value); + +} // namespace Npc + + #endif // GAMESERVER_NPC_H |