PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/src/NPC.h

http://github.com/clintbellanger/flare
C++ Header | 93 lines | 51 code | 16 blank | 26 comment | 0 complexity | 94ec5677372fb306d4744a352fcbeab1 MD5 | raw file
 1/*
 2Copyright 2011 Clint Bellanger
 3
 4This file is part of FLARE.
 5
 6FLARE is free software: you can redistribute it and/or modify it under the terms
 7of the GNU General Public License as published by the Free Software Foundation,
 8either version 3 of the License, or (at your option) any later version.
 9
10FLARE is distributed in the hope that it will be useful, but WITHOUT ANY
11WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License along with
15FLARE.  If not, see http://www.gnu.org/licenses/
16*/
17
18/**
19 * class NPC
20 */
21
22#ifndef NPC_H
23#define NPC_H
24
25#include "Entity.h"
26#include "Utils.h"
27#include "ItemManager.h"
28#include "ItemStorage.h"
29#include "MapIso.h"
30#include <SDL.h>
31#include <SDL_image.h>
32#include <SDL_mixer.h>
33#include <string>
34
35const int NPC_VENDOR_MAX_STOCK = 80;
36const int NPC_MAX_VOX = 8;
37const int NPC_VOX_INTRO = 0;
38
39const int NPC_MAX_DIALOG = 32;
40const int NPC_MAX_EVENTS = 16;
41
42class NPC : public Entity {
43protected:
44	ItemManager *items;
45
46	// animation info
47	SDL_Surface *sprites;
48	int anim_frames;
49	int anim_duration;
50	int current_frame;
51	
52public:
53	NPC(MapIso *_map, ItemManager *_items);
54	~NPC();
55	void load(const std::string& npc_id);
56	void loadGraphics(const std::string& filename_sprites, const std::string& filename_portrait);
57	void loadSound(const std::string& filename, int type);
58	void logic();
59	bool playSound(int type);
60	int chooseDialogNode();
61	bool processDialog(int dialog_node, int& event_cursor);
62	virtual Renderable getRender();
63	
64	// general info
65	std::string name;
66	Point pos; // map position
67	int level; // used in determining item quality
68	
69	// public animation info
70	Point render_size;
71	Point render_offset;
72
73	// talker info
74	SDL_Surface *portrait;
75	bool talker;
76
77	// vendor info
78	bool vendor;
79	ItemStorage stock;
80	int stock_count;
81	int random_stock;
82	
83	// vocals
84	Mix_Chunk *vox_intro[NPC_MAX_VOX];
85	int vox_intro_count;
86	
87	// story and dialog options
88	Event_Component dialog[NPC_MAX_DIALOG][NPC_MAX_EVENTS];
89	int dialog_count;
90	
91};
92
93#endif