summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Monster.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs/Monster.h')
-rw-r--r--src/Mobs/Monster.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 268db6168..ab5b2cf2f 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -43,6 +43,8 @@ public:
virtual ~cMonster() override;
+ virtual void Destroy(bool a_ShouldBroadcast = true) override;
+
virtual void Destroyed() override;
CLASS_PROTODEF(cMonster)
@@ -71,6 +73,37 @@ public:
virtual void CheckEventSeePlayer(cChunk & a_Chunk);
virtual void EventSeePlayer(cPlayer * a_Player, cChunk & a_Chunk);
+ // tolua_begin
+
+ /** Returns whether the mob can be leashed. */
+ bool CanBeLeashed() const { return m_CanBeLeashed; }
+
+ /** Sets whether the mob can be leashed, for extensibility in plugins */
+ void SetCanBeLeashed(bool a_CanBeLeashed) { m_CanBeLeashed = a_CanBeLeashed; }
+
+ /** Returns whether the monster is leashed to an entity. */
+ bool IsLeashed() const { return (m_LeashedTo != nullptr); }
+
+ /** Leash the monster to an entity. */
+ void LeashTo(cEntity * a_Entity, bool a_ShouldBroadcast = true);
+
+ /** Unleash the monster. Overload for the Unleash(bool, bool) function for plugins */
+ void Unleash(bool a_ShouldDropLeashPickup);
+
+ /** Returns the entity to where this mob is leashed, returns nullptr if it's not leashed */
+ cEntity * GetLeashedTo() const { return m_LeashedTo; }
+
+ // tolua_end
+
+ /** Unleash the monster. */
+ void Unleash(bool a_ShouldDropLeashPickup, bool a_ShouldBroadcast);
+
+ /** Sets entity position to where is leashed this mob */
+ void SetLeashToPos(Vector3d * pos) { m_LeashToPos = std::unique_ptr<Vector3d>(pos); }
+
+ /** Gets entity position to where mob should be leashed */
+ Vector3d * GetLeashToPos() const { return m_LeashToPos.get(); }
+
/** Reads the monster configuration for the specified monster name and assigns it to this object. */
void GetMonsterConfig(const AString & a_Name);
@@ -260,6 +293,18 @@ protected:
bool m_WasLastTargetAPlayer;
+ /** Entity leashed to */
+ cEntity * m_LeashedTo;
+
+ /** Entity pos where this mob was leashed to. Used when deserializing the chunk in order to make the mob find the leash knot. */
+ std::unique_ptr<Vector3d> m_LeashToPos;
+
+ /** Mob has ben leashed or unleashed in current player action. Avoids double actions on horses. */
+ bool m_IsLeashActionJustDone;
+
+ /** Determines whether a monster can be leashed */
+ bool m_CanBeLeashed;
+
/** Adds a random number of a_Item between a_Min and a_Max to itemdrops a_Drops */
void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0);
@@ -281,4 +326,7 @@ private:
it MUST be reset when the pointee changes worlds or is destroyed. */
cPawn * m_Target;
+ /** Leash calculations inside Tick function */
+ void CalcLeashActions();
+
} ; // tolua_export