homunculus.hpp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #ifndef HOMUNCULUS_HPP
  4. #define HOMUNCULUS_HPP
  5. #include <string>
  6. #include <common/cbasetypes.hpp>
  7. #include <common/database.hpp>
  8. #include "mob.hpp"
  9. #include "status.hpp" // struct status_data, struct status_change
  10. #include "unit.hpp" // struct unit_data
  11. #ifdef RENEWAL
  12. #define HOMUN_LEVEL_STATWEIGHT_VALUE 0
  13. #define APPLY_HOMUN_LEVEL_STATWEIGHT()( \
  14. hom.str_value = hom.agi_value = \
  15. hom.vit_value = hom.int_value = \
  16. hom.dex_value = hom.luk_value = hom.level / 10 - HOMUN_LEVEL_STATWEIGHT_VALUE \
  17. )
  18. #else
  19. #define APPLY_HOMUN_LEVEL_STATWEIGHT()
  20. #endif
  21. struct s_homun_exp_db {
  22. uint16 level;
  23. t_exp exp;
  24. };
  25. class HomExpDatabase : public TypesafeYamlDatabase<uint16, s_homun_exp_db> {
  26. public:
  27. HomExpDatabase() : TypesafeYamlDatabase("HOMUN_EXP_DB", 1) {
  28. }
  29. const std::string getDefaultLocation() override;
  30. uint64 parseBodyNode(const ryml::NodeRef& node) override;
  31. // Additional
  32. t_exp get_nextexp(uint16 level);
  33. };
  34. struct s_hom_stats {
  35. uint32 HP, SP;
  36. uint16 str, agi, vit, int_, dex, luk;
  37. };
  38. /// Homunculus skill entry [Celest]
  39. struct s_homun_skill_tree_entry {
  40. uint16 id; ///< Skill ID
  41. uint16 max; ///< Max level for this tree
  42. uint16 need_level; ///< Homunculus level required
  43. uint32 intimacy; ///< Intimacy required (n/100)
  44. bool evolution; ///< Require evolution to show on skill tree
  45. std::unordered_map<uint16, uint16> need; ///< Skills needed
  46. };
  47. struct s_homunculus_db {
  48. int32 base_class, evo_class;
  49. char name[NAME_LENGTH];
  50. struct s_hom_stats base, gmin, gmax, emin, emax;
  51. int32 foodID;
  52. uint16 baseASPD;
  53. int32 hungryDelay;
  54. e_element element;
  55. e_race race;
  56. e_size base_size, evo_size;
  57. std::vector<s_homun_skill_tree_entry> skill_tree;
  58. };
  59. enum e_hom_mode : uint8 { MH_MD_FIGHTING = 1, MH_MD_GRAPPLING };
  60. enum e_hom_state : uint8 {
  61. HOM_ST_ACTIVE = 0,
  62. HOM_ST_REST = 1,
  63. HOM_ST_MORPH = 2,
  64. };
  65. enum e_hom_state2 : uint8 {
  66. SP_ACK = 0x0,
  67. SP_INTIMATE = 0x1,
  68. SP_HUNGRY = 0x2,
  69. };
  70. struct homun_data {
  71. struct block_list bl;
  72. struct unit_data ud;
  73. struct view_data *vd;
  74. struct status_data base_status, battle_status;
  75. status_change sc;
  76. struct regen_data regen;
  77. std::shared_ptr<s_homunculus_db> homunculusDB; //[orn]
  78. struct s_homunculus homunculus; //[orn]
  79. int32 masterteleport_timer;
  80. map_session_data *master; //pointer back to its master
  81. int32 hungry_timer; //[orn]
  82. t_exp exp_next;
  83. std::unordered_map<uint16, int32> scd;
  84. };
  85. #define HOM_EVO 0x100 //256
  86. #define HOM_S 0x200 //512
  87. #define HOM_REG 0x1000 //4096
  88. /// Houmunculus ID
  89. enum homun_mapid {
  90. // Normal Homunculus
  91. MAPID_LIF = HOM_REG|0x0,
  92. MAPID_AMISTR,
  93. MAPID_FILIR,
  94. MAPID_VANILMIRTH,
  95. // Evolved Homunulus
  96. MAPID_LIF_E = HOM_REG|HOM_EVO|0x0,
  97. MAPID_AMISTR_E,
  98. MAPID_FILIR_E,
  99. MAPID_VANILMIRTH_E,
  100. // Homunculus S
  101. MAPID_EIRA = HOM_S|0x0,
  102. MAPID_BAYERI,
  103. MAPID_SERA,
  104. MAPID_DIETER,
  105. MAPID_ELANOR,
  106. };
  107. /// Homunculus class constants
  108. enum e_homun_classid : uint16 {
  109. MER_LIF = 6001,
  110. MER_AMISTR,
  111. MER_FILIR,
  112. MER_VANILMIRTH,
  113. MER_LIF2,
  114. MER_AMISTR2,
  115. MER_FILIR2,
  116. MER_VANILMIRTH2,
  117. MER_LIF_H,
  118. MER_AMISTR_H,
  119. MER_FILIR_H,
  120. MER_VANILMIRTH_H,
  121. MER_LIF_H2,
  122. MER_AMISTR_H2,
  123. MER_FILIR_H2,
  124. MER_VANILMIRTH_H2,
  125. // Homunculus S
  126. MER_EIRA = 6048,
  127. MER_BAYERI,
  128. MER_SERA,
  129. MER_DIETER,
  130. MER_ELEANOR,
  131. };
  132. /// Homunculus type
  133. enum homun_type : int8 {
  134. HT_REG = 0x1,
  135. HT_EVO = 0x2,
  136. HT_S = 0x4,
  137. HT_INVALID = -1,
  138. };
  139. /// Homunculus battle_config setting
  140. enum homun_setting : uint8 {
  141. HOMSET_NO_SUPPORT_SKILL = 0x01, /// Cannot be targetted by support skills, except for their master
  142. HOMSET_NO_INSTANT_LAND_SKILL = 0x02, /// Unit/land skill doesn't applied immediately
  143. HOMSET_FIRST_TARGET = 0x04, /// Mobs will always go after them instead of players until attacked
  144. HOMSET_COPY_SPEED = 0x08, /// Copy their master's speed on spawn/map-change
  145. HOMSET_DISPLAY_LUK = 0x10, /// They display luk/3+1 instead of their actual critical in the stat window, by default they don't crit
  146. HOMSET_SAME_MATK = 0x20, /// Their Min-Matk is always the same as their max
  147. };
  148. enum e_homun_grade : uint8 {
  149. HOMGRADE_HATE_WITH_PASSION = 0,
  150. HOMGRADE_HATE,
  151. HOMGRADE_AWKWARD,
  152. HOMGRADE_SHY,
  153. HOMGRADE_NEUTRAL,
  154. HOMGRADE_CORDIAL,
  155. HOMGRADE_LOYAL,
  156. };
  157. class HomunculusDatabase : public TypesafeYamlDatabase<int32, s_homunculus_db> {
  158. private:
  159. bool parseStatusNode(const std::string &nodeName, const std::string &subNodeName, const ryml::NodeRef &node, s_hom_stats &bonus);
  160. public:
  161. HomunculusDatabase() : TypesafeYamlDatabase("HOMUNCULUS_DB", 1) {
  162. }
  163. const std::string getDefaultLocation();
  164. uint64 parseBodyNode(const ryml::NodeRef& node);
  165. // Additional
  166. std::shared_ptr<s_homunculus_db> homun_search(int32 class_);
  167. };
  168. extern HomunculusDatabase homunculus_db;
  169. /// Check Homunculus Class ID
  170. #define homdb_checkid(id) ((id) >= HM_CLASS_BASE && (id) <= HM_CLASS_MAX)
  171. // merc_is_hom_alive(struct homun_data *)
  172. #define hom_is_active(x) ((x) && (x)->homunculus.vaporize == HOM_ST_ACTIVE && (x)->battle_status.hp > 0)
  173. int32 hom_recv_data(uint32 account_id, struct s_homunculus *sh, int32 flag); //albator
  174. struct view_data* hom_get_viewdata(int32 class_);
  175. int32 hom_class2mapid(int32 hom_class);
  176. enum homun_type hom_class2type(int32 class_);
  177. int32 hom_dead(struct homun_data *hd);
  178. void hom_skillup(struct homun_data *hd,uint16 skill_id);
  179. void hom_calc_skilltree(homun_data *hd);
  180. int16 hom_checkskill(struct homun_data *hd,uint16 skill_id);
  181. uint16 hom_skill_get_min_level(int32 class_, uint16 skill_id);
  182. void hom_gainexp(struct homun_data *hd,t_exp exp);
  183. int32 hom_levelup(struct homun_data *hd);
  184. int32 hom_evolution(struct homun_data *hd);
  185. int32 hom_mutate(struct homun_data *hd,int32 homun_id);
  186. void hom_heal(homun_data& hd, bool hp, bool sp);
  187. int32 hom_vaporize(map_session_data *sd, int32 flag);
  188. int32 hom_ressurect(map_session_data *sd, unsigned char per, int16 x, int16 y);
  189. void hom_revive(struct homun_data *hd, uint32 hp, uint32 sp);
  190. void hom_reset_stats(struct homun_data *hd);
  191. int32 hom_shuffle(struct homun_data *hd); // [Zephyrus]
  192. void hom_save(struct homun_data *hd);
  193. bool hom_call(map_session_data *sd);
  194. bool hom_create_request(map_session_data *sd, int32 class_);
  195. void hom_menu(map_session_data *sd,int32 type);
  196. int32 hom_food(map_session_data *sd, struct homun_data *hd);
  197. int32 hom_hungry_timer_delete(struct homun_data *hd);
  198. int32 hom_change_name(map_session_data *sd,char *name);
  199. void hom_change_name_ack(map_session_data *sd, char* name, int32 flag);
  200. int32 hom_increase_intimacy(struct homun_data * hd, uint32 value);
  201. int32 hom_decrease_intimacy(struct homun_data * hd, uint32 value);
  202. int32 hom_skill_tree_get_max(int32 skill_id, int32 b_class);
  203. void hom_init_timers(struct homun_data * hd);
  204. void hom_reload(void);
  205. void hom_addspiritball(TBL_HOM *hd, int32 max);
  206. void hom_delspiritball(TBL_HOM *hd, int32 count, int32 type);
  207. uint8 hom_get_intimacy_grade(struct homun_data *hd);
  208. uint32 hom_intimacy_grade2intimacy(enum e_homun_grade grade);
  209. enum e_homun_grade hom_intimacy_intimacy2grade(uint32 intimacy);
  210. int16 hom_skill_get_index(uint16 skill_id);
  211. void do_final_homunculus(void);
  212. void do_init_homunculus(void);
  213. #endif /* HOMUNCULUS_HPP */