unit.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #ifndef _UNIT_H_
  4. #define _UNIT_H_
  5. //#include "map.h"
  6. struct block_list;
  7. struct unit_data;
  8. struct map_session_data;
  9. #include "clif.h" // clr_type
  10. #include "map.h" // struct block_list
  11. #include "path.h" // struct walkpath_data
  12. #include "skill.h" // struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset
  13. extern const short dirx[8]; ///lookup to know where will move to x according dir
  14. extern const short diry[8]; ///lookup to know where will move to y according dir
  15. struct unit_data {
  16. struct block_list *bl; ///link to owner object BL_CHAR (BL_PC|BL_HOM|BL_PET|BL_ELE|BL_MER)
  17. struct walkpath_data walkpath;
  18. struct skill_timerskill *skilltimerskill[MAX_SKILLTIMERSKILL];
  19. struct skill_unit_group *skillunit[MAX_SKILLUNITGROUP];
  20. struct skill_unit_group_tickset skillunittick[MAX_SKILLUNITGROUPTICKSET];
  21. short attacktarget_lv;
  22. short to_x,to_y;
  23. short skillx,skilly;
  24. uint16 skill_id,skill_lv;
  25. int skilltarget;
  26. int skilltimer;
  27. int target;
  28. int target_to;
  29. int attacktimer;
  30. int walktimer;
  31. int chaserange;
  32. unsigned int attackabletime;
  33. unsigned int canact_tick;
  34. unsigned int canmove_tick;
  35. uint8 dir;
  36. unsigned char walk_count;
  37. unsigned char target_count;
  38. struct {
  39. unsigned change_walk_target : 1 ;
  40. unsigned skillcastcancel : 1 ;
  41. unsigned attack_continue : 1 ;
  42. unsigned walk_easy : 1 ;
  43. unsigned running : 1;
  44. unsigned speed_changed : 1;
  45. } state;
  46. };
  47. struct view_data {
  48. #ifdef __64BIT__
  49. unsigned int class_;
  50. #endif
  51. unsigned short
  52. #ifndef __64BIT__
  53. class_,
  54. #endif
  55. weapon,
  56. shield, //Or left-hand weapon.
  57. robe,
  58. head_top,
  59. head_mid,
  60. head_bottom,
  61. hair_style,
  62. hair_color,
  63. cloth_color;
  64. char sex;
  65. unsigned dead_sit : 2;
  66. };
  67. // PC, MOB, PET
  68. // Does walk action for unit
  69. int unit_walktoxy( struct block_list *bl, short x, short y, unsigned char flag);
  70. int unit_walktobl( struct block_list *bl, struct block_list *target, int range, unsigned char flag);
  71. int unit_run(struct block_list *bl);
  72. int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir);
  73. int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data);
  74. int unit_delay_walktobl_timer(int tid, unsigned int tick, int id, intptr_t data);
  75. // Ranger
  76. int unit_wugdash(struct block_list *bl, struct map_session_data *sd);
  77. // Causes the target object to stop moving.
  78. int unit_stop_walking(struct block_list *bl,int type);
  79. int unit_can_move(struct block_list *bl);
  80. int unit_is_walking(struct block_list *bl);
  81. int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int type);
  82. int unit_escape(struct block_list *bl, struct block_list *target, short dist);
  83. // Instant unit changes
  84. int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath);
  85. int unit_warp(struct block_list *bl, short map, short x, short y, clr_type type);
  86. int unit_setdir(struct block_list *bl,unsigned char dir);
  87. uint8 unit_getdir(struct block_list *bl);
  88. int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag);
  89. // Can-reach checks
  90. bool unit_can_reach_pos(struct block_list *bl,int x,int y,int easy);
  91. bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, int easy, short *x, short *y);
  92. // Unit attack functions
  93. int unit_stop_attack(struct block_list *bl);
  94. int unit_attack(struct block_list *src,int target_id,int continuous);
  95. int unit_cancel_combo(struct block_list *bl);
  96. // Cast on a unit
  97. int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv);
  98. int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv);
  99. int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel);
  100. int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel);
  101. // Cancel unit cast
  102. int unit_skillcastcancel(struct block_list *bl, char type);
  103. int unit_counttargeted(struct block_list *bl);
  104. int unit_set_target(struct unit_data* ud, int target_id);
  105. // unit_data
  106. void unit_dataset(struct block_list *bl);
  107. int unit_fixdamage(struct block_list *src,struct block_list *target,unsigned int tick,int sdelay,int ddelay,int64 damage,int div,int type,int64 damage2);
  108. // Remove unit
  109. struct unit_data* unit_bl2ud(struct block_list *bl);
  110. void unit_remove_map_pc(struct map_session_data *sd, clr_type clrtype);
  111. void unit_free_pc(struct map_session_data *sd);
  112. #define unit_remove_map(bl,clrtype) unit_remove_map_(bl,clrtype,__FILE__,__LINE__,__func__)
  113. int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, int line, const char* func);
  114. int unit_free(struct block_list *bl, clr_type clrtype);
  115. int unit_changeviewsize(struct block_list *bl,short size);
  116. void do_init_unit(void);
  117. void do_final_unit(void);
  118. #endif /* _UNIT_H_ */