summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Entities/Pawn.cpp36
-rw-r--r--src/Mobs/AggressiveMonster.cpp2
-rw-r--r--src/Mobs/Chicken.cpp4
-rw-r--r--src/Mobs/Chicken.h2
4 files changed, 43 insertions, 1 deletions
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 126947d3e..5ca0c6126 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -4,6 +4,7 @@
#include "Pawn.h"
#include "../World.h"
#include "../Bindings/PluginManager.h"
+#include "BoundingBox.h"
@@ -43,6 +44,41 @@ void cPawn::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
// TODO: Check for discrepancies between client and server effect values
}
+
+ class Pusher : public cEntityCallback
+ {
+ public:
+ cEntity * m_Pusher;
+
+ Pusher(cEntity * a_Pusher) :
+ m_Pusher(a_Pusher)
+ {
+ }
+
+ virtual bool Item(cEntity * a_Entity) override
+ {
+ if (a_Entity->GetUniqueID() == m_Pusher->GetUniqueID())
+ {
+ return false;
+ }
+
+ // we only push other mobs, boats and minecarts
+ if ((a_Entity->GetEntityType() != etMonster) && (a_Entity->GetEntityType() != etMinecart) && (a_Entity->GetEntityType() != etBoat))
+ {
+ return false;
+ }
+
+ Vector3d v3Delta = a_Entity->GetPosition() - m_Pusher->GetPosition();
+ v3Delta.y = 0.0; // we only push sideways
+ v3Delta *= 1.0 / v3Delta.Length(); // we push harder if we're close
+ // QUESTION: is there an additional multiplier for this? current shoving seems a bit weak
+
+ a_Entity->AddSpeed(v3Delta);
+ return false;
+ }
+ } Callback(this);
+
+ m_World->ForEachEntityInBox(cBoundingBox(GetPosition(), GetWidth(), GetHeight()), Callback);
super::Tick(a_Dt, a_Chunk);
}
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp
index 65bda2dff..1355a3627 100644
--- a/src/Mobs/AggressiveMonster.cpp
+++ b/src/Mobs/AggressiveMonster.cpp
@@ -80,7 +80,7 @@ void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
Vector3d AttackDirection(m_Target->GetPosition() + Vector3d(0, m_Target->GetHeight(), 0) - MyHeadPosition);
- if (TargetIsInRange() && !LineOfSight.Trace(MyHeadPosition, AttackDirection, static_cast<int>(AttackDirection.Length())))
+ if (TargetIsInRange() && !LineOfSight.Trace(MyHeadPosition, AttackDirection, static_cast<int>(AttackDirection.Length())) && (GetHealth() > 0.0))
{
// Attack if reached destination, target isn't null, and have a clear line of sight to target (so won't attack through walls)
StopMovingToPosition();
diff --git a/src/Mobs/Chicken.cpp b/src/Mobs/Chicken.cpp
index a52d1a2da..71f401e6e 100644
--- a/src/Mobs/Chicken.cpp
+++ b/src/Mobs/Chicken.cpp
@@ -61,6 +61,10 @@ void cChicken::GetDrops(cItems & a_Drops, cEntity * a_Killer)
+void cChicken::HandleFalling(void)
+{
+ // empty - chickens don't take fall damage
+}
diff --git a/src/Mobs/Chicken.h b/src/Mobs/Chicken.h
index 9349187c6..05cf0ed39 100644
--- a/src/Mobs/Chicken.h
+++ b/src/Mobs/Chicken.h
@@ -21,6 +21,8 @@ public:
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_SEEDS); }
+ virtual void HandleFalling(void) override;
+
private:
int m_EggDropTimer;