Moved switch{} out of GetArmorCoverAgainst().
This commit is contained in:
parent
b2f40a7a11
commit
acff6148b6
@ -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
|
// Ref.: http://www.minecraftwiki.net/wiki/Armor#Effects as of 2012_12_20
|
||||||
switch (a_DamageType)
|
switch (a_DamageType)
|
||||||
{
|
{
|
||||||
@ -400,9 +397,33 @@ int cEntity::GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_Dama
|
|||||||
case dtLightning:
|
case dtLightning:
|
||||||
case dtPlugin:
|
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:
|
// Add up all armor points:
|
||||||
// Ref.: http://www.minecraftwiki.net/wiki/Armor#Defense_points as of 2012_12_20
|
// Ref.: http://www.minecraftwiki.net/wiki/Armor#Defense_points as of 2012_12_20
|
||||||
|
@ -270,6 +270,9 @@ public:
|
|||||||
/// Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items
|
/// Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items
|
||||||
virtual int GetRawDamageAgainst(const cEntity & a_Receiver);
|
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
|
/// 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);
|
virtual int GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_DamageType, int a_RawDamage);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user