homunculus.hpp 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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 "status.hpp" // struct status_data, struct status_change
  9. #include "unit.hpp" // struct unit_data
  10. #ifdef RENEWAL
  11. #define HOMUN_LEVEL_STATWEIGHT_VALUE 0
  12. #define APPLY_HOMUN_LEVEL_STATWEIGHT()( \
  13. hom->str_value = hom->agi_value = \
  14. hom->vit_value = hom->int_value = \
  15. hom->dex_value = hom->luk_value = hom->level / 10 - HOMUN_LEVEL_STATWEIGHT_VALUE \
  16. )
  17. #else
  18. #define APPLY_HOMUN_LEVEL_STATWEIGHT()
  19. #endif
  20. struct s_homun_exp_db {
  21. uint16 level;
  22. t_exp exp;
  23. };
  24. class HomExpDatabase : public TypesafeYamlDatabase<uint16, s_homun_exp_db> {
  25. public:
  26. HomExpDatabase() : TypesafeYamlDatabase("HOMUN_EXP_DB", 1) {
  27. }
  28. const std::string getDefaultLocation() override;
  29. uint64 parseBodyNode(const ryml::NodeRef& node) override;
  30. // Additional
  31. t_exp get_nextexp(uint16 level);
  32. };
  33. struct h_stats {
  34. unsigned int HP, SP;
  35. unsigned short str, agi, vit, int_, dex, luk;
  36. };
  37. struct s_homunculus_db {
  38. int base_class, evo_class;
  39. char name[NAME_LENGTH];
  40. struct h_stats base, gmin, gmax, emin, emax;
  41. int foodID;
  42. int baseASPD;
  43. long hungryDelay;
  44. unsigned char element, race, base_size, evo_size;
  45. };
  46. extern struct s_homunculus_db homunculus_db[MAX_HOMUNCULUS_CLASS];
  47. enum e_hom_search_type : uint8 { HOMUNCULUS_CLASS, HOMUNCULUS_FOOD };
  48. enum e_hom_mode : uint8 { MH_MD_FIGHTING = 1, MH_MD_GRAPPLING };
  49. enum e_hom_state : uint8 {
  50. HOM_ST_ACTIVE = 0,
  51. HOM_ST_REST = 1,
  52. HOM_ST_MORPH = 2,
  53. };
  54. enum e_hom_state2 : uint8 {
  55. SP_ACK = 0x0,
  56. SP_INTIMATE = 0x1,
  57. SP_HUNGRY = 0x2,
  58. };
  59. struct homun_data {
  60. struct block_list bl;
  61. struct unit_data ud;
  62. struct view_data *vd;
  63. struct status_data base_status, battle_status;
  64. status_change sc;
  65. struct regen_data regen;
  66. struct s_homunculus_db *homunculusDB; //[orn]
  67. struct s_homunculus homunculus; //[orn]
  68. int masterteleport_timer;
  69. map_session_data *master; //pointer back to its master
  70. int hungry_timer; //[orn]
  71. t_exp exp_next;
  72. std::vector<uint16> blockskill; // [orn]
  73. };
  74. #define MAX_HOM_SKILL_REQUIRE 5
  75. #define MAX_HOM_SKILL_TREE 8
  76. /// Homunculus skill entry [Celest]
  77. struct homun_skill_tree_entry {
  78. uint16 id; ///< Skill ID
  79. uint8 max; ///< Max level for this tree
  80. uint8 need_level; ///< Homunculus level required
  81. uint16 intimacy; ///< Intimacy required (n/100)
  82. struct {
  83. uint16 id; ///< Skill ID
  84. uint8 lv; ///< Level of skill
  85. } need[MAX_HOM_SKILL_REQUIRE]; ///< Skills needed
  86. };
  87. #define HOM_EVO 0x100 //256
  88. #define HOM_S 0x200 //512
  89. #define HOM_REG 0x1000 //4096
  90. /// Houmunculus ID
  91. enum homun_mapid {
  92. // Normal Homunculus
  93. MAPID_LIF = HOM_REG|0x0,
  94. MAPID_AMISTR,
  95. MAPID_FILIR,
  96. MAPID_VANILMIRTH,
  97. // Evolved Homunulus
  98. MAPID_LIF_E = HOM_REG|HOM_EVO|0x0,
  99. MAPID_AMISTR_E,
  100. MAPID_FILIR_E,
  101. MAPID_VANILMIRTH_E,
  102. // Homunculus S
  103. MAPID_EIRA = HOM_S|0x0,
  104. MAPID_BAYERI,
  105. MAPID_SERA,
  106. MAPID_DIETER,
  107. MAPID_ELANOR,
  108. };
  109. /// Homunculus type
  110. enum homun_type : int8 {
  111. HT_REG = 0x1,
  112. HT_EVO = 0x2,
  113. HT_S = 0x4,
  114. HT_INVALID = -1,
  115. };
  116. /// Homunculus battle_config setting
  117. enum homun_setting : uint8 {
  118. HOMSET_NO_SUPPORT_SKILL = 0x01, /// Cannot be targetted by support skills, except for their master
  119. HOMSET_NO_INSTANT_LAND_SKILL = 0x02, /// Unit/land skill doesn't applied immediately
  120. HOMSET_FIRST_TARGET = 0x04, /// Mobs will always go after them instead of players until attacked
  121. HOMSET_COPY_SPEED = 0x08, /// Copy their master's speed on spawn/map-change
  122. HOMSET_DISPLAY_LUK = 0x10, /// They display luk/3+1 instead of their actual critical in the stat window, by default they don't crit
  123. HOMSET_SAME_MATK = 0x20, /// Their Min-Matk is always the same as their max
  124. HOMSET_RESET_REUSESKILL_VAPORIZED = 0x40, /// Skill re-use delay is reset when they are vaporized.
  125. HOMSET_RESET_REUSESKILL_TELEPORTED = 0x80, /// Skill re-use delay is reset when they are warped (by skill or item) with player.
  126. };
  127. enum e_homun_grade : uint8 {
  128. HOMGRADE_HATE_WITH_PASSION = 0,
  129. HOMGRADE_HATE,
  130. HOMGRADE_AWKWARD,
  131. HOMGRADE_SHY,
  132. HOMGRADE_NEUTRAL,
  133. HOMGRADE_CORDIAL,
  134. HOMGRADE_LOYAL,
  135. };
  136. /// Check Homunculus Class ID
  137. #define homdb_checkid(id) ((id) >= HM_CLASS_BASE && (id) <= HM_CLASS_MAX)
  138. // merc_is_hom_alive(struct homun_data *)
  139. #define hom_is_active(x) ((x) && (x)->homunculus.vaporize == HOM_ST_ACTIVE && (x)->battle_status.hp > 0)
  140. int hom_recv_data(uint32 account_id, struct s_homunculus *sh, int flag); //albator
  141. struct view_data* hom_get_viewdata(int class_);
  142. int hom_class2mapid(int hom_class);
  143. enum homun_type hom_class2type(int class_);
  144. void hom_damage(struct homun_data *hd);
  145. int hom_dead(struct homun_data *hd);
  146. void hom_skillup(struct homun_data *hd,uint16 skill_id);
  147. void hom_calc_skilltree(struct homun_data *hd, bool flag_evolve);
  148. short hom_checkskill(struct homun_data *hd,uint16 skill_id);
  149. uint8 hom_skill_get_min_level(int class_, uint16 skill_id);
  150. void hom_gainexp(struct homun_data *hd,t_exp exp);
  151. int hom_levelup(struct homun_data *hd);
  152. int hom_evolution(struct homun_data *hd);
  153. int hom_mutate(struct homun_data *hd,int homun_id);
  154. void hom_heal(struct homun_data *hd);
  155. int hom_vaporize(map_session_data *sd, int flag);
  156. int hom_ressurect(map_session_data *sd, unsigned char per, short x, short y);
  157. void hom_revive(struct homun_data *hd, unsigned int hp, unsigned int sp);
  158. void hom_reset_stats(struct homun_data *hd);
  159. int hom_shuffle(struct homun_data *hd); // [Zephyrus]
  160. void hom_save(struct homun_data *hd);
  161. bool hom_call(map_session_data *sd);
  162. bool hom_create_request(map_session_data *sd, int class_);
  163. int hom_search(int key,int type);
  164. void hom_menu(map_session_data *sd,int type);
  165. int hom_food(map_session_data *sd, struct homun_data *hd);
  166. int hom_hungry_timer_delete(struct homun_data *hd);
  167. int hom_change_name(map_session_data *sd,char *name);
  168. void hom_change_name_ack(map_session_data *sd, char* name, int flag);
  169. #define hom_stop_walking(hd, type) unit_stop_walking(&(hd)->bl, type)
  170. #define hom_stop_attack(hd) unit_stop_attack(&(hd)->bl)
  171. int hom_increase_intimacy(struct homun_data * hd, unsigned int value);
  172. int hom_decrease_intimacy(struct homun_data * hd, unsigned int value);
  173. int hom_skill_tree_get_max(int skill_id, int b_class);
  174. void hom_init_timers(struct homun_data * hd);
  175. void hom_reload_skill(void);
  176. void hom_reload(void);
  177. void hom_addspiritball(TBL_HOM *hd, int max);
  178. void hom_delspiritball(TBL_HOM *hd, int count, int type);
  179. uint8 hom_get_intimacy_grade(struct homun_data *hd);
  180. uint32 hom_intimacy_grade2intimacy(enum e_homun_grade grade);
  181. enum e_homun_grade hom_intimacy_intimacy2grade(uint32 intimacy);
  182. short hom_skill_get_index(uint16 skill_id);
  183. void do_final_homunculus(void);
  184. void do_init_homunculus(void);
  185. #endif /* HOMUNCULUS_HPP */