From a967313839bab2a5f43befabe689801b949b274e Mon Sep 17 00:00:00 2001 From: "r.ramazanov" Date: Mon, 21 Apr 2014 13:13:25 +0400 Subject: Mobs shouldn't burn when it's Raining #906 --- src/Entities/Entity.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 56ef36ef8..c1926dafc 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -774,12 +774,19 @@ void cEntity::TickBurning(cChunk & a_Chunk) if (GetWorld()->GetWeather() == eWeather_Rain) { - if (HasBeenBurning) + + int PosX = POSX_TOINT - a_Chunk.GetPosX() * cChunkDef::Width, + PosY = POSY_TOINT, + PosZ = POSZ_TOINT - a_Chunk.GetPosZ() * cChunkDef::Width; + + if ((PosY > 0) || (PosY <= cChunkDef::Height)) { - m_TicksLeftBurning = 0; - OnFinishedBurning(); - } - return; + // Inside the world + if (a_Chunk.GetSkyLight(PosX, PosY, PosZ) == 15) + { + m_TicksLeftBurning = 0; + } + } } // Do the burning damage: -- cgit v1.2.3 From 5deb35c5cfc97fc07601fb64ce9631c794237680 Mon Sep 17 00:00:00 2001 From: "r.ramazanov" Date: Wed, 23 Apr 2014 18:15:04 +0400 Subject: Mobs shouldn't burn when it's Raining #906 Mob Knockback is far too much #776 --- src/Entities/Entity.cpp | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index c1926dafc..46bb499b4 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -325,9 +325,32 @@ void cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) m_Health = 0; } - if (IsMob() || IsPlayer()) // Knockback for only players and mobs + if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs { - AddSpeed(a_TDI.Knockback * 2); + int KnockbackLevel = 0; + if (a_TDI.Attacker->GetEquippedWeapon().m_ItemType == E_ITEM_BOW) + { + KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchPunch); + } + else + { + KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback); + } + + Vector3d additionalSpeed(0, 0, 0); + switch (KnockbackLevel) + { + case 1: + additionalSpeed.Set(5, .2, 5); + break; + case 2: + additionalSpeed.Set(8, .2, 8); + break; + default: + additionalSpeed.Set(2, .2, 2); + break; + } + AddSpeed(a_TDI.Knockback * additionalSpeed); } m_World->BroadcastEntityStatus(*this, esGenericHurt); @@ -772,16 +795,14 @@ void cEntity::TickBurning(cChunk & a_Chunk) // Remember the current burning state: bool HasBeenBurning = (m_TicksLeftBurning > 0); - if (GetWorld()->GetWeather() == eWeather_Rain) + if (m_World->IsWeatherWet()) { + int PosX = POSX_TOINT - a_Chunk.GetPosX() * cChunkDef::Width; + int PosY = POSY_TOINT; + int PosZ = POSZ_TOINT - a_Chunk.GetPosZ() * cChunkDef::Width; - int PosX = POSX_TOINT - a_Chunk.GetPosX() * cChunkDef::Width, - PosY = POSY_TOINT, - PosZ = POSZ_TOINT - a_Chunk.GetPosZ() * cChunkDef::Width; - - if ((PosY > 0) || (PosY <= cChunkDef::Height)) + if((POSY_TOINT - 1) == m_World->GetHeight(POSX_TOINT, POSZ_TOINT)) { - // Inside the world if (a_Chunk.GetSkyLight(PosX, PosY, PosZ) == 15) { m_TicksLeftBurning = 0; -- cgit v1.2.3 From a72744f5c33ec11f33637839e4d6206c4aa2fa2a Mon Sep 17 00:00:00 2001 From: "r.ramazanov" Date: Fri, 25 Apr 2014 10:08:36 +0400 Subject: Mobs shouldn't burn when it's Raining & Mob Knockback is far too much --- src/Entities/Entity.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index c09317298..89275a418 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -342,13 +342,13 @@ void cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) switch (KnockbackLevel) { case 1: - additionalSpeed.Set(5, .2, 5); + additionalSpeed.Set(5, .3, 5); break; case 2: - additionalSpeed.Set(8, .2, 8); + additionalSpeed.Set(8, .3, 8); break; default: - additionalSpeed.Set(2, .2, 2); + additionalSpeed.Set(2, .3, 2); break; } AddSpeed(a_TDI.Knockback * additionalSpeed); @@ -802,12 +802,9 @@ void cEntity::TickBurning(cChunk & a_Chunk) int PosY = POSY_TOINT; int PosZ = POSZ_TOINT - a_Chunk.GetPosZ() * cChunkDef::Width; - if((POSY_TOINT - 1) == m_World->GetHeight(POSX_TOINT, POSZ_TOINT)) + if (PosY > m_World->GetHeight(POSX_TOINT, POSZ_TOINT)) { - if (a_Chunk.GetSkyLight(PosX, PosY, PosZ) == 15) - { - m_TicksLeftBurning = 0; - } + m_TicksLeftBurning = 0; } } -- cgit v1.2.3 From 827c3760db5da766a99c42312aa95b43dded9436 Mon Sep 17 00:00:00 2001 From: "r.ramazanov" Date: Fri, 25 Apr 2014 10:58:48 +0400 Subject: Fix for clang --- src/Entities/Entity.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 89275a418..402f94d08 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -798,11 +798,7 @@ void cEntity::TickBurning(cChunk & a_Chunk) if (m_World->IsWeatherWet()) { - int PosX = POSX_TOINT - a_Chunk.GetPosX() * cChunkDef::Width; - int PosY = POSY_TOINT; - int PosZ = POSZ_TOINT - a_Chunk.GetPosZ() * cChunkDef::Width; - - if (PosY > m_World->GetHeight(POSX_TOINT, POSZ_TOINT)) + if (POSY_TOINT > m_World->GetHeight(POSX_TOINT, POSZ_TOINT)) { m_TicksLeftBurning = 0; } -- cgit v1.2.3 From 4cd2d57c643ec2c7dab7a664248dbf65254c1b1d Mon Sep 17 00:00:00 2001 From: "r.ramazanov" Date: Fri, 25 Apr 2014 12:06:22 +0400 Subject: Fix formatting --- src/Entities/Entity.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 402f94d08..d0dd6fb50 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -341,15 +341,21 @@ void cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) Vector3d additionalSpeed(0, 0, 0); switch (KnockbackLevel) { - case 1: - additionalSpeed.Set(5, .3, 5); - break; - case 2: - additionalSpeed.Set(8, .3, 8); - break; - default: - additionalSpeed.Set(2, .3, 2); - break; + case 1: + { + additionalSpeed.Set(5, .3, 5); + break; + } + case 2: + { + additionalSpeed.Set(8, .3, 8); + break; + } + default: + { + additionalSpeed.Set(2, .3, 2); + break; + } } AddSpeed(a_TDI.Knockback * additionalSpeed); } -- cgit v1.2.3