summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarchshift <admin@archshift.com>2014-04-26 04:49:08 +0200
committerarchshift <admin@archshift.com>2014-04-26 04:49:08 +0200
commitacff6148b61a64b3d8bec791ca936457fc61a096 (patch)
treef1bd3a0fe1663b036ec9b4ac8a645dd55cdd9e90
parentRemoved unused assignments. (diff)
downloadcuberite-acff6148b61a64b3d8bec791ca936457fc61a096.tar
cuberite-acff6148b61a64b3d8bec791ca936457fc61a096.tar.gz
cuberite-acff6148b61a64b3d8bec791ca936457fc61a096.tar.bz2
cuberite-acff6148b61a64b3d8bec791ca936457fc61a096.tar.lz
cuberite-acff6148b61a64b3d8bec791ca936457fc61a096.tar.xz
cuberite-acff6148b61a64b3d8bec791ca936457fc61a096.tar.zst
cuberite-acff6148b61a64b3d8bec791ca936457fc61a096.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Entity.cpp31
-rw-r--r--src/Entities/Entity.h3
2 files changed, 29 insertions, 5 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 6da6da54e..49e7e45e2 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -381,11 +381,8 @@ int cEntity::GetRawDamageAgainst(const cEntity & a_Receiver)
-int cEntity::GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_DamageType, int a_Damage)
+bool cEntity::ArmorCoversAgainst(eDamageType a_DamageType)
{
- // Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover
-
- // Filter out damage types that are not protected by armor:
// Ref.: http://www.minecraftwiki.net/wiki/Armor#Effects as of 2012_12_20
switch (a_DamageType)
{
@@ -400,9 +397,33 @@ int cEntity::GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_Dama
case dtLightning:
case dtPlugin:
{
- return 0;
+ return false;
+ }
+
+ case dtAttack:
+ case dtArrowAttack:
+ case dtCactusContact:
+ case dtLavaContact:
+ case dtFireContact:
+ case dtEnderPearl:
+ case dtExplosion:
+ {
+ return true;
}
}
+ ASSERT("Invalid damage type!");
+}
+
+
+
+
+
+int cEntity::GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_DamageType, int a_Damage)
+{
+ // Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover
+
+ // Filter out damage types that are not protected by armor:
+ if (!ArmorCoversAgainst(a_DamageType)) return 0;
// Add up all armor points:
// Ref.: http://www.minecraftwiki.net/wiki/Armor#Defense_points as of 2012_12_20
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 86efc5a98..db40f12ed 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -270,6 +270,9 @@ public:
/// Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items
virtual int GetRawDamageAgainst(const cEntity & a_Receiver);
+ // Returns whether armor will protect against the passed damage type
+ virtual bool ArmorCoversAgainst(eDamageType a_DamageType);
+
/// Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover
virtual int GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_DamageType, int a_RawDamage);