mob.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #ifndef _MOB_H_
  4. #define _MOB_H_
  5. #include "unit.h"
  6. #include "map.h"
  7. #define MAX_RANDOMMONSTER 3
  8. #define MAX_MOB_RACE_DB 6
  9. /* Change this to increase the table size in your mob_db to accomodate
  10. a larger mob database. Be sure to note that IDs 4001 to 4048 are reserved for advanced/baby/expanded classes.
  11. */
  12. #define MAX_MOB_DB 10000
  13. //The number of drops all mobs have and the max drop-slot that the steal skill
  14. //will attempt to steal from.
  15. #define MAX_MOB_DROP 10
  16. #define MAX_STEAL_DROP 7
  17. //Min time before mobs do a check to call nearby friends for help (or for slaves to support their master)
  18. #define MIN_MOBLINKTIME 1000
  19. //Distance that slaves should keep from their master.
  20. #define MOB_SLAVEDISTANCE 2
  21. // These define the range of available IDs for clones. [Valaris]
  22. #define MOB_CLONE_START 9001
  23. #define MOB_CLONE_END 10000
  24. // Scripted Mob AI Constants
  25. #define CALLBACK_NPCCLICK 0x100
  26. #define CALLBACK_ATTACK 0x80
  27. #define CALLBACK_DETECT 0x40
  28. #define CALLBACK_DEAD 0x20
  29. #define CALLBACK_ASSIST 0x10
  30. #define CALLBACK_KILL 0x08
  31. #define CALLBACK_UNLOCK 0x04
  32. #define CALLBACK_WALKACK 0x02
  33. #define CALLBACK_WARPACK 0x01
  34. int mob_script_callback(struct mob_data *md, struct block_list *target, short action_type);
  35. struct mob_skill {
  36. short state;
  37. short skill_id,skill_lv;
  38. short permillage;
  39. int casttime,delay;
  40. short cancel;
  41. short cond1,cond2;
  42. short target;
  43. int val[5];
  44. short emotion;
  45. };
  46. struct mob_db {
  47. char sprite[NAME_LENGTH],name[NAME_LENGTH],jname[NAME_LENGTH];
  48. unsigned int base_exp,job_exp;
  49. unsigned int mexp,mexpper;
  50. unsigned int min_thinktime; //Min think time, Recharge Time as aegis calls it.
  51. int range2,range3;
  52. short race2; // celest
  53. unsigned short lv;
  54. struct { int nameid,p; } dropitem[MAX_MOB_DROP];
  55. struct { int nameid,p; } mvpitem[3];
  56. struct status_data status;
  57. struct view_data vd;
  58. short option;
  59. int summonper[MAX_RANDOMMONSTER];
  60. int maxskill;
  61. struct mob_skill skill[MAX_MOBSKILL];
  62. };
  63. enum {
  64. MST_TARGET = 0,
  65. MST_SELF,
  66. MST_FRIEND,
  67. MST_MASTER,
  68. MST_AROUND5,
  69. MST_AROUND6,
  70. MST_AROUND7,
  71. MST_AROUND8,
  72. MST_AROUND1,
  73. MST_AROUND2,
  74. MST_AROUND3,
  75. MST_AROUND4,
  76. MST_AROUND = MST_AROUND4,
  77. MSC_ALWAYS = 0x0000,
  78. MSC_MYHPLTMAXRATE,
  79. MSC_MYHPINRATE,
  80. MSC_FRIENDHPLTMAXRATE,
  81. MSC_FRIENDHPINRATE,
  82. MSC_MYSTATUSON,
  83. MSC_MYSTATUSOFF,
  84. MSC_FRIENDSTATUSON,
  85. MSC_FRIENDSTATUSOFF,
  86. MSC_ATTACKPCGT,
  87. MSC_ATTACKPCGE,
  88. MSC_SLAVELT,
  89. MSC_SLAVELE,
  90. MSC_CLOSEDATTACKED,
  91. MSC_LONGRANGEATTACKED,
  92. MSC_AFTERSKILL,
  93. MSC_SKILLUSED ,
  94. MSC_CASTTARGETED,
  95. MSC_RUDEATTACKED,
  96. MSC_MASTERHPLTMAXRATE,
  97. MSC_MASTERATTACKED,
  98. MSC_ALCHEMIST,
  99. MSC_SPAWN,
  100. };
  101. //Mob skill states.
  102. enum {
  103. MSS_ANY = -1,
  104. MSS_IDLE,
  105. MSS_WALK,
  106. MSS_LOOT,
  107. MSS_DEAD,
  108. MSS_BERSERK, //Aggressive mob attacking
  109. MSS_ANGRY, //Mob retaliating from being attacked.
  110. MSS_RUSH, //Mob following a player after being attacked.
  111. MSS_FOLLOW, //Mob following a player without being attacked.
  112. MSS_ANYTARGET,
  113. };
  114. /*==========================================
  115. * The structure object for item drop with delay
  116. * Since it is only two being able to pass [ int ] a timer function
  117. * Data is put in and passed to this structure object.
  118. *------------------------------------------
  119. */
  120. struct item_drop {
  121. struct item item_data;
  122. struct item_drop *next;
  123. };
  124. struct item_drop_list {
  125. int m,x,y;
  126. struct map_session_data *first_sd,*second_sd,*third_sd;
  127. struct item_drop *item;
  128. };
  129. struct mob_db* mob_db(int class_);
  130. int mobdb_searchname(const char *str);
  131. int mobdb_searchname_array(struct mob_db** data, int size, const char *str);
  132. int mobdb_checkid(const int id);
  133. struct view_data* mob_get_viewdata(int class_);
  134. struct mob_data *mob_once_spawn_sub(struct block_list *bl, int m,
  135. short x, short y, const char *mobname, int class_, const char *event);
  136. int mob_once_spawn(struct map_session_data *sd,char *mapname,
  137. short x,short y,const char *mobname,int class_,int amount,const char *event);
  138. int mob_once_spawn_area(struct map_session_data *sd,char *mapname,
  139. int x0,int y0,int x1,int y1,
  140. const char *mobname,int class_,int amount,const char *event);
  141. int mob_spawn_guardian(struct map_session_data *sd,char *mapname, // Spawning Guardians [Valaris]
  142. int x,int y,const char *mobname,int class_,int amount,const char *event,int guardian); // Spawning Guardians [Valaris]
  143. int mob_guardian_guildchange(struct block_list *bl,va_list ap); //Change Guardian's ownership. [Skotlex]
  144. int mob_randomwalk(struct mob_data *md,int tick);
  145. int mob_target(struct mob_data *md,struct block_list *bl,int dist);
  146. int mob_unlocktarget(struct mob_data *md,int tick);
  147. struct mob_data* mob_spawn_dataset(struct spawn_data *data);
  148. int mob_spawn(struct mob_data *md);
  149. int mob_setdelayspawn(struct mob_data *md);
  150. int mob_parse_dataset(struct spawn_data *data);
  151. void mob_damage(struct mob_data *md, struct block_list *src, int damage);
  152. int mob_dead(struct mob_data *md, struct block_list *src, int type);
  153. void mob_revive(struct mob_data *md, unsigned int hp);
  154. void mob_heal(struct mob_data *md,unsigned int heal);
  155. #define mob_stop_walking(md, type) { if (md->ud.walktimer != -1) unit_stop_walking(&md->bl, type); }
  156. #define mob_stop_attack(md) { if (md->ud.attacktimer != -1) unit_stop_attack(&md->bl); }
  157. int do_init_mob(void);
  158. int do_final_mob(void);
  159. int mob_timer_delete(int tid, unsigned int tick, int id, int data);
  160. int mob_deleteslave(struct mob_data *md);
  161. int mob_random_class (int *value, size_t count);
  162. int mob_get_random_id(int type, int flag, int lv);
  163. int mob_class_change(struct mob_data *md,int class_);
  164. int mob_warpslave(struct block_list *bl, int range);
  165. int mob_linksearch(struct block_list *bl,va_list ap);
  166. int mobskill_use(struct mob_data *md,unsigned int tick,int event);
  167. int mobskill_event(struct mob_data *md,struct block_list *src,unsigned int tick, int flag);
  168. int mobskill_castend_id( int tid, unsigned int tick, int id,int data );
  169. int mobskill_castend_pos( int tid, unsigned int tick, int id,int data );
  170. int mob_summonslave(struct mob_data *md2,int *value,int amount,int skill_id);
  171. int mob_countslave(struct block_list *bl);
  172. int mob_convertslave(struct mob_data *md);
  173. int mob_is_clone(int class_);
  174. int mob_clone_spawn(struct map_session_data *sd, int m, int x, int y, const char *event, int master_id, int mode, int flag, unsigned int duration);
  175. int mob_clone_delete(int class_);
  176. void mob_reload(void);
  177. #endif