summaryrefslogtreecommitdiffstats
path: root/source/Entities/ProjectileEntity.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-08-30 14:24:03 +0200
committermadmaxoft <github@xoft.cz>2013-08-30 14:24:03 +0200
commit17ad4c2610f2c33d5b4a8b42b7d4b8fbda9ade32 (patch)
treefeaaf5bf652bfdc542dee9b9c452391531aee6ba /source/Entities/ProjectileEntity.cpp
parentImplemented basic physics for projectiles. (diff)
downloadcuberite-17ad4c2610f2c33d5b4a8b42b7d4b8fbda9ade32.tar
cuberite-17ad4c2610f2c33d5b4a8b42b7d4b8fbda9ade32.tar.gz
cuberite-17ad4c2610f2c33d5b4a8b42b7d4b8fbda9ade32.tar.bz2
cuberite-17ad4c2610f2c33d5b4a8b42b7d4b8fbda9ade32.tar.lz
cuberite-17ad4c2610f2c33d5b4a8b42b7d4b8fbda9ade32.tar.xz
cuberite-17ad4c2610f2c33d5b4a8b42b7d4b8fbda9ade32.tar.zst
cuberite-17ad4c2610f2c33d5b4a8b42b7d4b8fbda9ade32.zip
Diffstat (limited to 'source/Entities/ProjectileEntity.cpp')
-rw-r--r--source/Entities/ProjectileEntity.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/source/Entities/ProjectileEntity.cpp b/source/Entities/ProjectileEntity.cpp
index 4983943a9..f405e9aa4 100644
--- a/source/Entities/ProjectileEntity.cpp
+++ b/source/Entities/ProjectileEntity.cpp
@@ -229,6 +229,47 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a
+cArrowEntity::cArrowEntity(cPlayer & a_Player, double a_Force) :
+ super(pkArrow, &a_Player, PosFromPlayerPos(a_Player), SpeedFromPlayerLook(a_Player, a_Force), 0.5, 0.5),
+ m_PickupState(psInSurvivalOrCreative),
+ m_DamageCoeff(2)
+{
+}
+
+
+
+
+
+Vector3d cArrowEntity::PosFromPlayerPos(const cPlayer & a_Player)
+{
+ Vector3d res = a_Player.GetEyePosition();
+
+ // Adjust the position to be just outside the player's bounding box:
+ res.x += 0.16 * cos(a_Player.GetPitch());
+ res.y += -0.1;
+ res.z += 0.16 * sin(a_Player.GetPitch());
+
+ return res;
+}
+
+
+
+
+
+Vector3d cArrowEntity::SpeedFromPlayerLook(const cPlayer & a_Player, double a_Force)
+{
+ Vector3d res = a_Player.GetLookVector();
+ res.Normalize();
+
+ // TODO: Add a slight random change (+-0.0075 in each direction)
+
+ return res * a_Force * 1.5 * 20;
+}
+
+
+
+
+
bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
{
switch (m_PickupState)