From db65e11d57fb52395a3ba2e9372bdaf29aca691c Mon Sep 17 00:00:00 2001 From: beeduck Date: Mon, 18 Jul 2016 13:10:00 -0700 Subject: Fixes for boat entities (#3265) protocol for vehicles now properly handled, protocol for boat paddles now properly handled, boats can no longer spawn underwater, boats now properly float, boat metadata now properly broadcasted. --- src/Entities/Boat.cpp | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'src/Entities/Boat.cpp') diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp index e81e57529..330e54740 100644 --- a/src/Entities/Boat.cpp +++ b/src/Entities/Boat.cpp @@ -14,7 +14,10 @@ cBoat::cBoat(double a_X, double a_Y, double a_Z) : - super(etBoat, a_X, a_Y, a_Z, 0.98, 0.7) + super(etBoat, a_X, a_Y, a_Z, 0.98, 0.7), + m_LastDamage(0), m_ForwardDirection(0), + m_DamageTaken(0.0f), m_Type(0), + m_RightPaddleUsed(false), m_LeftPaddleUsed(false) { SetMass(20.0f); SetGravity(-16.0f); @@ -37,12 +40,15 @@ void cBoat::SpawnOn(cClientHandle & a_ClientHandle) bool cBoat::DoTakeDamage(TakeDamageInfo & TDI) { + m_LastDamage = 10; if (!super::DoTakeDamage(TDI)) { return false; } - if (GetHealth() == 0) + m_World->BroadcastEntityMetadata(*this); + + if (GetHealth() <= 0) { if (TDI.Attacker != nullptr) { @@ -112,6 +118,14 @@ void cBoat::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) AddSpeedY(0.2); } } + + if (GetLastDamage() > 0) + { + SetLastDamage(GetLastDamage() - 1); + } + + // Broadcast any changes in position + m_World->BroadcastEntityMetadata(*this); } @@ -130,3 +144,23 @@ void cBoat::HandleSpeedFromAttachee(float a_Forward, float a_Sideways) AddSpeed(ToAddSpeed); } + + + + +void cBoat::SetLastDamage(int TimeSinceLastHit) +{ + m_LastDamage = TimeSinceLastHit; +} + + + + + +void cBoat::UpdatePaddles(bool a_RightPaddleUsed, bool a_LeftPaddleUsed) +{ + m_RightPaddleUsed = a_RightPaddleUsed; + m_LeftPaddleUsed = a_LeftPaddleUsed; + + m_World->BroadcastEntityMetadata(*this); +} -- cgit v1.2.3