pet.hpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #ifndef _PET_HPP_
  4. #define _PET_HPP_
  5. #include "../common/cbasetypes.h"
  6. #include "../common/mmo.h"
  7. #include "unit.hpp"
  8. #include "status.hpp"
  9. //fwd declaration
  10. struct s_map_session_data;
  11. enum e_sc_type : int16;
  12. #define MAX_PET_DB 300
  13. #define MAX_PETLOOT_SIZE 30
  14. /// Pet DB
  15. struct s_pet_db {
  16. short class_; ///< Monster ID
  17. char name[NAME_LENGTH], ///< AEGIS name
  18. jname[NAME_LENGTH]; ///< English name
  19. unsigned short itemID; ///< Lure ID
  20. unsigned short EggID; ///< Egg ID
  21. unsigned short AcceID; ///< Accessory ID
  22. unsigned short FoodID; ///< Food ID
  23. int fullness; ///< Amount of hunger decresed each hungry_delay interval
  24. int hungry_delay; ///< Hunger value decrease each x seconds
  25. int r_hungry; ///< Intimacy increased after feeding
  26. int r_full; ///< Intimacy reduced when over-fed
  27. int intimate; ///< Initial intimacy value
  28. int die; ///< Intimacy decreased when die
  29. int capture; ///< Capture success rate 1000 = 100%
  30. int speed; ///< Walk speed
  31. char s_perfor; ///< Special performance
  32. int talk_convert_class; ///< Disables pet talk (instead of talking they emote with /!.) (?)
  33. int attack_rate; ///< Rate of which the pet will attack (requires at least pet_support_min_friendly intimacy).
  34. int defence_attack_rate; ///< Rate of which the pet will retaliate when master is being attacked (requires at least pet_support_min_friendly intimacy).
  35. int change_target_rate; ///< Rate of which the pet will change its attack target.
  36. struct script_code
  37. *pet_script, ///< Script since pet hatched
  38. *pet_loyal_script; ///< Script when pet is loyal
  39. };
  40. extern struct s_pet_db pet_db[MAX_PET_DB];
  41. enum e_pet_itemtype : uint8 { PET_CLASS,PET_CATCH,PET_EGG,PET_EQUIP,PET_FOOD };
  42. struct pet_recovery { //Stat recovery
  43. enum sc_type type; //Status Change id
  44. unsigned short delay; //How long before curing (secs).
  45. int timer;
  46. };
  47. struct pet_bonus {
  48. unsigned short type; //bStr, bVit?
  49. unsigned short val; //value
  50. unsigned short duration; //in seconds
  51. unsigned short delay; //Time before re-effect the bonus in seconds
  52. int timer;
  53. };
  54. struct pet_skill_attack { //Attack Skill
  55. unsigned short id;
  56. unsigned short lv; // Skill level
  57. unsigned short damage; // Fixed damage value of petskillattack2
  58. unsigned short div_; //0 = Normal skill. >0 = Fixed damage (lv), fixed div_.
  59. unsigned short rate; //Base chance of skill ocurrance (10 = 10% of attacks)
  60. unsigned short bonusrate; //How being 100% loyal affects cast rate (10 = At 1000 intimacy->rate+10%
  61. };
  62. struct pet_skill_support { //Support Skill
  63. unsigned short id;
  64. unsigned short lv;
  65. unsigned short hp; //Max HP% for skill to trigger (50 -> 50% for Magnificat)
  66. unsigned short sp; //Max SP% for skill to trigger (100 = no check)
  67. unsigned short delay; //Time (secs) between being able to recast.
  68. int timer;
  69. };
  70. struct pet_loot {
  71. struct item *item;
  72. unsigned short count;
  73. unsigned short weight;
  74. unsigned short max;
  75. };
  76. struct pet_data {
  77. struct block_list bl;
  78. struct unit_data ud;
  79. struct view_data vd;
  80. struct s_pet pet;
  81. struct status_data status;
  82. struct mob_db *db;
  83. struct s_pet_db *petDB;
  84. int pet_hungry_timer;
  85. int target_id;
  86. struct {
  87. unsigned skillbonus : 1;
  88. } state;
  89. int move_fail_count;
  90. unsigned int next_walktime,last_thinktime;
  91. unsigned short rate_fix; //Support rate as modified by intimacy (1000 = 100%) [Skotlex]
  92. struct pet_recovery* recovery;
  93. struct pet_bonus* bonus;
  94. struct pet_skill_attack* a_skill;
  95. struct pet_skill_support* s_skill;
  96. struct pet_loot* loot;
  97. int masterteleport_timer;
  98. struct map_session_data *master;
  99. };
  100. int pet_create_egg(struct map_session_data *sd, unsigned short item_id);
  101. int pet_hungry_val(struct pet_data *pd);
  102. void pet_set_intimate(struct pet_data *pd, int value);
  103. int pet_target_check(struct pet_data *pd,struct block_list *bl,int type);
  104. int pet_unlocktarget(struct pet_data *pd);
  105. int pet_sc_check(struct map_session_data *sd, int type); //Skotlex
  106. int search_petDB_index(int key,int type);
  107. int pet_hungry_timer_delete(struct pet_data *pd);
  108. int pet_data_init(struct map_session_data *sd, struct s_pet *pet);
  109. int pet_birth_process(struct map_session_data *sd, struct s_pet *pet);
  110. int pet_recv_petdata(uint32 account_id,struct s_pet *p,int flag);
  111. int pet_select_egg(struct map_session_data *sd,short egg_index);
  112. int pet_catch_process1(struct map_session_data *sd,int target_class);
  113. int pet_catch_process2(struct map_session_data *sd,int target_id);
  114. bool pet_get_egg(uint32 account_id, short pet_class, int pet_id);
  115. int pet_menu(struct map_session_data *sd,int menunum);
  116. int pet_change_name(struct map_session_data *sd,char *name);
  117. int pet_change_name_ack(struct map_session_data *sd, char* name, int flag);
  118. int pet_equipitem(struct map_session_data *sd,int index);
  119. int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd);
  120. int pet_attackskill(struct pet_data *pd, int target_id);
  121. int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data); // [Skotlex]
  122. int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data); // [Valaris]
  123. int pet_recovery_timer(int tid, unsigned int tick, int id, intptr_t data); // [Valaris]
  124. int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data); // [Valaris]
  125. #define pet_stop_walking(pd, type) unit_stop_walking(&(pd)->bl, type)
  126. #define pet_stop_attack(pd) unit_stop_attack(&(pd)->bl)
  127. void read_petdb(void);
  128. void do_init_pet(void);
  129. void do_final_pet(void);
  130. #endif /* _PET_HPP_ */