summaryrefslogtreecommitdiffstats
path: root/source/Entities/Entity.cpp
diff options
context:
space:
mode:
authormgueydan <gueydan.mathieuÃ@gmail.com>2013-09-22 14:29:33 +0200
committermgueydan <gueydan.mathieuÃ@gmail.com>2013-09-22 14:29:33 +0200
commitac4cb65b8d8443c6bb7835934f4b74dc2bdb820d (patch)
tree6f869625bd6a4509e37231194d777fc4e9df7d5e /source/Entities/Entity.cpp
parentInside cMonster::getMobFamily() : replacing Polymorphism by Map, in order to remove redundancy (diff)
parentMerged branch 'Projectiles'. (diff)
downloadcuberite-ac4cb65b8d8443c6bb7835934f4b74dc2bdb820d.tar
cuberite-ac4cb65b8d8443c6bb7835934f4b74dc2bdb820d.tar.gz
cuberite-ac4cb65b8d8443c6bb7835934f4b74dc2bdb820d.tar.bz2
cuberite-ac4cb65b8d8443c6bb7835934f4b74dc2bdb820d.tar.lz
cuberite-ac4cb65b8d8443c6bb7835934f4b74dc2bdb820d.tar.xz
cuberite-ac4cb65b8d8443c6bb7835934f4b74dc2bdb820d.tar.zst
cuberite-ac4cb65b8d8443c6bb7835934f4b74dc2bdb820d.zip
Diffstat (limited to 'source/Entities/Entity.cpp')
-rw-r--r--source/Entities/Entity.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/source/Entities/Entity.cpp b/source/Entities/Entity.cpp
index 4066e81ab..1a593b3d1 100644
--- a/source/Entities/Entity.cpp
+++ b/source/Entities/Entity.cpp
@@ -253,6 +253,39 @@ void cEntity::TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_R
+void cEntity::SetRotationFromSpeed(void)
+{
+ const double EPS = 0.0000001;
+ if ((abs(m_Speed.x) < EPS) && (abs(m_Speed.z) < EPS))
+ {
+ // atan2() may overflow or is undefined, pick any number
+ SetRotation(0);
+ return;
+ }
+ SetRotation(atan2(m_Speed.x, m_Speed.z) * 180 / PI);
+}
+
+
+
+
+
+void cEntity::SetPitchFromSpeed(void)
+{
+ const double EPS = 0.0000001;
+ double xz = sqrt(m_Speed.x * m_Speed.x + m_Speed.z * m_Speed.z); // Speed XZ-plane component
+ if ((abs(xz) < EPS) && (abs(m_Speed.y) < EPS))
+ {
+ // atan2() may overflow or is undefined, pick any number
+ SetPitch(0);
+ return;
+ }
+ SetPitch(atan2(m_Speed.y, xz) * 180 / PI);
+}
+
+
+
+
+
void cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if (cRoot::Get()->GetPluginManager()->CallHookTakeDamage(*this, a_TDI))