mercenary.hpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #ifndef MERCENARY_HPP
  4. #define MERCENARY_HPP
  5. #include <common/cbasetypes.hpp>
  6. #include "status.hpp" // struct status_data, struct status_change
  7. #include "unit.hpp" // struct unit_data
  8. // number of cells that a mercenary can walk to from it's master before being warped
  9. #define MAX_MER_DISTANCE 15
  10. enum e_MercGuildType {
  11. NONE_MERC_GUILD = -1,
  12. ARCH_MERC_GUILD,
  13. SPEAR_MERC_GUILD,
  14. SWORD_MERC_GUILD,
  15. };
  16. enum e_MERID {
  17. MERID_MER_ARCHER01 = 6017,
  18. MERID_MER_ARCHER10 = 6026,
  19. MERID_MER_LANCER01,
  20. MERID_MER_LANCER10 = 6036,
  21. MERID_MER_SWORDMAN01,
  22. MERID_MER_SWORDMAN10 = 6046
  23. };
  24. struct s_mercenary_db {
  25. int32 class_;
  26. std::string sprite, name;
  27. uint16 lv;
  28. uint16 range2, range3;
  29. status_data status;
  30. view_data vd;
  31. std::unordered_map<uint16, uint16> skill;
  32. };
  33. struct s_mercenary_data {
  34. block_list bl;
  35. unit_data ud;
  36. view_data *vd;
  37. status_data base_status, battle_status;
  38. status_change sc;
  39. regen_data regen;
  40. std::shared_ptr<s_mercenary_db> db;
  41. s_mercenary mercenary;
  42. std::unordered_map<uint16, int32> scd;
  43. int32 masterteleport_timer;
  44. map_session_data *master;
  45. int32 contract_timer;
  46. unsigned devotion_flag : 1;
  47. };
  48. struct view_data * mercenary_get_viewdata(uint16 class_);
  49. class MercenaryDatabase : public TypesafeYamlDatabase<int32, s_mercenary_db> {
  50. public:
  51. MercenaryDatabase() : TypesafeYamlDatabase("MERCENARY_DB", 1) {
  52. }
  53. const std::string getDefaultLocation() override;
  54. uint64 parseBodyNode(const ryml::NodeRef& node) override;
  55. };
  56. extern MercenaryDatabase mercenary_db;
  57. bool mercenary_create(map_session_data *sd, uint16 class_, uint32 lifetime);
  58. bool mercenary_recv_data(s_mercenary *merc, bool flag);
  59. void mercenary_save(s_mercenary_data *md);
  60. void mercenary_heal(s_mercenary_data *md, int32 hp, int32 sp);
  61. bool mercenary_dead(s_mercenary_data *md);
  62. int32 mercenary_delete(s_mercenary_data *md, int32 reply);
  63. void mercenary_contract_stop(s_mercenary_data *md);
  64. t_tick mercenary_get_lifetime(s_mercenary_data *md);
  65. e_MercGuildType mercenary_get_guild(s_mercenary_data *md);
  66. int32 mercenary_get_faith(s_mercenary_data *md);
  67. void mercenary_set_faith(s_mercenary_data *md, int32 value);
  68. int32 mercenary_get_calls(s_mercenary_data *md);
  69. void mercenary_set_calls(s_mercenary_data *md, int32 value);
  70. void mercenary_kills(s_mercenary_data *md);
  71. uint16 mercenary_checkskill(s_mercenary_data *md, uint16 skill_id);
  72. void do_init_mercenary(void);
  73. void do_final_mercenary(void);
  74. #endif /* MERCENARY_HPP */