summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/ArrowEntity.cpp22
-rw-r--r--src/Entities/ArrowEntity.h1
-rw-r--r--src/Entities/Entity.cpp25
-rw-r--r--src/Entities/Player.cpp20
4 files changed, 61 insertions, 7 deletions
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index c4fd378fb..e71f30a66 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -109,18 +109,32 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
Damage += m_World->GetTickRandomNumber(Damage / 2 + 2);
}
- LOGD("Arrow hit an entity");
int PowerLevel = m_Creator->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchPower);
if (PowerLevel > 0)
{
- LOGD("Arrow hit an entity 2");
int ExtraDamage = 0.25 * (PowerLevel + 1);
Damage += ceil(ExtraDamage);
}
- a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1);
+
+ int KnockbackAmount = 1;
+ int PunchLevel = m_Creator->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchPunch);
+ if (PunchLevel > 0)
+ {
+ Vector3f LookVector = m_Creator->GetLookVector();
+ Vector3f FinalSpeed = Vector3f(0, 0, 0);
+ switch (PunchLevel)
+ {
+ case 1: FinalSpeed = LookVector * Vector3d(5, 0.3, 5);
+ case 2: FinalSpeed = LookVector * Vector3d(8, 0.3, 8);
+ default: break;
+ }
+ a_EntityHit.SetSpeed(FinalSpeed);
+ }
+
+ a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, KnockbackAmount);
- if (m_TicksLeftBurning > 0)
+ if ((m_TicksLeftBurning > 0 && !a_EntityHit.IsSubmerged() && !a_EntityHit.IsSwimming()))
{
a_EntityHit.StartBurning(100);
}
diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h
index 2ea6e9fde..553bcb6e7 100644
--- a/src/Entities/ArrowEntity.h
+++ b/src/Entities/ArrowEntity.h
@@ -91,6 +91,7 @@ protected:
/// If true, the arrow is in the process of being collected - don't go to anyone else
bool m_bIsCollected;
+ // Stores the creator from that arrow
cEntity * m_Creator;
/// Stores the block position that arrow is lodged into, sets m_IsInGround to false if it becomes air
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 398f7703b..05bad3a78 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -316,7 +316,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
// IsOnGround() only is false if the player is moving downwards
// TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain)
-
+ // Thanks to daniel0916
cEnchantments Enchantments = Player->GetEquippedItem().m_Enchantments;
int SharpnessLevel = Enchantments.GetLevel(cEnchantments::enchSharpness);
@@ -372,8 +372,27 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
{
BurnTicks += 4 * (FireAspectLevel - 1);
}
+ if (!IsMob() && !IsSubmerged() && !IsSwimming())
+ {
+ StartBurning(BurnTicks * 20);
+ }
+ else if (IsMob() && !IsSubmerged() && !IsSwimming())
+ {
+ cMonster * Monster = (cMonster *)this;
+ switch (Monster->GetMobType())
+ {
+ case cMonster::mtGhast:
+ case cMonster::mtZombiePigman:
+ case cMonster::mtMagmaCube:
+ {
+
+ break;
+ };
+ default:StartBurning(BurnTicks * 20);
+ }
+ }
- StartBurning(BurnTicks * 20);
+
}
if (!Player->IsOnGround())
@@ -410,7 +429,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
case 2: AdditionalSpeed.Set(8, 0.3, 8); break;
default: break;
}
- AddSpeed(a_TDI.Knockback + AdditionalSpeed);
+ SetSpeed(a_TDI.Knockback + AdditionalSpeed);
}
m_World->BroadcastEntityStatus(*this, esGenericHurt);
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index ab4ff3161..c1031907d 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -17,6 +17,7 @@
#include "../Chunk.h"
#include "../Items/ItemHandler.h"
#include "../Vector3.h"
+#include "../FastRandom.h"
#include "../WorldStorage/StatSerializer.h"
#include "../CompositeChat.h"
@@ -1962,7 +1963,26 @@ void cPlayer::UseEquippedItem(int a_Amount)
{
return;
}
+ cItem Item = GetEquippedItem();
+ int UnbreakingLevel = Item.m_Enchantments.GetLevel(cEnchantments::enchUnbreaking);
+ if (UnbreakingLevel > 0)
+ {
+ int chance;
+ if (ItemCategory::IsArmor(Item.m_ItemType))
+ {
+ chance = 60 + (40 / (UnbreakingLevel + 1));
+ }
+ else
+ {
+ chance = 100 / (UnbreakingLevel + 1);
+ }
+ cFastRandom Random;
+ if (Random.NextInt(100) <= chance)
+ {
+ return;
+ }
+ }
if (GetInventory().DamageEquippedItem(a_Amount))
{
m_World->BroadcastSoundEffect("random.break", GetPosX(), GetPosY(), GetPosZ(), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));