path.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #ifndef PATH_HPP
  4. #define PATH_HPP
  5. #include "../common/cbasetypes.hpp"
  6. enum cell_chk : uint8;
  7. #define MOVE_COST 10
  8. #define MOVE_DIAGONAL_COST 14
  9. #define MAX_WALKPATH 32
  10. enum directions : int8 {
  11. DIR_CENTER = -1,
  12. DIR_NORTH = 0,
  13. DIR_NORTHWEST = 1,
  14. DIR_WEST = 2,
  15. DIR_SOUTHWEST = 3,
  16. DIR_SOUTH = 4,
  17. DIR_SOUTHEAST = 5,
  18. DIR_EAST = 6,
  19. DIR_NORTHEAST = 7,
  20. DIR_MAX
  21. };
  22. struct walkpath_data {
  23. unsigned char path_len,path_pos;
  24. enum directions path[MAX_WALKPATH];
  25. };
  26. struct shootpath_data {
  27. int rx,ry,len;
  28. int x[MAX_WALKPATH];
  29. int y[MAX_WALKPATH];
  30. };
  31. #define check_distance_bl(bl1, bl2, distance) check_distance((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y, distance)
  32. #define check_distance_blxy(bl, x1, y1, distance) check_distance((bl)->x-(x1), (bl)->y-(y1), distance)
  33. #define check_distance_xy(x0, y0, x1, y1, distance) check_distance((x0)-(x1), (y0)-(y1), distance)
  34. #define distance_bl(bl1, bl2) distance((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y)
  35. #define distance_blxy(bl, x1, y1) distance((bl)->x-(x1), (bl)->y-(y1))
  36. #define distance_xy(x0, y0, x1, y1) distance((x0)-(x1), (y0)-(y1))
  37. #define check_distance_client_bl(bl1, bl2, distance) check_distance_client((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y, distance)
  38. #define check_distance_client_blxy(bl, x1, y1, distance) check_distance_client((bl)->x-(x1), (bl)->y-(y1), distance)
  39. #define check_distance_client_xy(x0, y0, x1, y1, distance) check_distance_client((x0)-(x1), (y0)-(y1), distance)
  40. #define distance_client_bl(bl1, bl2) distance_client((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y)
  41. #define distance_client_blxy(bl, x1, y1) distance_client((bl)->x-(x1), (bl)->y-(y1))
  42. #define distance_client_xy(x0, y0, x1, y1) distance_client((x0)-(x1), (y0)-(y1))
  43. // calculates destination cell for knockback
  44. int path_blownpos(int16 m,int16 x0,int16 y0,int16 dx,int16 dy,int count);
  45. // tries to find a walkable path
  46. bool path_search(struct walkpath_data *wpd,int16 m,int16 x0,int16 y0,int16 x1,int16 y1,int flag,cell_chk cell);
  47. // tries to find a shootable path
  48. bool path_search_long(struct shootpath_data *spd,int16 m,int16 x0,int16 y0,int16 x1,int16 y1,cell_chk cell);
  49. // distance related functions
  50. bool check_distance(int dx, int dy, int distance);
  51. unsigned int distance(int dx, int dy);
  52. bool check_distance_client(int dx, int dy, int distance);
  53. int distance_client(int dx, int dy);
  54. bool direction_diagonal( enum directions direction );
  55. bool direction_opposite( enum directions direction );
  56. //
  57. void do_init_path();
  58. void do_final_path();
  59. #endif /* PATH_HPP */