diff --git a/Include/Core/Classes/Region.hpp b/Include/Core/Classes/Region.hpp index 455fe16..388e172 100644 --- a/Include/Core/Classes/Region.hpp +++ b/Include/Core/Classes/Region.hpp @@ -17,6 +17,7 @@ namespace Internal Region(const Region& R); static Class GetClass(); + std::int32_t GetEntityCount() const; std::vector GetGameObjects() const; GameObject GetGameObjects(std::int32_t I) const; std::vector>> GetSceneTiles() const; diff --git a/Include/Core/Math.hpp b/Include/Core/Math.hpp index f83caa9..f26684d 100644 --- a/Include/Core/Math.hpp +++ b/Include/Core/Math.hpp @@ -14,7 +14,6 @@ std::int32_t UniformRandom(std::int32_t Min, std::int32_t Max); double UniformRandom(); std::int32_t NormalRandom(std::int32_t Mean, double StandardDeviation); std::int32_t NormalRandom(std::int32_t Low, std::int32_t High, double PercentageDeviation); -std::vector Spiral(Point Start, Box Area); std::vector ConvexHull(std::vector Points); /** @} */ diff --git a/Include/Game/Core.hpp b/Include/Game/Core.hpp index 46f595a..09a21bb 100644 --- a/Include/Game/Core.hpp +++ b/Include/Game/Core.hpp @@ -11,6 +11,7 @@ #include "Tools/Worlds.hpp" #include "Tools/RandomHandler.hpp" #include "Tools/Camera.hpp" +#include "Tools/Pathfinding.hpp" #include "Interfaces/Bank.hpp" #include "Interfaces/Chat.hpp" diff --git a/Include/Game/Interactable/DecorativeObject.hpp b/Include/Game/Interactable/DecorativeObject.hpp index 9abc1f4..873e9c7 100644 --- a/Include/Game/Interactable/DecorativeObject.hpp +++ b/Include/Game/Interactable/DecorativeObject.hpp @@ -31,6 +31,8 @@ namespace Interactable double GetVisibility() const; Tile GetTile() const; + Tile GetReachableTile() const; + bool IsReachable() const; bool RotateTo(std::int32_t Angle = 0) const; bool RotateTo(Camera::COMPASS_DIRECTION Direction) const; diff --git a/Include/Game/Interactable/GameObject.hpp b/Include/Game/Interactable/GameObject.hpp index 538298b..2951c7f 100644 --- a/Include/Game/Interactable/GameObject.hpp +++ b/Include/Game/Interactable/GameObject.hpp @@ -31,6 +31,10 @@ namespace Interactable double GetVisibility() const; Tile GetTile() const; + Tile GetReachableTile() const; + Tile GetMin() const; + Tile GetMax() const; + bool IsReachable() const; bool RotateTo(std::int32_t Angle = 0) const; bool RotateTo(Camera::COMPASS_DIRECTION Direction) const; diff --git a/Include/Game/Interactable/GroundItem.hpp b/Include/Game/Interactable/GroundItem.hpp index cc1bca1..b09aad9 100644 --- a/Include/Game/Interactable/GroundItem.hpp +++ b/Include/Game/Interactable/GroundItem.hpp @@ -34,6 +34,8 @@ namespace Interactable double GetVisibility() const; Tile GetTile() const; Tile GetLocalTile() const; + Tile GetReachableTile() const; + bool IsReachable() const; bool RotateTo(std::int32_t Angle = 0) const; bool RotateTo(Camera::COMPASS_DIRECTION Direction) const; diff --git a/Include/Game/Interactable/GroundObject.hpp b/Include/Game/Interactable/GroundObject.hpp index 57c0860..23f9d82 100644 --- a/Include/Game/Interactable/GroundObject.hpp +++ b/Include/Game/Interactable/GroundObject.hpp @@ -31,6 +31,8 @@ namespace Interactable double GetVisibility() const; Tile GetTile() const; + Tile GetReachableTile() const; + bool IsReachable() const; bool RotateTo(std::int32_t Angle = 0) const; bool RotateTo(Camera::COMPASS_DIRECTION Direction) const; diff --git a/Include/Game/Interactable/NPC.hpp b/Include/Game/Interactable/NPC.hpp index 484d85c..790bc7c 100644 --- a/Include/Game/Interactable/NPC.hpp +++ b/Include/Game/Interactable/NPC.hpp @@ -31,6 +31,8 @@ namespace Interactable double GetVisibility() const; Tile GetTile() const; + Tile GetReachableTile() const; + bool IsReachable() const; bool RotateTo(std::int32_t Angle = 0) const; bool RotateTo(Camera::COMPASS_DIRECTION Direction) const; diff --git a/Include/Game/Interactable/Player.hpp b/Include/Game/Interactable/Player.hpp index 9e809e3..44befe0 100644 --- a/Include/Game/Interactable/Player.hpp +++ b/Include/Game/Interactable/Player.hpp @@ -30,6 +30,8 @@ namespace Interactable double GetVisibility() const; Tile GetTile() const; + Tile GetReachableTile() const; + bool IsReachable() const; bool RotateTo(std::int32_t Angle = 0) const; bool RotateTo(Camera::COMPASS_DIRECTION Direction) const; diff --git a/Include/Game/Interactable/WallObject.hpp b/Include/Game/Interactable/WallObject.hpp index 0febb12..232e8c5 100644 --- a/Include/Game/Interactable/WallObject.hpp +++ b/Include/Game/Interactable/WallObject.hpp @@ -31,6 +31,8 @@ namespace Interactable double GetVisibility() const; Tile GetTile() const; + Tile GetReachableTile() const; + bool IsReachable() const; bool RotateTo(std::int32_t Angle = 0) const; bool RotateTo(Camera::COMPASS_DIRECTION Direction) const; diff --git a/Include/Game/Interfaces/Minimap.hpp b/Include/Game/Interfaces/Minimap.hpp index cca3738..86c7a08 100644 --- a/Include/Game/Interfaces/Minimap.hpp +++ b/Include/Game/Interfaces/Minimap.hpp @@ -65,6 +65,13 @@ class Minimap * @return true if the function succesfully clicked the orb */ static bool ClickQuickPrayer(); + + /** + * @brief Clicks the toggle-run orb + * + * @return true if the function succesfully clicked the orb + */ + static bool ClickToggleRun(); }; /** @} */ diff --git a/Include/Game/Tools/Pathfinding.hpp b/Include/Game/Tools/Pathfinding.hpp new file mode 100644 index 0000000..266c3fe --- /dev/null +++ b/Include/Game/Tools/Pathfinding.hpp @@ -0,0 +1,92 @@ +#ifndef PATHFINDING_HPP_INCLUDED +#define PATHFINDING_HPP_INCLUDED + +#include "../../Core/Types/Tile.hpp" +#include +#include + +class Pathfinding +{ + public: + + enum COLLISION_FLAG + { + OPEN = 0, + CLOSED = 0xFFFFFF, + UNINITIALIZED = 0x1000000, + OCCUPIED = 0x100, + SOLID = 0x20000, + BLOCKED = 0x200000, + + NORTH = 0x2, + EAST = 0x8, + SOUTH = 0x20, + WEST = 0x80, + + NORTHEAST = 0x4, + SOUTHEAST = 0x10, + SOUTHWEST = 0x40, + NORTHWEST = 0x1, + + BLOCKED_NORTH = 0x400, + BLOCKED_EAST = 0x1000, + BLOCKED_SOUTH = 0x4000, + BLOCKED_WEST = 0x10000, + + BLOCKED_NORTHEAST = 0x800, + BLOCKED_SOUTHEAST = 0x2000, + BLOCKED_NORTHWEST = 0x200, + BLOCKED_SOUTHWEST = 0x8000, + }; + + typedef enum PATHFINDER + { + BREADTH_FIRST_SEARCH + } PATHFINDER; + + class TileNode + { + public: + std::int32_t X; + std::int32_t Y; + std::int32_t Flag; + bool Inspected; + std::int32_t Parent[2]; + TileNode(); + TileNode(std::int32_t X, std::int32_t Y, std::int32_t Flag); + bool IsBlocked(bool AllowOccupied = true) const; + Tile ToWorldTile() const; + bool operator==(const TileNode& N) const; + operator bool() const; + }; + + static void RegenerateNodes(); + static std::vector> GetNodes(); + + static Tile FindWalkableTile(const Tile& T); + static Tile FindWalkableTile(const Tile& T, const Tile& Min, const Tile& Max); + static std::vector FindWalkableTiles(const Tile& T); + static std::vector FindWalkableTiles(const Tile& T, const Tile& Min, const Tile& Max); + + static std::vector FindPathTo(const Tile& Goal, bool AllowOccupied = false, PATHFINDER Finder = BREADTH_FIRST_SEARCH); + static std::vector FindPathTo(const std::vector& Goals, bool AllowOccupied = false, PATHFINDER Finder = BREADTH_FIRST_SEARCH); + // Ignores collision + static std::vector FindDirectPathTo(const Tile& Goal, PATHFINDER Finder = BREADTH_FIRST_SEARCH); + static std::vector FindDirectPathTo(const std::vector& Goals, PATHFINDER Finder = BREADTH_FIRST_SEARCH); + + + + static bool IsInside(std::uint32_t X, std::uint32_t Y); + static std::vector GetNeighborsTo(std::uint32_t X, std::uint32_t Y, bool AllowOccupied = false, bool CheckCollision = true); + static std::vector Finder_BFS( std::uint32_t StartX, std::uint32_t StartY, + std::uint32_t EndX, std::uint32_t EndY, + bool AllowOccupied = false, bool CheckCollision = true ); + + static std::vector Finder_BFS( std::uint32_t StartX, std::uint32_t StartY, + const std::vector>& Ends, + bool AllowOccupied = false, bool CheckCollision = true ); + private: + static std::vector> Nodes; +}; + +#endif // PATHFINDING_HPP_INCLUDED diff --git a/Library/libAlpacaLibrary.a b/Library/libAlpacaLibrary.a index e3d4fa4..90a5232 100644 Binary files a/Library/libAlpacaLibrary.a and b/Library/libAlpacaLibrary.a differ