1
0

Plugins can set flying speed.

This commit is contained in:
madmaxoft
2014-03-20 16:14:40 +01:00
parent 9fae50f447
commit b370cacf0c
4 changed files with 124 additions and 80 deletions

View File

@@ -45,6 +45,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
, m_ClientHandle(a_Client)
, m_NormalMaxSpeed(1.0)
, m_SprintingMaxSpeed(1.3)
, m_FlyingMaxSpeed(1.0)
, m_IsCrouched(false)
, m_IsSprinting(false)
, m_IsFlying(false)
@@ -684,7 +685,21 @@ const cSlotNums & cPlayer::GetInventoryPaintSlots(void) const
double cPlayer::GetMaxSpeed(void) const
{
return m_IsSprinting ? m_SprintingMaxSpeed : m_NormalMaxSpeed;
if (m_IsFlying)
{
return m_FlyingMaxSpeed;
}
else
{
if (m_IsSprinting)
{
return m_SprintingMaxSpeed;
}
else
{
return m_NormalMaxSpeed;
}
}
}
@@ -694,7 +709,7 @@ double cPlayer::GetMaxSpeed(void) const
void cPlayer::SetNormalMaxSpeed(double a_Speed)
{
m_NormalMaxSpeed = a_Speed;
if (!m_IsSprinting)
if (!m_IsSprinting && !m_IsFlying)
{
m_ClientHandle->SendPlayerMaxSpeed();
}
@@ -707,7 +722,7 @@ void cPlayer::SetNormalMaxSpeed(double a_Speed)
void cPlayer::SetSprintingMaxSpeed(double a_Speed)
{
m_SprintingMaxSpeed = a_Speed;
if (m_IsSprinting)
if (m_IsSprinting && !m_IsFlying)
{
m_ClientHandle->SendPlayerMaxSpeed();
}
@@ -717,6 +732,18 @@ void cPlayer::SetSprintingMaxSpeed(double a_Speed)
void cPlayer::SetFlyingMaxSpeed(double a_Speed)
{
m_FlyingMaxSpeed = a_Speed;
// Update the flying speed, always:
m_ClientHandle->SendPlayerAbilities();
}
void cPlayer::SetCrouch(bool a_IsCrouched)
{
// Set the crouch status, broadcast to all visible players