summaryrefslogtreecommitdiffstats
path: root/src/Entities/ArrowEntity.cpp
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-01-12 11:13:36 +0100
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-01-12 11:13:36 +0100
commite2a053263f4798f879392756bb056eabf0ade3a4 (patch)
tree5d543baa8842fe74c4ed66984860be483d28c627 /src/Entities/ArrowEntity.cpp
parentMerge pull request #2853 from cuberite/DetailedBlockAreaLogging (diff)
parentTamed wolf assists owner (attack / defence) (diff)
downloadcuberite-e2a053263f4798f879392756bb056eabf0ade3a4.tar
cuberite-e2a053263f4798f879392756bb056eabf0ade3a4.tar.gz
cuberite-e2a053263f4798f879392756bb056eabf0ade3a4.tar.bz2
cuberite-e2a053263f4798f879392756bb056eabf0ade3a4.tar.lz
cuberite-e2a053263f4798f879392756bb056eabf0ade3a4.tar.xz
cuberite-e2a053263f4798f879392756bb056eabf0ade3a4.tar.zst
cuberite-e2a053263f4798f879392756bb056eabf0ade3a4.zip
Diffstat (limited to 'src/Entities/ArrowEntity.cpp')
-rw-r--r--src/Entities/ArrowEntity.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 76b4c9758..47789992c 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -102,6 +102,8 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa
void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
+ super::OnHitEntity(a_EntityHit, a_HitPos);
+
int Damage = static_cast<int>(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5);
if (m_IsCritical)
{
@@ -140,7 +142,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
// Broadcast successful hit sound
GetWorld()->BroadcastSoundEffect("random.successful_hit", GetPosX(), GetPosY(), GetPosZ(), 0.5, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
-
+
Destroy();
}
@@ -177,7 +179,7 @@ void cArrowEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
m_Timer += a_Dt;
-
+
if (m_bIsCollected)
{
if (m_Timer > std::chrono::milliseconds(500))
@@ -191,7 +193,7 @@ void cArrowEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
Destroy();
return;
}
-
+
if (m_IsInGround)
{
if (!m_HasTeleported) // Sent a teleport already, don't do again
@@ -206,17 +208,17 @@ void cArrowEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
m_HitGroundTimer += a_Dt;
}
}
-
+
int RelPosX = m_HitBlockPos.x - a_Chunk.GetPosX() * cChunkDef::Width;
int RelPosZ = m_HitBlockPos.z - a_Chunk.GetPosZ() * cChunkDef::Width;
cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(RelPosX, RelPosZ);
-
+
if (Chunk == nullptr)
{
// Inside an unloaded chunk, abort
return;
}
-
+
if (Chunk->GetBlock(RelPosX, m_HitBlockPos.y, RelPosZ) == E_BLOCK_AIR) // Block attached to was destroyed?
{
m_IsInGround = false; // Yes, begin simulating physics again