diff options
author | Mattes D <github@xoft.cz> | 2014-04-25 23:41:04 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-04-25 23:41:04 +0200 |
commit | 43cca14763aa2a58150dec4b69bc31548f49ac36 (patch) | |
tree | 50008e0a730b255a55872ddb5784f483acb56cea /src/Entities/ProjectileEntity.cpp | |
parent | Merge pull request #938 from archshift/xcode-oops (diff) | |
parent | Creator not user. (diff) | |
download | cuberite-43cca14763aa2a58150dec4b69bc31548f49ac36.tar cuberite-43cca14763aa2a58150dec4b69bc31548f49ac36.tar.gz cuberite-43cca14763aa2a58150dec4b69bc31548f49ac36.tar.bz2 cuberite-43cca14763aa2a58150dec4b69bc31548f49ac36.tar.lz cuberite-43cca14763aa2a58150dec4b69bc31548f49ac36.tar.xz cuberite-43cca14763aa2a58150dec4b69bc31548f49ac36.tar.zst cuberite-43cca14763aa2a58150dec4b69bc31548f49ac36.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Entities/ProjectileEntity.cpp | 63 |
1 files changed, 57 insertions, 6 deletions
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 96db17ffd..fd3e80e5f 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -440,6 +440,7 @@ cArrowEntity::cArrowEntity(cPlayer & a_Player, double a_Force) : m_IsCritical((a_Force >= 1)), m_Timer(0), m_HitGroundTimer(0), + m_HasTeleported(false), m_bIsCollected(false), m_HitBlockPos(0, 0, 0) { @@ -562,12 +563,12 @@ void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk) // We can afford to do this because xoft's algorithm for trajectory is near perfect, so things are pretty close anyway without sync // Besides, this seems to be what the vanilla server does, note how arrows teleport half a second after they hit to the server position - if (m_HitGroundTimer != -1) // Sent a teleport already, don't do again + if (!m_HasTeleported) // Sent a teleport already, don't do again { if (m_HitGroundTimer > 1000.f) // Send after a second, could be less, but just in case { m_World->BroadcastTeleportEntity(*this); - m_HitGroundTimer = -1; + m_HasTeleported = true; } else { @@ -611,6 +612,32 @@ cThrownEggEntity::cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y, void cThrownEggEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { + TrySpawnChicken(a_HitPos); + + Destroy(); +} + + + + + +void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) +{ + int TotalDamage = 0; + // TODO: If entity is Ender Crystal, destroy it + + TrySpawnChicken(a_HitPos); + a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1); + + Destroy(true); +} + + + + + +void cThrownEggEntity::TrySpawnChicken(const Vector3d & a_HitPos) +{ if (m_World->GetTickRandomNumber(7) == 1) { m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken); @@ -622,7 +649,6 @@ void cThrownEggEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_H m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken); m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken); } - Destroy(); } @@ -644,15 +670,39 @@ cThrownEnderPearlEntity::cThrownEnderPearlEntity(cEntity * a_Creator, double a_X void cThrownEnderPearlEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { + // TODO: Tweak a_HitPos based on block face. + TeleportCreator(a_HitPos); + + Destroy(); +} + + + + + +void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) +{ + int TotalDamage = 0; + // TODO: If entity is Ender Crystal, destroy it + + TeleportCreator(a_HitPos); + a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1); + + Destroy(true); +} + + + + + +void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos) +{ // Teleport the creator here, make them take 5 damage: if (m_Creator != NULL) { - // TODO: The coords might need some tweaking based on the block face m_Creator->TeleportToCoords(a_HitPos.x + 0.5, a_HitPos.y + 1.7, a_HitPos.z + 0.5); m_Creator->TakeDamage(dtEnderPearl, this, 5, 0); } - - Destroy(); } @@ -696,6 +746,7 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & TotalDamage = 1; } } + // TODO: If entity is Ender Crystal, destroy it a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1); Destroy(true); |