diff options
author | madmaxoft <github@xoft.cz> | 2013-09-03 08:37:15 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-09-03 08:37:15 +0200 |
commit | 3a921955d94851b4f0148f69f3f0c35a227aa8f5 (patch) | |
tree | 7a19cc7ee486fc58f5f3a6739676d84b2878e27d | |
parent | Projectiles slow down in water and lava. (diff) | |
download | cuberite-3a921955d94851b4f0148f69f3f0c35a227aa8f5.tar cuberite-3a921955d94851b4f0148f69f3f0c35a227aa8f5.tar.gz cuberite-3a921955d94851b4f0148f69f3f0c35a227aa8f5.tar.bz2 cuberite-3a921955d94851b4f0148f69f3f0c35a227aa8f5.tar.lz cuberite-3a921955d94851b4f0148f69f3f0c35a227aa8f5.tar.xz cuberite-3a921955d94851b4f0148f69f3f0c35a227aa8f5.tar.zst cuberite-3a921955d94851b4f0148f69f3f0c35a227aa8f5.zip |
Diffstat (limited to '')
-rw-r--r-- | source/Entities/ProjectileEntity.cpp | 14 | ||||
-rw-r--r-- | source/Entities/ProjectileEntity.h | 3 |
2 files changed, 13 insertions, 4 deletions
diff --git a/source/Entities/ProjectileEntity.cpp b/source/Entities/ProjectileEntity.cpp index bef411559..c259cb52f 100644 --- a/source/Entities/ProjectileEntity.cpp +++ b/source/Entities/ProjectileEntity.cpp @@ -345,7 +345,8 @@ void cProjectileEntity::SpawnOn(cClientHandle & a_Client) 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) + m_DamageCoeff(2), + m_IsCritical(false) { SetSpeed(a_Speed); SetMass(0.1); @@ -361,7 +362,8 @@ 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, a_Player.GetThrowStartPos(), a_Player.GetThrowSpeed(a_Force * 1.5 * 20), 0.5, 0.5), m_PickupState(psInSurvivalOrCreative), - m_DamageCoeff(2) + m_DamageCoeff(2), + m_IsCritical((a_Force >= 1)) { } @@ -401,8 +403,12 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit) return; } - // TODO: The damage dealt should be based on arrow speed in addition to the damage coeff - a_EntityHit.TakeDamage(dtRangedAttack, this, (int)(2.5 * m_DamageCoeff), 1); + int Damage = (int)(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5); + if (m_IsCritical) + { + Damage += m_World->GetTickRandomNumber(Damage / 2 + 2); + } + a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1); Destroy(); } diff --git a/source/Entities/ProjectileEntity.h b/source/Entities/ProjectileEntity.h index da82c82ea..bd282d7e7 100644 --- a/source/Entities/ProjectileEntity.h +++ b/source/Entities/ProjectileEntity.h @@ -140,6 +140,9 @@ protected: /// The coefficient applied to the damage that the arrow will deal, based on the bow enchantment. 2.0 for normal arrow double m_DamageCoeff; + + /// If true, the arrow deals more damage + bool m_IsCritical; // cProjectileEntity overrides: virtual void SpawnOn(cClientHandle & a_Client) override; |