Arrows deal damage based on their speed.
This commit is contained in:
parent
e8b77ea2f5
commit
3a921955d9
@ -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) :
|
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),
|
super(pkArrow, a_Creator, a_X, a_Y, a_Z, 0.5, 0.5),
|
||||||
m_PickupState(psNoPickup),
|
m_PickupState(psNoPickup),
|
||||||
m_DamageCoeff(2)
|
m_DamageCoeff(2),
|
||||||
|
m_IsCritical(false)
|
||||||
{
|
{
|
||||||
SetSpeed(a_Speed);
|
SetSpeed(a_Speed);
|
||||||
SetMass(0.1);
|
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) :
|
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),
|
super(pkArrow, &a_Player, a_Player.GetThrowStartPos(), a_Player.GetThrowSpeed(a_Force * 1.5 * 20), 0.5, 0.5),
|
||||||
m_PickupState(psInSurvivalOrCreative),
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: The damage dealt should be based on arrow speed in addition to the damage coeff
|
int Damage = (int)(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5);
|
||||||
a_EntityHit.TakeDamage(dtRangedAttack, this, (int)(2.5 * m_DamageCoeff), 1);
|
if (m_IsCritical)
|
||||||
|
{
|
||||||
|
Damage += m_World->GetTickRandomNumber(Damage / 2 + 2);
|
||||||
|
}
|
||||||
|
a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1);
|
||||||
|
|
||||||
Destroy();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
@ -141,6 +141,9 @@ protected:
|
|||||||
/// The coefficient applied to the damage that the arrow will deal, based on the bow enchantment. 2.0 for normal arrow
|
/// The coefficient applied to the damage that the arrow will deal, based on the bow enchantment. 2.0 for normal arrow
|
||||||
double m_DamageCoeff;
|
double m_DamageCoeff;
|
||||||
|
|
||||||
|
/// If true, the arrow deals more damage
|
||||||
|
bool m_IsCritical;
|
||||||
|
|
||||||
// cProjectileEntity overrides:
|
// cProjectileEntity overrides:
|
||||||
virtual void SpawnOn(cClientHandle & a_Client) override;
|
virtual void SpawnOn(cClientHandle & a_Client) override;
|
||||||
virtual void OnHitEntity(cEntity & a_EntityHit) override;
|
virtual void OnHitEntity(cEntity & a_EntityHit) override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user