unit.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 "map.h" // struct block_list
  10. #include "path.h" // struct walkpath_data
  11. #include "skill.h" // struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset
  12. struct unit_data {
  13. struct block_list *bl;
  14. struct walkpath_data walkpath;
  15. struct skill_timerskill *skilltimerskill[MAX_SKILLTIMERSKILL];
  16. struct skill_unit_group *skillunit[MAX_SKILLUNITGROUP];
  17. struct skill_unit_group_tickset skillunittick[MAX_SKILLUNITGROUPTICKSET];
  18. short attacktarget_lv;
  19. short to_x,to_y;
  20. short skillx,skilly;
  21. short skillid,skilllv;
  22. int skilltarget;
  23. int skilltimer;
  24. int target;
  25. int attacktimer;
  26. int walktimer;
  27. int chaserange;
  28. unsigned int attackabletime;
  29. unsigned int canact_tick;
  30. unsigned int canmove_tick;
  31. uint8 dir;
  32. unsigned char walk_count;
  33. struct {
  34. unsigned change_walk_target : 1 ;
  35. unsigned skillcastcancel : 1 ;
  36. unsigned attack_continue : 1 ;
  37. unsigned walk_easy : 1 ;
  38. unsigned running : 1;
  39. unsigned speed_changed : 1;
  40. } state;
  41. };
  42. struct view_data {
  43. unsigned short
  44. class_,
  45. weapon,
  46. shield, //Or left-hand weapon.
  47. head_top,
  48. head_mid,
  49. head_bottom,
  50. hair_style,
  51. hair_color,
  52. cloth_color;
  53. char sex;
  54. unsigned dead_sit : 2;
  55. };
  56. // PC, MOB, PET に共通する処理を1つにまとめる計画
  57. // 歩行開始
  58. // 戻り値は、0 ( 成功 ), 1 ( 失敗 )
  59. int unit_walktoxy( struct block_list *bl, short x, short y, int easy);
  60. int unit_walktobl( struct block_list *bl, struct block_list *target, int range, int easy);
  61. int unit_run(struct block_list *bl);
  62. // 歩行停止
  63. // typeは以下の組み合わせ :
  64. // 1: 位置情報の送信( この関数の後に位置情報を送信する場合は不要 )
  65. // 2: ダメージディレイ有り
  66. // 4: 不明(MOBのみ?)
  67. int unit_stop_walking(struct block_list *bl,int type);
  68. int unit_can_move(struct block_list *bl);
  69. int unit_is_walking(struct block_list *bl);
  70. int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int type);
  71. int unit_escape(struct block_list *bl, struct block_list *target, short dist);
  72. // 位置の強制移動(吹き飛ばしなど)
  73. int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath);
  74. int unit_warp(struct block_list *bl, short map, short x, short y, int type);
  75. int unit_setdir(struct block_list *bl,unsigned char dir);
  76. uint8 unit_getdir(struct block_list *bl);
  77. // そこまで歩行でたどり着けるかの判定
  78. bool unit_can_reach_pos(struct block_list *bl,int x,int y,int easy);
  79. bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, int easy, short *x, short *y);
  80. // 攻撃関連
  81. int unit_stop_attack(struct block_list *bl);
  82. int unit_attack(struct block_list *src,int target_id,int continuous);
  83. int unit_cancel_combo(struct block_list *bl);
  84. // スキル使用
  85. int unit_skilluse_id(struct block_list *src, int target_id, short skill_num, short skill_lv);
  86. int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_y, short skill_num, short skill_lv);
  87. // スキル使用( 補正済みキャスト時間、キャンセル不可設定付き )
  88. int unit_skilluse_id2(struct block_list *src, int target_id, short skill_num, short skill_lv, int casttime, int castcancel);
  89. int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, short skill_num, short skill_lv, int casttime, int castcancel);
  90. // 詠唱キャンセル
  91. int unit_skillcastcancel(struct block_list *bl,int type);
  92. int unit_counttargeted(struct block_list *bl,int target_lv);
  93. // unit_data の初期化処理
  94. void unit_dataset(struct block_list *bl);
  95. int unit_fixdamage(struct block_list *src,struct block_list *target,unsigned int tick,int sdelay,int ddelay,int damage,int div,int type,int damage2);
  96. // その他
  97. struct unit_data* unit_bl2ud(struct block_list *bl);
  98. void unit_remove_map_pc(struct map_session_data *sd, int clrtype);
  99. void unit_free_pc(struct map_session_data *sd);
  100. #define unit_remove_map(bl,clrtype) unit_remove_map_(bl,clrtype,__FILE__,__LINE__,__func__)
  101. int unit_remove_map_(struct block_list *bl, int clrtype, const char* file, int line, const char* func);
  102. int unit_free(struct block_list *bl, int clrtype);
  103. int unit_changeviewsize(struct block_list *bl,short size);
  104. // 初期化ルーチン
  105. int do_init_unit(void);
  106. int do_final_unit(void);
  107. extern const short dirx[8];
  108. extern const short diry[8];
  109. #endif /* _UNIT_H_ */