summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-06-01 10:43:37 +0200
committerMattes D <github@xoft.cz>2014-06-01 10:43:37 +0200
commit2059944d1e39e952c164b8a87c0c3f216b3b731e (patch)
treefd210c1cf1bfcda2f7ed1292df01a26f9555c057 /src/Mobs
parentInitial commit of the Generator article. (diff)
parentUpdated AlchemistVillage prefabs. (diff)
downloadcuberite-2059944d1e39e952c164b8a87c0c3f216b3b731e.tar
cuberite-2059944d1e39e952c164b8a87c0c3f216b3b731e.tar.gz
cuberite-2059944d1e39e952c164b8a87c0c3f216b3b731e.tar.bz2
cuberite-2059944d1e39e952c164b8a87c0c3f216b3b731e.tar.lz
cuberite-2059944d1e39e952c164b8a87c0c3f216b3b731e.tar.xz
cuberite-2059944d1e39e952c164b8a87c0c3f216b3b731e.tar.zst
cuberite-2059944d1e39e952c164b8a87c0c3f216b3b731e.zip
Diffstat (limited to 'src/Mobs')
-rw-r--r--src/Mobs/Monster.cpp6
-rw-r--r--src/Mobs/Wither.cpp34
-rw-r--r--src/Mobs/Wither.h1
3 files changed, 40 insertions, 1 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 62670907f..a9ca7a2fa 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -355,6 +355,8 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
InStateEscaping(a_Dt);
break;
}
+
+ case ATTACKING: break;
} // switch (m_EMState)
BroadcastMovementUpdate();
@@ -464,8 +466,10 @@ bool cMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
return false;
}
- if((m_SoundHurt != "") && (m_Health > 0))
+ if (!m_SoundHurt.empty() && (m_Health > 0))
+ {
m_World->BroadcastSoundEffect(m_SoundHurt, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f);
+ }
if (a_TDI.Attacker != NULL)
{
diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp
index 5b6e895e1..170f4fdc0 100644
--- a/src/Mobs/Wither.cpp
+++ b/src/Mobs/Wither.cpp
@@ -2,7 +2,9 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Wither.h"
+
#include "../World.h"
+#include "../Entities/Player.h"
@@ -100,3 +102,35 @@ void cWither::GetDrops(cItems & a_Drops, cEntity * a_Killer)
+
+void cWither::KilledBy(cEntity * a_Killer)
+{
+ super::KilledBy(a_Killer);
+
+ class cPlayerCallback : public cPlayerListCallback
+ {
+ Vector3f m_Pos;
+
+ virtual bool Item(cPlayer * a_Player)
+ {
+ // TODO 2014-05-21 xdot: Vanilla minecraft uses an AABB check instead of a radius one
+ double Dist = (a_Player->GetPosition() - m_Pos).Length();
+ if (Dist < 50.0)
+ {
+ // If player is close, award achievement
+ a_Player->AwardAchievement(achKillWither);
+ }
+ return false;
+ }
+
+ public:
+ cPlayerCallback(const Vector3f & a_Pos) : m_Pos(a_Pos) {}
+
+ } PlayerCallback(GetPosition());
+
+ m_World->ForEachPlayer(PlayerCallback);
+}
+
+
+
+
diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h
index 08b460009..93b4f8bfc 100644
--- a/src/Mobs/Wither.h
+++ b/src/Mobs/Wither.h
@@ -29,6 +29,7 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void KilledBy(cEntity * a_Killer) override;
private: