diff options
author | Mattes D <github@xoft.cz> | 2014-04-26 23:26:59 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-04-26 23:26:59 +0200 |
commit | da931da6037279826a52980f9335e189c370d4d2 (patch) | |
tree | 2935aeea2eab9d1ce7dbf571087d905a4681fae3 /src/Entities/Entity.cpp | |
parent | Merge pull request #863 from mc-server/chunkysparsing (diff) | |
parent | More small fixes. (diff) | |
download | cuberite-da931da6037279826a52980f9335e189c370d4d2.tar cuberite-da931da6037279826a52980f9335e189c370d4d2.tar.gz cuberite-da931da6037279826a52980f9335e189c370d4d2.tar.bz2 cuberite-da931da6037279826a52980f9335e189c370d4d2.tar.lz cuberite-da931da6037279826a52980f9335e189c370d4d2.tar.xz cuberite-da931da6037279826a52980f9335e189c370d4d2.tar.zst cuberite-da931da6037279826a52980f9335e189c370d4d2.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Entities/Entity.cpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index d0dd6fb50..7c8e18b51 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -410,11 +410,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) { @@ -429,9 +426,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 |