summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs')
-rw-r--r--src/Mobs/Monster.cpp22
-rw-r--r--src/Mobs/Monster.h4
2 files changed, 21 insertions, 5 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index dfcd0dd6a..09f937564 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -132,12 +132,12 @@ cMonster::~cMonster()
-void cMonster::Destroy(bool a_ShouldBroadcast)
+void cMonster::OnRemoveFromWorld(cWorld & a_World)
{
if (IsLeashed())
{
cEntity * LeashedTo = GetLeashedTo();
- Unleash(false, a_ShouldBroadcast);
+ Unleash(false, true);
// Remove leash knot if there are no more mobs leashed to
if (!LeashedTo->HasAnyMobLeashed() && LeashedTo->IsLeashKnot())
@@ -146,7 +146,7 @@ void cMonster::Destroy(bool a_ShouldBroadcast)
}
}
- super::Destroy(a_ShouldBroadcast);
+ super::OnRemoveFromWorld(a_World);
}
@@ -282,7 +282,7 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
m_DestroyTimer += a_Dt;
if (m_DestroyTimer > std::chrono::seconds(1))
{
- Destroy(true);
+ Destroy();
}
return;
}
@@ -590,6 +590,20 @@ bool cMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
+void cMonster::DoMoveToWorld(const cEntity::sWorldChangeInfo & a_WorldChangeInfo)
+{
+ // Stop all mobs from targeting this entity
+ // Stop this entity from targeting other mobs
+ SetTarget(nullptr);
+ StopEveryoneFromTargetingMe();
+
+ super::DoMoveToWorld(a_WorldChangeInfo);
+}
+
+
+
+
+
void cMonster::KilledBy(TakeDamageInfo & a_TDI)
{
super::KilledBy(a_TDI);
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 11d49b82e..676e8ebe5 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -43,7 +43,7 @@ public:
virtual ~cMonster() override;
- virtual void Destroy(bool a_ShouldBroadcast = true) override;
+ virtual void OnRemoveFromWorld(cWorld & a_World) override;
virtual void Destroyed() override;
@@ -319,6 +319,8 @@ protected:
/** Adds weapon that is equipped with the chance saved in m_DropChance[...] (this will be greter than 1 if picked up or 0.085 + (0.01 per LootingLevel) if born with) to the drop */
void AddRandomWeaponDropItem(cItems & a_Drops, unsigned int a_LootingLevel);
+ virtual void DoMoveToWorld(const cEntity::sWorldChangeInfo & a_WorldChangeInfo) override;
+
private:
/** A pointer to the entity this mobile is aiming to reach.
The validity of this pointer SHALL be guaranteed by the pointee;