From 1b0e21e0b270b3938b81df119d5a741a3e1e1257 Mon Sep 17 00:00:00 2001 From: wiseoldman95 Date: Wed, 29 Apr 2015 19:24:14 +0300 Subject: A* Pathfinding and better monster AI --- src/Mobs/Monster.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/Mobs/Monster.h') diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 21ed0c25a..43861e021 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -10,11 +10,12 @@ - - class cClientHandle; class cWorld; +// Fwd: cPath +enum class ePathFinderStatus; +class cPath; @@ -61,6 +62,7 @@ public: virtual void OnRightClicked(cPlayer & a_Player) override; virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export + virtual void StopMovingToPosition(); virtual bool ReachedDestination(void); // tolua_begin @@ -162,6 +164,11 @@ protected: /** A pointer to the entity this mobile is aiming to reach */ cEntity * m_Target; + cPath * m_Path; // TODO unique ptr + ePathFinderStatus m_PathStatus; + bool m_IsFollowingPath; + /* If 0, will give up reaching the next m_Dest and will re-compute path. */ + int m_GiveUpCounter; /** Coordinates of the next position that should be reached */ Vector3d m_Destination; /** Coordinates for the ultimate, final destination. */ @@ -201,11 +208,7 @@ protected: This is based on the ultimate, final destination and the current position, as well as the traversed coordinates, and any environmental hazards */ void TickPathFinding(void); /** Finishes a pathfinding task, be it due to failure or something else */ - inline void FinishPathFinding(void) - { - m_TraversedCoordinates.clear(); - m_bMovingToDestination = false; - } + void FinishPathFinding(void); /** Sets the body yaw and head yaw/pitch based on next/ultimate destinations */ void SetPitchAndYawFromDestination(void); @@ -239,10 +242,11 @@ protected: float m_DropChanceLeggings; float m_DropChanceBoots; bool m_CanPickUpLoot; + int m_TicksSinceLastDamaged; // How many ticks ago we were last damaged by a player? void HandleDaylightBurning(cChunk & a_Chunk); + bool WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk); bool m_BurnsInDaylight; - double m_RelativeWalkSpeed; /** Adds a random number of a_Item between a_Min and a_Max to itemdrops a_Drops*/ -- cgit v1.2.3