summaryrefslogtreecommitdiffstats
path: root/source/Entities/ProjectileEntity.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-08-30 18:10:58 +0200
committermadmaxoft <github@xoft.cz>2013-08-30 18:10:58 +0200
commitd7a52870003e46858bec65cc76880cecc5de7bb8 (patch)
tree67d10f543dc8ed0b49da5ecb61cc0d989a246309 /source/Entities/ProjectileEntity.cpp
parentMoved throw pos and speed calculation from cProjectileEntity into cPlayer. (diff)
downloadcuberite-d7a52870003e46858bec65cc76880cecc5de7bb8.tar
cuberite-d7a52870003e46858bec65cc76880cecc5de7bb8.tar.gz
cuberite-d7a52870003e46858bec65cc76880cecc5de7bb8.tar.bz2
cuberite-d7a52870003e46858bec65cc76880cecc5de7bb8.tar.lz
cuberite-d7a52870003e46858bec65cc76880cecc5de7bb8.tar.xz
cuberite-d7a52870003e46858bec65cc76880cecc5de7bb8.tar.zst
cuberite-d7a52870003e46858bec65cc76880cecc5de7bb8.zip
Diffstat (limited to '')
-rw-r--r--source/Entities/ProjectileEntity.cpp91
1 files changed, 88 insertions, 3 deletions
diff --git a/source/Entities/ProjectileEntity.cpp b/source/Entities/ProjectileEntity.cpp
index 1dbc46ca1..91b2c97a8 100644
--- a/source/Entities/ProjectileEntity.cpp
+++ b/source/Entities/ProjectileEntity.cpp
@@ -101,11 +101,14 @@ cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator,
switch (a_Kind)
{
- case pkArrow: return new cArrowEntity(a_Creator, a_X, a_Y, a_Z, Speed);
+ case pkArrow: return new cArrowEntity (a_Creator, a_X, a_Y, a_Z, Speed);
+ case pkEgg: return new cThrownEggEntity (a_Creator, a_X, a_Y, a_Z, Speed);
+ case pkEnderPearl: return new cThrownEnderPearlEntity(a_Creator, a_X, a_Y, a_Z, Speed);
+ case pkSnowball: return new cThrownSnowballEntity (a_Creator, a_X, a_Y, a_Z, Speed);
// TODO: the rest
}
- LOGWARNING("%s: Unknown kind: %d", __FUNCTION__, a_Kind);
+ LOGWARNING("%s: Unknown projectile kind: %d", __FUNCTION__, a_Kind);
return NULL;
}
@@ -210,10 +213,20 @@ void cProjectileEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
+void cProjectileEntity::SpawnOn(cClientHandle & a_Client)
+{
+ // Default spawning - use the projectile kind to spawn an object:
+ a_Client.SendSpawnObject(*this, m_ProjectileKind, 0, 0, 0);
+}
+
+
+
+
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cArrowEntity:
-cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d a_Speed) :
+cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
super(pkArrow, a_Creator, a_X, a_Y, a_Z, 0.5, 0.5),
m_PickupState(psNoPickup),
m_DamageCoeff(2)
@@ -264,3 +277,75 @@ void cArrowEntity::SpawnOn(cClientHandle & a_Client)
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cThrownEggEntity:
+
+cThrownEggEntity::cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
+ super(pkEgg, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
+{
+ SetSpeed(a_Speed);
+}
+
+
+
+
+
+void cThrownEggEntity::OnHitSolidBlock(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace)
+{
+ // TODO: Random-spawn a chicken or four
+
+ Destroy();
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cThrownEnderPearlEntity :
+
+cThrownEnderPearlEntity::cThrownEnderPearlEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
+ super(pkEnderPearl, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
+{
+ SetSpeed(a_Speed);
+}
+
+
+
+
+
+void cThrownEnderPearlEntity::OnHitSolidBlock(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace)
+{
+ // TODO: Teleport the creator here, make them take 5 damage
+
+ Destroy();
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cThrownSnowballEntity :
+
+cThrownSnowballEntity::cThrownSnowballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
+ super(pkSnowball, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
+{
+ SetSpeed(a_Speed);
+}
+
+
+
+
+
+void cThrownSnowballEntity::OnHitSolidBlock(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace)
+{
+ // TODO: Apply damage to certain mobs (blaze etc.) and anger all mobs
+
+ Destroy();
+}
+
+
+
+
+