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