1 /*
2 Copyright © 2011-2012 Clint Bellanger
3 Copyright © 2013 Henrik Andersson
4 Copyright © 2012-2015 Justin Jacobs
5 
6 This file is part of FLARE.
7 
8 FLARE is free software: you can redistribute it and/or modify it under the terms
9 of the GNU General Public License as published by the Free Software Foundation,
10 either version 3 of the License, or (at your option) any later version.
11 
12 FLARE is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14 PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License along with
17 FLARE.  If not, see http://www.gnu.org/licenses/
18 */
19 
20 /**
21  * class NPC
22  */
23 
24 #ifndef NPC_H
25 #define NPC_H
26 
27 #include "Entity.h"
28 #include "ItemStorage.h"
29 
30 class EventComponent;
31 
32 class NPC : public Entity {
33 private:
34 	enum {
35 		VOX_INTRO = 0,
36 		VOX_QUEST = 1,
37 	};
38 
39 	void loadGraphics();
40 	int loadSound(const std::string& fname, int vox_type);
41 	bool isDialogType(const int &event_type);
42 	bool playSoundQuest(int id);
43 
44 	std::string gfx; // filename of sprite.
45 
46 	std::vector<EventComponent> random_table;
47 	Point random_table_count;
48 
49 	std::vector<StatusID> vendor_requires_status;
50 	std::vector<StatusID> vendor_requires_not_status;
51 
52 	std::vector<std::string> portrait_filenames;
53 
54 	// vocals
55 	std::vector<SoundID> vox_intro;
56 	std::vector<SoundID> vox_quests;
57 
58 public:
59 	static const int VENDOR_MAX_STOCK = 80;
60 	static const bool GET_RESPONSE_NODES = true;
61 
62 	explicit NPC(const Entity& e);
63 	~NPC();
64 	void load(const std::string& npc_id);
65 	void logic();
66 	bool playSoundIntro();
67 	void getDialogNodes(std::vector<int> &result, bool allow_responses);
68 	void getDialogResponses(std::vector<int>& result, size_t node_id, size_t event_cursor);
69 	std::string getDialogTopic(unsigned int dialog_node);
70 	bool checkMovement(unsigned int dialog_node);
71 	void moveMapEvents();
72 	bool checkVendor();
73 	bool processDialog(unsigned int dialog_node, unsigned int& event_cursor);
74 	void processEvent(unsigned int dialog_node, unsigned int cursor);
75 
76 	// general info
77 	std::string name;
78 	std::string filename;
79 
80 	int direction;
81 	bool show_on_minimap;
82 
83 	// talker info
84 	Sprite* npc_portrait;
85 	Sprite* hero_portrait;
86 	std::vector<Sprite*> portraits;
87 	bool talker;
88 
89 	// vendor info
90 	bool vendor;
91 	bool reset_buyback;
92 	ItemStorage stock;
93 
94 	// story and dialog options
95 	// outer vector is addressing the dialog and the inner vector is
96 	// addressing the events during one dialog
97 	std::vector<std::vector<EventComponent> > dialog;
98 };
99 
100 #endif
101